├── .gitignore ├── README.md ├── include ├── pnew.cpp ├── new ├── functional ├── slist ├── cctype ├── stl_string_fwd.h ├── utility ├── map ├── set ├── hash_map ├── hash_set ├── list ├── algorithm ├── stack ├── deque ├── vector ├── basic_definitions ├── queue ├── avr_config.h ├── iterator ├── numeric ├── stl_relops.h ├── cstddef ├── locale ├── stl_ctraits_fns.h ├── stl_range_errors.h ├── stl_raw_storage_iter.h ├── stl_hash_fun.h ├── iostream ├── stl_pair.h ├── lcdostream ├── memory ├── stl_construct.h ├── iosfwd ├── iomanip ├── stl_stack.h ├── char_traits.h ├── stl_tempbuf.h ├── serstream ├── sequence_concepts.h ├── stl_queue.h ├── stl_numeric.h ├── streambuf ├── stl_uninitialized.h ├── stl_set.h ├── container_concepts.h ├── stl_multiset.h ├── stl_heap.h ├── istream_helpers └── stl_multimap.h ├── examples ├── test_string.cpp ├── test_bitset.cpp ├── test_serial.cpp ├── test_list.cpp ├── test_stack.cpp ├── test_vector.cpp ├── test_set.cpp ├── test_map.cpp └── makefile └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.elf 3 | *.o 4 | *.hex 5 | *.d 6 | /Debug/ 7 | .cproject 8 | .project 9 | .settings/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The C++ Standard Template Library for the Arduino 2 | 3 | This is the source code that accompanies my [blog article](http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/) regarding porting the SGI C++ STL to the Arduino. Please read the article for full details. 4 | -------------------------------------------------------------------------------- /include/pnew.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * pnew.cpp 3 | * 4 | * Created on: 24 Dec 2011 5 | * Author: Andy Brown 6 | */ 7 | 8 | /** 9 | * Global placement operator new 10 | */ 11 | 12 | void* operator new(size_t size_,void *ptr_) 13 | { 14 | return ptr_; 15 | } 16 | 17 | void operator delete(void *ptr_, size_t size_) 18 | { 19 | free(ptr_); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /include/new: -------------------------------------------------------------------------------- 1 | /* 2 | * new 3 | * 4 | * Created on: 1 Jan 2011 5 | * Author: Andy Brown 6 | */ 7 | 8 | #ifndef __1F3E89E5_F35D_4f8d_A849_9A3416814905 9 | #define __1F3E89E5_F35D_4f8d_A849_9A3416814905 10 | 11 | 12 | void *operator new(size_t size_); 13 | void* operator new(size_t size_,void *ptr_); 14 | void operator delete(void *ptr_); 15 | void operator delete(void *ptr_, unsigned int size); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /examples/test_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | * Test std::string 9 | */ 10 | 11 | struct TestString { 12 | 13 | static void RunTest() { 14 | 15 | std::ohserialstream serial(Serial); 16 | std::string str; 17 | char c; 18 | 19 | for(c='A';c<='Z';c++) 20 | str+=c; 21 | 22 | serial << str << std::endl; 23 | } 24 | 25 | }; 26 | 27 | TestString s; 28 | 29 | void setup() { 30 | Serial.begin(115200); 31 | } 32 | 33 | void loop() { 34 | delay(1000); 35 | s.RunTest(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /examples/test_bitset.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | * Test std::bitset 10 | */ 11 | 12 | struct TestBitset { 13 | 14 | static void RunTest() { 15 | 16 | std::ohserialstream serial(Serial); 17 | 18 | std::bitset<64> mybits(0); 19 | 20 | // set bits 63 and 31 using 21 | // different methods 22 | 23 | mybits[63]=1; 24 | mybits|=0x80000000; 25 | 26 | serial << mybits << std::endl; 27 | } 28 | 29 | }; 30 | 31 | TestBitset b; 32 | 33 | void setup() { 34 | Serial.begin(115200); 35 | } 36 | 37 | void loop() { 38 | delay(1000); 39 | b.RunTest(); 40 | } 41 | -------------------------------------------------------------------------------- /examples/test_serial.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include // for setprecision() 7 | #include 8 | 9 | /* 10 | * Run some tests on the hardware serial stream 11 | */ 12 | 13 | struct TestSerial { 14 | 15 | static void RunTest() { 16 | 17 | std::ohserialstream serial(Serial); 18 | 19 | serial << "Hello world" << std::endl 20 | << "Floating point: " 21 | << std::setprecision(3) << 3.14159 << std::endl; 22 | } 23 | }; 24 | 25 | TestSerial s; 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | } 30 | 31 | void loop() { 32 | delay(1000); 33 | s.RunTest(); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /examples/test_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | * Test std::list 10 | */ 11 | 12 | struct TestList { 13 | 14 | static void RunTest() { 15 | 16 | std::ohserialstream serial(Serial); 17 | std::list lst; 18 | std::list::const_iterator it; 19 | int i; 20 | 21 | for(i=0;i<50;i++) 22 | lst.push_back(i); 23 | 24 | for(it=lst.begin();it!=lst.end();it++) 25 | serial << *it << ' '; 26 | 27 | serial << std::endl; 28 | } 29 | 30 | }; 31 | 32 | TestList l; 33 | 34 | void setup() { 35 | Serial.begin(115200); 36 | } 37 | 38 | void loop() { 39 | delay(1000); 40 | l.RunTest(); 41 | } 42 | -------------------------------------------------------------------------------- /examples/test_stack.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Test std::stack 11 | */ 12 | 13 | struct TestStack { 14 | 15 | static void RunTest() { 16 | 17 | std::ohserialstream serial(Serial); 18 | std::stack > stk; 19 | int i; 20 | 21 | for(i=0;i<20;i++) 22 | stk.push(i); 23 | 24 | while(!stk.empty()) { 25 | serial << stk.top() << ' '; 26 | stk.pop(); 27 | } 28 | 29 | serial << std::endl; 30 | } 31 | }; 32 | 33 | TestStack s; 34 | 35 | void setup() { 36 | Serial.begin(115200); 37 | } 38 | 39 | void loop() { 40 | delay(1000); 41 | s.RunTest(); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /examples/test_vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | * Test std::vector 10 | */ 11 | 12 | struct TestVector { 13 | 14 | static void RunTest() { 15 | 16 | std::ohserialstream serial(Serial); 17 | std::vector vec; 18 | std::vector::const_iterator it; 19 | int i; 20 | 21 | vec.reserve(50); 22 | for(i=0;i<50;i++) 23 | vec.push_back(i); 24 | 25 | for(it=vec.begin();it!=vec.end();it++) 26 | serial << *it << " "; 27 | 28 | serial << "OK" << std::endl; 29 | } 30 | 31 | }; 32 | 33 | TestVector v; 34 | 35 | void setup() { 36 | Serial.begin(115200); 37 | } 38 | 39 | void loop() { 40 | delay(1000); 41 | v.RunTest(); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /examples/test_set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | * Test std::set 9 | */ 10 | 11 | struct TestSet { 12 | 13 | static void RunTest() { 14 | 15 | std::ohserialstream serial(Serial); 16 | 17 | std::set s1,s2; 18 | int i; 19 | 20 | for(i=0;i<10;i++) 21 | s1.insert(i); 22 | 23 | for(i=5;i<15;i++) 24 | s2.insert(i); 25 | 26 | std::set_intersection( 27 | s1.begin(),s1.end(), 28 | s2.begin(),s2.end(), 29 | std::ostream_iterator(serial," ")); 30 | 31 | serial << std::endl; 32 | } 33 | }; 34 | 35 | 36 | TestSet s; 37 | 38 | void setup() { 39 | Serial.begin(115200); 40 | } 41 | 42 | void loop() { 43 | delay(1000); 44 | s.RunTest(); 45 | } 46 | -------------------------------------------------------------------------------- /examples/test_map.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | 8 | /* 9 | * Test std::map 10 | */ 11 | 12 | struct TestMap { 13 | 14 | static void RunTest() { 15 | 16 | std::ohserialstream serial(Serial); 17 | 18 | std::map days; 19 | int i; 20 | 21 | days[1]="Monday"; 22 | days[2]="Tuesday"; 23 | days[3]="Wednesday"; 24 | days[4]="Thursday"; 25 | days[5]="Friday"; 26 | days[6]="Saturday"; 27 | days[7]="Sunday"; 28 | 29 | for(i=1;i<=7;i++) 30 | serial << days[i] << std::endl; 31 | 32 | serial << std::endl; 33 | } 34 | }; 35 | 36 | TestMap m; 37 | 38 | void setup() { 39 | Serial.begin(115200); 40 | } 41 | 42 | void loop() { 43 | delay(1000); 44 | m.RunTest(); 45 | } 46 | -------------------------------------------------------------------------------- /include/functional: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_FUNCTIONAL 16 | #define __SGI_STL_FUNCTIONAL 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #endif /* __SGI_STL_FUNCTIONAL */ 23 | 24 | // Local Variables: 25 | // mode:C++ 26 | // End: 27 | -------------------------------------------------------------------------------- /include/slist: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_SLIST 16 | #define __SGI_STL_SLIST 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #endif /* __SGI_STL_SLIST */ 25 | 26 | // Local Variables: 27 | // mode:C++ 28 | // End: 29 | -------------------------------------------------------------------------------- /include/cctype: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | 21 | namespace std{ 22 | 23 | using ::isalnum; 24 | using ::isalpha; 25 | using ::iscntrl; 26 | using ::isdigit; 27 | using ::isgraph; 28 | using ::islower; 29 | using ::isprint; 30 | using ::ispunct; 31 | using ::isspace; 32 | using ::isupper; 33 | using ::isxdigit; 34 | using ::tolower; 35 | using ::toupper; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /include/stl_string_fwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_STRING_FWD_H 15 | #define __SGI_STL_STRING_FWD_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | __STL_BEGIN_NAMESPACE 23 | 24 | template , 26 | class _Alloc = __STL_DEFAULT_ALLOCATOR(_CharT) > 27 | class basic_string; 28 | 29 | typedef basic_string string; 30 | typedef basic_string wstring; 31 | 32 | static const char* __get_c_string(const string&); 33 | 34 | __STL_END_NAMESPACE 35 | 36 | #endif /* __SGI_STL_STRING_FWD_H */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | License 2 | 3 | Copyright (c) 2011-2022 Andrew Brown. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 11 | 12 | * The name of Andrew Brown may not be used to endorse or promote products derived from this software without specific prior written permission. 13 | 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDREW BROWN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | -------------------------------------------------------------------------------- /include/utility: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_UTILITY 28 | #define __SGI_STL_UTILITY 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #endif /* __SGI_STL_UTILITY */ 35 | 36 | // Local Variables: 37 | // mode:C++ 38 | // End: 39 | -------------------------------------------------------------------------------- /include/map: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_MAP 28 | #define __SGI_STL_MAP 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_MAP */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/set: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_SET 28 | #define __SGI_STL_SET 29 | 30 | #ifndef __SGI_STL_INTERNAL_TREE_H 31 | #include 32 | #endif 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_SET */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/hash_map: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_MAP 28 | #define __SGI_STL_HASH_MAP 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | 36 | #endif /* __SGI_STL_HASH_MAP */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/hash_set: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | #ifndef __SGI_STL_HASH_SET 28 | #define __SGI_STL_HASH_SET 29 | 30 | #ifndef __SGI_STL_INTERNAL_HASHTABLE_H 31 | #include 32 | #endif 33 | 34 | #include 35 | 36 | #endif /* __SGI_STL_HASH_SET */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/list: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_LIST 28 | #define __SGI_STL_LIST 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_LIST */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/algorithm: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_ALGORITHM 28 | #define __SGI_STL_ALGORITHM 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #endif /* __SGI_STL_ALGORITHM */ 37 | 38 | // Local Variables: 39 | // mode:C++ 40 | // End: 41 | -------------------------------------------------------------------------------- /include/stack: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_STACK 28 | #define __SGI_STL_STACK 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif /* __SGI_STL_STACK */ 38 | 39 | // Local Variables: 40 | // mode:C++ 41 | // End: 42 | -------------------------------------------------------------------------------- /include/deque: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_DEQUE 28 | #define __SGI_STL_DEQUE 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif /* __SGI_STL_DEQUE */ 38 | 39 | // Local Variables: 40 | // mode:C++ 41 | // End: 42 | -------------------------------------------------------------------------------- /include/vector: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_VECTOR 28 | #define __SGI_STL_VECTOR 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #endif /* __SGI_STL_VECTOR */ 39 | 40 | // Local Variables: 41 | // mode:C++ 42 | // End: 43 | -------------------------------------------------------------------------------- /include/basic_definitions: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | This file is part of the uClibc++ Library. 3 | This library is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU Lesser General Public 5 | License as published by the Free Software Foundation; either 6 | version 2.1 of the License, or (at your option) any later version. 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; if not, write to the Free Software 15 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | */ 17 | 18 | #ifndef __BASIC_DEFINITIONS 19 | #define __BASIC_DEFINITIONS 1 20 | 21 | #pragma GCC visibility push(default) 22 | 23 | //The following is used to support GCC symbol visibility patch 24 | 25 | #define _UCXXEXPORT __attribute__ ((visibility("default"))) 26 | #define _UCXXLOCAL __attribute__ ((visibility("hidden"))) 27 | #define __UCLIBCXX_NORETURN __attribute__ ((__noreturn__)) 28 | #define __UCLIBCXX_TLS 29 | 30 | 31 | //Testing purposes 32 | #define __STRING_MAX_UNITS 65535 33 | 34 | namespace std{ 35 | typedef signed long int streamsize; 36 | } 37 | 38 | #pragma GCC visibility pop 39 | 40 | #endif 41 | 42 | 43 | #ifdef __DODEBUG__ 44 | #define UCLIBCXX_DEBUG 1 45 | #else 46 | #define UCLIBCXX_DEBUG 0 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/queue: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_QUEUE 28 | #define __SGI_STL_QUEUE 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #endif /* __SGI_STL_QUEUE */ 42 | 43 | // Local Variables: 44 | // mode:C++ 45 | // End: 46 | -------------------------------------------------------------------------------- /include/avr_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * avr_config.h 3 | * Contains values that you can change to customize the way that the library behaves 4 | * 5 | * Created on: 1 Jan 2011 6 | * Author: Andy Brown 7 | */ 8 | 9 | #ifndef __C4BCBBDE_67BC_4bb4_A5E1_7745E49AF0B6 10 | #define __C4BCBBDE_67BC_4bb4_A5E1_7745E49AF0B6 11 | 12 | #include 13 | 14 | 15 | namespace avrstl { 16 | 17 | // default alloc-ahead for vectors. quoting from the SGI docs: 18 | // 19 | // "It is crucial that the amount of growth is proportional to the current capacity(), 20 | // rather than a fixed constant: in the former case inserting a series of elements 21 | // into a vector is a linear time operation, and in the latter case it is quadratic." 22 | // 23 | // If this advice pertains to you, then uncomment the first line and comment out the second. 24 | // The default here in avr-land is to assume that memory is scarce. 25 | 26 | // template size_t AvrVectorAllocAhead(size_t oldSize_) { return 2*oldSize_; } 27 | template size_t AvrVectorAllocAhead(size_t oldSize_) { return 20+oldSize_; } 28 | // template<> size_t AvrVectorAllocAhead(size_t oldSize_) { return 20+oldSize_; } // sample specialization for char 29 | 30 | // minimum buffer size allocated ahead by a deque 31 | 32 | inline size_t AvrDequeBufferSize() { return 20; } 33 | 34 | // alloc-ahead additional memory increment for strings. The default SGI implementation will add 35 | // the old size, doubling memory each time. We don't have memory to burn, so add 20 types each time 36 | 37 | template size_t AvrStringAllocAheadIncrement(size_t oldSize_) { return 20; } 38 | } 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/iterator: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_ITERATOR 28 | #define __SGI_STL_ITERATOR 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifdef __STL_USE_NEW_IOSTREAMS 35 | #include 36 | #else /* __STL_USE_NEW_IOSTREAMS */ 37 | #include 38 | #endif /* __STL_USE_NEW_IOSTREAMS */ 39 | 40 | #include 41 | #include 42 | 43 | #endif /* __SGI_STL_ITERATOR */ 44 | 45 | // Local Variables: 46 | // mode:C++ 47 | // End: 48 | -------------------------------------------------------------------------------- /include/numeric: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | #ifndef __SGI_STL_NUMERIC 28 | #define __SGI_STL_NUMERIC 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #ifndef __AVR__ 35 | #ifdef __STL_USE_NEW_IOSTREAMS 36 | #include 37 | #else /* __STL_USE_NEW_IOSTREAMS */ 38 | #include 39 | #endif /* __STL_USE_NEW_IOSTREAMS */ 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #endif /* __SGI_STL_NUMERIC */ 48 | 49 | // Local Variables: 50 | // mode:C++ 51 | // End: 52 | -------------------------------------------------------------------------------- /include/stl_relops.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * Copyright (c) 1996,1997 15 | * Silicon Graphics 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Silicon Graphics makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_RELOPS 32 | #define __SGI_STL_INTERNAL_RELOPS 33 | 34 | __STL_BEGIN_RELOPS_NAMESPACE 35 | 36 | template 37 | inline bool operator!=(const _Tp& __x, const _Tp& __y) { 38 | return !(__x == __y); 39 | } 40 | 41 | template 42 | inline bool operator>(const _Tp& __x, const _Tp& __y) { 43 | return __y < __x; 44 | } 45 | 46 | template 47 | inline bool operator<=(const _Tp& __x, const _Tp& __y) { 48 | return !(__y < __x); 49 | } 50 | 51 | template 52 | inline bool operator>=(const _Tp& __x, const _Tp& __y) { 53 | return !(__x < __y); 54 | } 55 | 56 | __STL_END_RELOPS_NAMESPACE 57 | 58 | #endif /* __SGI_STL_INTERNAL_RELOPS */ 59 | 60 | // Local Variables: 61 | // mode:C++ 62 | // End: 63 | -------------------------------------------------------------------------------- /include/cstddef: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- forwarding header. 2 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. 4 | // 5 | // This file is part of the GNU ISO C++ Library. This library is free 6 | // software; you can redistribute it and/or modify it under the 7 | // terms of the GNU General Public License as published by the 8 | // Free Software Foundation; either version 2, or (at your option) 9 | // any later version. 10 | 11 | // This library is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | 16 | // You should have received a copy of the GNU General Public License along 17 | // with this library; see the file COPYING. If not, write to the Free 18 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 | // USA. 20 | 21 | // As a special exception, you may use this file as part of a free software 22 | // library without restriction. Specifically, if other files instantiate 23 | // templates or use macros or inline functions from this file, or you compile 24 | // this file and link it with other files to produce an executable, this 25 | // file does not by itself cause the resulting executable to be covered by 26 | // the GNU General Public License. This exception does not however 27 | // invalidate any other reasons why the executable file might be covered by 28 | // the GNU General Public License. 29 | 30 | // 31 | // ISO C++ 14882: 18.1 Types 32 | // 33 | 34 | /** @file cstddef 35 | * This is a Standard C++ Library file. You should @c #include this file 36 | * in your programs, rather than any of the "*.h" implementation files. 37 | * 38 | * This is the C++ version of the Standard C Library header @c stddef.h, 39 | * and its contents are (mostly) the same as that header, but are all 40 | * contained in the namespace @c std. 41 | */ 42 | 43 | #ifndef _CPP_CSTDDEF 44 | #define _CPP_CSTDDEF 1 45 | 46 | #ifdef __GCC__ 47 | #pragma GCC system_header 48 | #endif 49 | 50 | #include 51 | 52 | namespace std 53 | { 54 | using ::ptrdiff_t; 55 | using ::size_t; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/locale: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #ifndef __AVR__ 24 | #include 25 | #endif 26 | 27 | #ifndef __HEADER_STD_LOCALE 28 | #define __HEADER_STD_LOCALE 1 29 | 30 | #pragma GCC visibility push(default) 31 | 32 | namespace std{ 33 | class _UCXXEXPORT locale { 34 | public: 35 | // types: 36 | class facet; 37 | class id; 38 | typedef unsigned char category; 39 | 40 | static const category 41 | none = 0, 42 | collate = 0x01, ctype = 0x02, 43 | monetary = 0x04, numeric = 0x08, 44 | time = 0x10, messages = 0x20, 45 | all = collate | ctype | monetary | numeric | time | messages; 46 | 47 | // construct/copy/destroy: 48 | locale() throw(){ 49 | return; 50 | } 51 | locale(const locale& other) throw(){ 52 | (void)other; 53 | return; 54 | } 55 | locale(const char *) throw(){ 56 | return; 57 | } 58 | ~locale() throw(){ 59 | return; 60 | } 61 | 62 | const locale& operator=(const locale&) throw(){ 63 | return *this; 64 | } 65 | #ifndef __AVR__ 66 | std::string name() const { return "C"; } 67 | #endif 68 | }; 69 | 70 | class _UCXXEXPORT locale::facet { 71 | friend class locale; 72 | explicit facet(size_t = 0){ 73 | return; 74 | } 75 | virtual ~facet(){ 76 | return; 77 | } 78 | }; 79 | 80 | class _UCXXEXPORT locale::id { 81 | id(){ } 82 | }; 83 | 84 | } 85 | 86 | #pragma GCC visibility pop 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /include/stl_ctraits_fns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | // WARNING: This is an internal header file, included by other C++ 15 | // standard library headers. You should not attempt to use this header 16 | // file directly. 17 | 18 | #ifndef __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H 19 | #define __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H 20 | 21 | // This file contains a few small adapters that allow a character 22 | // traits class to be used as a function object. 23 | 24 | __STL_BEGIN_NAMESPACE 25 | 26 | template 27 | struct _Eq_traits 28 | : public binary_function 31 | { 32 | bool operator()(const typename _Traits::char_type& __x, 33 | const typename _Traits::char_type& __y) const 34 | { return _Traits::eq(__x, __y); } 35 | }; 36 | 37 | template 38 | struct _Eq_int_traits 39 | : public binary_function 42 | { 43 | bool operator()(const typename _Traits::char_type& __x, 44 | const typename _Traits::int_type& __y) const 45 | { return _Traits::eq_int_type(_Traits::to_int_type(__x), __y); } 46 | }; 47 | 48 | template 49 | struct _Lt_traits 50 | : public binary_function 53 | { 54 | bool operator()(const typename _Traits::char_type& __x, 55 | const typename _Traits::char_type& __y) const 56 | { return _Traits::lt(__x, __y); } 57 | }; 58 | 59 | __STL_END_NAMESPACE 60 | 61 | #endif /* __SGI_STL_INTERNAL_CTRAITS_FUNCTIONS_H */ 62 | 63 | // Local Variables: 64 | // mode:C++ 65 | // End: 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /include/stl_range_errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 3 | * Silicon Graphics 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __STL_RANGE_ERRORS_H 16 | #define __STL_RANGE_ERRORS_H 17 | 18 | // A few places in the STL throw range errors, using standard exception 19 | // classes defined in . This header file provides functions 20 | // to throw those exception objects. 21 | 22 | // __STL_DONT_THROW_RANGE_ERRORS is a hook so that users can disable 23 | // this exception throwing. 24 | 25 | #include 26 | 27 | #if defined(__STL_CAN_THROW_RANGE_ERRORS) && \ 28 | defined(__STL_USE_EXCEPTIONS) && \ 29 | !defined(__STL_DONT_THROW_RANGE_ERRORS) 30 | # define __STL_THROW_RANGE_ERRORS 31 | #endif 32 | 33 | // For the SGI 7.3 compiler, declare these functions here and define them 34 | // elsewhere. 35 | #if defined(__STL_THROW_RANGE_ERRORS) && \ 36 | defined(__sgi) && !defined(__GNUC__) && \ 37 | _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) 38 | 39 | __STL_BEGIN_NAMESPACE 40 | void __stl_throw_range_error(const char* __msg); 41 | void __stl_throw_length_error(const char* __msg); 42 | __STL_END_NAMESPACE 43 | 44 | // For other compilers where we're throwing range errors, include the 45 | // stdexcept header and throw the appropriate exceptions directly. 46 | #elif defined(__STL_THROW_RANGE_ERRORS) 47 | 48 | #include 49 | 50 | __STL_BEGIN_NAMESPACE 51 | inline void __stl_throw_range_error(const char* __msg) 52 | { throw range_error(__msg); } 53 | inline void __stl_throw_length_error(const char* __msg) 54 | { throw length_error(__msg); } 55 | __STL_END_NAMESPACE 56 | 57 | // Otherwise, define inline functions that do nothing. 58 | #else 59 | 60 | __STL_BEGIN_NAMESPACE 61 | inline void __stl_throw_range_error(const char*) {} 62 | inline void __stl_throw_length_error(const char*) {} 63 | __STL_END_NAMESPACE 64 | 65 | #endif 66 | 67 | #endif /* __STL_RANGE_ERRORS_H */ 68 | 69 | // Local Variables: 70 | // mode:C++ 71 | // End: 72 | -------------------------------------------------------------------------------- /examples/makefile: -------------------------------------------------------------------------------- 1 | CXX=avr-g++ 2 | 3 | ARDUINO_DIR=/opt/arduino 4 | ARDUINO_CORE_DIR=/home/gionata/workspace_Arduino/Core/ArduinoCore 5 | PROJECT_DIR=.. 6 | 7 | # avr tools path 8 | AVR_OBJCOPY=avr-objcopy 9 | AVR_SIZE=avr-size 10 | AVRDUDE=$(ARDUINO_DIR)/hardware/tools/avrdude 11 | 12 | 13 | # CPU type and speed 14 | MCU=atmega328p 15 | CPU_SPEED=16000000UL 16 | 17 | # Arduino USB port for Linux 18 | PORT=/dev/ttyACM0 19 | 20 | 21 | # Include (dependencies: avr-stl, arduino) 22 | INCLUDE=-I../include -I$(ARDUINO_CORE_DIR) 23 | 24 | # Libraries (dependencies: unocore) 25 | LIBS=-L$(ARDUINO_CORE_DIR)/Arduino_Uno -lunocore 26 | 27 | # Executable name 28 | TARGET=testSTL 29 | 30 | CFLAGS=-Wall -Wno-unused-local-typedefs -Os -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields\ 31 | -fno-exceptions -ffunction-sections -fdata-sections -fno-use-cxa-atexit -mmcu=$(MCU) -DF_CPU=$(CPU_SPEED) \ 32 | -MMD -MP -MF"$(OBJ).d" -MT"$(OBJ).d" 33 | 34 | CLINKFLAGS=-Wl,-Map,$(TARGET).map,--cref -Wl,-gc-sections -mmcu=$(MCU) 35 | 36 | vector: OBJ=test_vector 37 | vector: clean build sizedummy upload 38 | 39 | string: OBJ=test_string 40 | string: clean build sizedummy upload 41 | 42 | serial: OBJ=test_serial 43 | serial: clean build sizedummy upload 44 | 45 | stack: OBJ=test_stack 46 | stack: clean build sizedummy upload 47 | 48 | bitset: OBJ=test_bitset 49 | bitset: clean build sizedummy upload 50 | 51 | list: OBJ=test_list 52 | list: clean build sizedummy upload 53 | 54 | set: OBJ=test_set 55 | set: clean build sizedummy upload 56 | 57 | map: OBJ=test_map 58 | map: clean build sizedummy upload 59 | 60 | build: $(TARGET).hex 61 | 62 | $(TARGET).hex: $(TARGET).elf 63 | @echo 'Create Flash image (ihex format)' 64 | $(AVR_OBJCOPY) -R .eeprom -O ihex $< $@ 65 | @echo 'Finished building target: $@' 66 | @echo ' ' 67 | 68 | $(TARGET).elf: 69 | make -e $(OBJ).o 70 | @echo 'Building target: $@' 71 | @echo 'Invoking: AVR C++ Linker' 72 | $(CXX) $(CLINKFLAGS) $(INCLUDE) $(OBJ).o -o $@ $(LIBS) 73 | @echo 'Finished building target: $@' 74 | @echo ' ' 75 | 76 | %.o: %.cpp 77 | $(CXX) $< $(CFLAGS) $(INCLUDE) -c -o $@ 78 | 79 | upload: 80 | @echo 'Invoking: AVRDude' 81 | $(AVRDUDE) -C $(AVRDUDE).conf -pm328p -carduino -P$(PORT) -b115200 -Uflash:w:$(TARGET).hex:a 82 | @echo 'Finished building: $@' 83 | @echo ' ' 84 | 85 | sizedummy: $(TARGET).elf 86 | @echo 'Invoking: Print Size' 87 | $(AVR_SIZE) --format=avr --mcu=$(MCU) $(TARGET).elf 88 | @echo 'Finished building: $@' 89 | @echo ' ' 90 | 91 | clean: 92 | @echo -n Cleaning ... 93 | $(shell rm $(TARGET).elf 2> /dev/null) 94 | $(shell rm $(TARGET).hex 2> /dev/null) 95 | $(shell rm $(TARGET).map 2> /dev/null) 96 | $(shell rm *.o 2> /dev/null) 97 | $(shell rm *.d 2> /dev/null) 98 | @echo " done" 99 | 100 | -------------------------------------------------------------------------------- /include/stl_raw_storage_iter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H 32 | #define __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H 33 | 34 | __STL_BEGIN_NAMESPACE 35 | 36 | template 37 | class raw_storage_iterator { 38 | protected: 39 | _ForwardIterator _M_iter; 40 | public: 41 | typedef output_iterator_tag iterator_category; 42 | typedef void value_type; 43 | typedef void difference_type; 44 | typedef void pointer; 45 | typedef void reference; 46 | 47 | explicit raw_storage_iterator(_ForwardIterator __x) : _M_iter(__x) {} 48 | raw_storage_iterator& operator*() { return *this; } 49 | raw_storage_iterator& operator=(const _Tp& __element) { 50 | construct(&*_M_iter, __element); 51 | return *this; 52 | } 53 | raw_storage_iterator<_ForwardIterator, _Tp>& operator++() { 54 | ++_M_iter; 55 | return *this; 56 | } 57 | raw_storage_iterator<_ForwardIterator, _Tp> operator++(int) { 58 | raw_storage_iterator<_ForwardIterator, _Tp> __tmp = *this; 59 | ++_M_iter; 60 | return __tmp; 61 | } 62 | }; 63 | 64 | #ifndef __STL_CLASS_PARTIAL_SPECIALIZATION 65 | 66 | template 67 | inline output_iterator_tag 68 | iterator_category(const raw_storage_iterator<_ForwardIterator, _Tp>&) 69 | { 70 | return output_iterator_tag(); 71 | } 72 | 73 | #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ 74 | 75 | __STL_END_NAMESPACE 76 | 77 | #endif /* __SGI_STL_INTERNAL_RAW_STORAGE_ITERATOR_H */ 78 | 79 | // Local Variables: 80 | // mode:C++ 81 | // End: 82 | -------------------------------------------------------------------------------- /include/stl_hash_fun.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-1998 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | * 14 | * Copyright (c) 1994 15 | * Hewlett-Packard Company 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Hewlett-Packard Company makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | * 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_HASH_FUN_H 32 | #define __SGI_STL_HASH_FUN_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | template struct hash { }; 39 | 40 | inline size_t __stl_hash_string(const char* __s) 41 | { 42 | unsigned long __h = 0; 43 | for ( ; *__s; ++__s) 44 | __h = 5*__h + *__s; 45 | 46 | return size_t(__h); 47 | } 48 | 49 | __STL_TEMPLATE_NULL struct hash 50 | { 51 | size_t operator()(const char* __s) const { return __stl_hash_string(__s); } 52 | }; 53 | 54 | __STL_TEMPLATE_NULL struct hash 55 | { 56 | size_t operator()(const char* __s) const { return __stl_hash_string(__s); } 57 | }; 58 | 59 | __STL_TEMPLATE_NULL struct hash { 60 | size_t operator()(char __x) const { return __x; } 61 | }; 62 | __STL_TEMPLATE_NULL struct hash { 63 | size_t operator()(unsigned char __x) const { return __x; } 64 | }; 65 | __STL_TEMPLATE_NULL struct hash { 66 | size_t operator()(unsigned char __x) const { return __x; } 67 | }; 68 | __STL_TEMPLATE_NULL struct hash { 69 | size_t operator()(short __x) const { return __x; } 70 | }; 71 | __STL_TEMPLATE_NULL struct hash { 72 | size_t operator()(unsigned short __x) const { return __x; } 73 | }; 74 | __STL_TEMPLATE_NULL struct hash { 75 | size_t operator()(int __x) const { return __x; } 76 | }; 77 | __STL_TEMPLATE_NULL struct hash { 78 | size_t operator()(unsigned int __x) const { return __x; } 79 | }; 80 | __STL_TEMPLATE_NULL struct hash { 81 | size_t operator()(long __x) const { return __x; } 82 | }; 83 | __STL_TEMPLATE_NULL struct hash { 84 | size_t operator()(unsigned long __x) const { return __x; } 85 | }; 86 | 87 | __STL_END_NAMESPACE 88 | 89 | #endif /* __SGI_STL_HASH_FUN_H */ 90 | 91 | // Local Variables: 92 | // mode:C++ 93 | // End: 94 | -------------------------------------------------------------------------------- /include/iostream: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | 22 | #ifndef __HEADER_STD_IOSTREAM 23 | #define __HEADER_STD_IOSTREAM 1 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifndef __AVR__ 31 | #include 32 | #include 33 | #endif 34 | 35 | 36 | #pragma GCC visibility push(default) 37 | 38 | namespace std{ 39 | #ifdef __UCLIBCXX_SUPPORT_CIN__ 40 | extern istream cin; 41 | #endif 42 | #ifdef __UCLIBCXX_SUPPORT_COUT__ 43 | extern ostream cout; 44 | #endif 45 | #ifdef __UCLIBCXX_SUPPORT_CERR__ 46 | extern ostream cerr; 47 | #endif 48 | #ifdef __UCLIBCXX_SUPPORT_CLOG__ 49 | extern ostream clog; 50 | #endif 51 | #ifdef __UCLIBCXX_SUPPORT_WCIN__ 52 | extern wistream wcin; 53 | #endif 54 | #ifdef __UCLIBCXX_SUPPORT_WCOUT__ 55 | extern wostream wcout; 56 | #endif 57 | #ifdef __UCLIBCXX_SUPPORT_WCERR__ 58 | extern wostream wcerr; 59 | #endif 60 | #ifdef __UCLIBCXX_SUPPORT_WCLOG__ 61 | extern wostream wclog; 62 | #endif 63 | 64 | 65 | template class _UCXXEXPORT basic_iostream : 66 | public basic_istream, public basic_ostream 67 | { 68 | public: 69 | // constructor/destructor 70 | explicit _UCXXEXPORT basic_iostream(basic_streambuf* sb); 71 | virtual _UCXXEXPORT ~basic_iostream(); //Below 72 | }; 73 | 74 | template _UCXXEXPORT 75 | basic_iostream:: basic_iostream(basic_streambuf* sb) 76 | : basic_ios(sb), basic_istream(sb), basic_ostream(sb) 77 | { 78 | return; 79 | } 80 | 81 | 82 | template _UCXXEXPORT basic_iostream::~basic_iostream(){ 83 | return; 84 | } 85 | 86 | 87 | #ifdef __UCLIBCXX_EXPAND_OSTREAM_CHAR__ 88 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 89 | #ifndef __UCLIBCXX_COMPILE_IOSTREAM__ 90 | 91 | template <> _UCXXEXPORT basic_iostream >:: 92 | basic_iostream(basic_streambuf >* sb); 93 | template <> _UCXXEXPORT basic_iostream >::~basic_iostream(); 94 | 95 | #endif 96 | #endif 97 | #endif 98 | 99 | 100 | 101 | } 102 | 103 | #pragma GCC visibility pop 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /include/stl_pair.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_PAIR_H 32 | #define __SGI_STL_INTERNAL_PAIR_H 33 | 34 | __STL_BEGIN_NAMESPACE 35 | 36 | template 37 | struct pair { 38 | typedef _T1 first_type; 39 | typedef _T2 second_type; 40 | 41 | _T1 first; 42 | _T2 second; 43 | pair() : first(_T1()), second(_T2()) {} 44 | pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} 45 | 46 | #ifdef __STL_MEMBER_TEMPLATES 47 | template 48 | pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} 49 | #endif 50 | }; 51 | 52 | template 53 | inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) 54 | { 55 | return __x.first == __y.first && __x.second == __y.second; 56 | } 57 | 58 | template 59 | inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) 60 | { 61 | return __x.first < __y.first || 62 | (!(__y.first < __x.first) && __x.second < __y.second); 63 | } 64 | 65 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 66 | 67 | template 68 | inline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 69 | return !(__x == __y); 70 | } 71 | 72 | template 73 | inline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 74 | return __y < __x; 75 | } 76 | 77 | template 78 | inline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 79 | return !(__y < __x); 80 | } 81 | 82 | template 83 | inline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 84 | return !(__x < __y); 85 | } 86 | 87 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 88 | 89 | template 90 | inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y) 91 | { 92 | return pair<_T1, _T2>(__x, __y); 93 | } 94 | 95 | __STL_END_NAMESPACE 96 | 97 | #endif /* __SGI_STL_INTERNAL_PAIR_H */ 98 | 99 | // Local Variables: 100 | // mode:C++ 101 | // End: 102 | -------------------------------------------------------------------------------- /include/lcdostream: -------------------------------------------------------------------------------- 1 | /* 2 | * lcdostream 3 | * Implementation of output stream for the Arduino LiquidCrystal library 4 | * 5 | * Created on: 6 Jan 2011 6 | * Author: Andy Brown 7 | * 8 | * http://andybrown.me.uk/ws/terms-and-conditions 9 | */ 10 | 11 | 12 | #ifndef __65B857C4_2BD5_4044_8D08C067F4A032DC 13 | #define __65B857C4_2BD5_4044_8D08C067F4A032DC 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | namespace std 25 | { 26 | /* 27 | * basic_lcdbuf implements an unbuffered basic_streambuf as a backing buffer 28 | * for the output class. 29 | */ 30 | 31 | template 32 | class basic_lcdbuf : public basic_streambuf 33 | { 34 | public: 35 | 36 | /* 37 | * Types used here 38 | */ 39 | 40 | typedef charT char_type; 41 | typedef typename traits::int_type int_type; 42 | 43 | /* 44 | * constructor - wraps an existing LiquidCrystal class instance 45 | */ 46 | 47 | explicit basic_lcdbuf(LiquidCrystal& lcd_) 48 | : _lcd(lcd_) 49 | { 50 | basic_streambuf::openedFor = ios_base::out; 51 | } 52 | 53 | /* 54 | * Required to maintain the chain 55 | */ 56 | 57 | virtual ~basic_lcdbuf() { } 58 | 59 | /* 60 | * Get a reference to the wrapped object 61 | */ 62 | 63 | LiquidCrystal& lcd() { return _lcd; } 64 | 65 | protected: 66 | 67 | /* 68 | * Write up to n chars 69 | */ 70 | 71 | virtual streamsize xsputn(const char_type* s, streamsize n){ 72 | 73 | for(streamsize i=0;i class basic_olcdstream 103 | : public basic_ostream 104 | { 105 | public: 106 | 107 | /* 108 | * Types used here 109 | */ 110 | 111 | typedef charT char_type; 112 | 113 | 114 | /* 115 | * Constructor 116 | */ 117 | 118 | explicit basic_olcdstream(LiquidCrystal& lcd_) 119 | : basic_ios(&sb), basic_ostream(&sb), sb(lcd_) 120 | { 121 | } 122 | 123 | /* 124 | * Required to maintain the chain 125 | */ 126 | 127 | virtual ~basic_olcdstream() { } 128 | 129 | 130 | /* 131 | * Move the LCD cursor 132 | */ 133 | 134 | void moveCursor(int x_,int y_) { 135 | sb.lcd().setCursor(x_,y_); 136 | } 137 | 138 | void clear() { 139 | sb.lcd().clear(); 140 | } 141 | 142 | /* 143 | * The wrapped object 144 | */ 145 | 146 | private: 147 | basic_lcdbuf sb; 148 | }; 149 | 150 | 151 | /* 152 | * Move the cursor 153 | */ 154 | 155 | struct __move{ 156 | int _x,_y; 157 | __move(int x,int y): _x(x),_y(y) { } 158 | }; 159 | 160 | inline __move move(int x,int y) { 161 | return __move(x,y); 162 | } 163 | 164 | template basic_olcdstream& 165 | operator<<(basic_olcdstream& os, const __move m) 166 | { 167 | os.moveCursor(m._x,m._y); 168 | return os; 169 | } 170 | 171 | 172 | /* 173 | * Clear screen 174 | */ 175 | 176 | struct __clear{ 177 | }; 178 | 179 | inline __clear clear() { 180 | return __clear(); 181 | } 182 | 183 | template basic_olcdstream& 184 | operator<<(basic_olcdstream& os, const __clear c) 185 | { 186 | os.clear(); 187 | return os; 188 | } 189 | } 190 | 191 | 192 | #endif 193 | -------------------------------------------------------------------------------- /include/memory: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-1999 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | * 13 | */ 14 | 15 | #ifndef __SGI_STL_MEMORY 16 | #define __SGI_STL_MEMORY 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | __STL_BEGIN_NAMESPACE 27 | 28 | #if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \ 29 | defined(__STL_MEMBER_TEMPLATES) 30 | 31 | template struct auto_ptr_ref { 32 | _Tp1* _M_ptr; 33 | auto_ptr_ref(_Tp1* __p) : _M_ptr(__p) {} 34 | }; 35 | 36 | #endif 37 | 38 | template class auto_ptr { 39 | private: 40 | _Tp* _M_ptr; 41 | 42 | public: 43 | typedef _Tp element_type; 44 | 45 | explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {} 46 | auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {} 47 | 48 | #ifdef __STL_MEMBER_TEMPLATES 49 | template auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW 50 | : _M_ptr(__a.release()) {} 51 | #endif /* __STL_MEMBER_TEMPLATES */ 52 | 53 | auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW { 54 | if (&__a != this) { 55 | delete _M_ptr; 56 | _M_ptr = __a.release(); 57 | } 58 | return *this; 59 | } 60 | 61 | #ifdef __STL_MEMBER_TEMPLATES 62 | template 63 | auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW { 64 | if (__a.get() != this->get()) { 65 | delete _M_ptr; 66 | _M_ptr = __a.release(); 67 | } 68 | return *this; 69 | } 70 | #endif /* __STL_MEMBER_TEMPLATES */ 71 | 72 | // Note: The C++ standard says there is supposed to be an empty throw 73 | // specification here, but omitting it is standard conforming. Its 74 | // presence can be detected only if _Tp::~_Tp() throws, but (17.4.3.6/2) 75 | // this is prohibited. 76 | ~auto_ptr() { delete _M_ptr; } 77 | 78 | _Tp& operator*() const __STL_NOTHROW { 79 | return *_M_ptr; 80 | } 81 | _Tp* operator->() const __STL_NOTHROW { 82 | return _M_ptr; 83 | } 84 | _Tp* get() const __STL_NOTHROW { 85 | return _M_ptr; 86 | } 87 | _Tp* release() __STL_NOTHROW { 88 | _Tp* __tmp = _M_ptr; 89 | _M_ptr = 0; 90 | return __tmp; 91 | } 92 | void reset(_Tp* __p = 0) __STL_NOTHROW { 93 | if (__p != _M_ptr) { 94 | delete _M_ptr; 95 | _M_ptr = __p; 96 | } 97 | } 98 | 99 | // According to the C++ standard, these conversions are required. Most 100 | // present-day compilers, however, do not enforce that requirement---and, 101 | // in fact, most present-day compilers do not support the language 102 | // features that these conversions rely on. 103 | 104 | #if defined(__SGI_STL_USE_AUTO_PTR_CONVERSIONS) && \ 105 | defined(__STL_MEMBER_TEMPLATES) 106 | 107 | public: 108 | auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW 109 | : _M_ptr(__ref._M_ptr) {} 110 | 111 | auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW { 112 | if (__ref._M_ptr != this->get()) { 113 | delete _M_ptr; 114 | _M_ptr = __ref._M_ptr; 115 | } 116 | return *this; 117 | } 118 | 119 | template operator auto_ptr_ref<_Tp1>() __STL_NOTHROW 120 | { return auto_ptr_ref<_Tp1>(this->release()); } 121 | template operator auto_ptr<_Tp1>() __STL_NOTHROW 122 | { return auto_ptr<_Tp1>(this->release()); } 123 | 124 | #endif /* auto ptr conversions && member templates */ 125 | }; 126 | 127 | __STL_END_NAMESPACE 128 | 129 | #endif /* __SGI_STL_MEMORY */ 130 | 131 | 132 | // Local Variables: 133 | // mode:C++ 134 | // End: 135 | -------------------------------------------------------------------------------- /include/stl_construct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_CONSTRUCT_H 32 | #define __SGI_STL_INTERNAL_CONSTRUCT_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | template 39 | inline void destroy(_Tp* __pointer); 40 | 41 | // construct and destroy. These functions are not part of the C++ standard, 42 | // and are provided for backward compatibility with the HP STL. We also 43 | // provide internal names _Construct and _Destroy that can be used within 44 | // the library, so that standard-conforming pieces don't have to rely on 45 | // non-standard extensions. 46 | 47 | // Internal names 48 | 49 | template 50 | inline void _Construct(_T1* __p, const _T2& __value) { 51 | new ((void*) __p) _T1(__value); 52 | } 53 | 54 | template 55 | inline void _Construct(_T1* __p) { 56 | new ((void*) __p) _T1(); 57 | } 58 | 59 | template 60 | inline void _Destroy(_Tp* __pointer) { 61 | __pointer->~_Tp(); 62 | } 63 | 64 | template 65 | void 66 | __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type) 67 | { 68 | for ( ; __first != __last; ++__first) 69 | destroy(&*__first); 70 | } 71 | 72 | template 73 | inline void __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type) {} 74 | 75 | template 76 | inline void 77 | __destroy(_ForwardIterator __first, _ForwardIterator __last, _Tp*) 78 | { 79 | typedef typename __type_traits<_Tp>::has_trivial_destructor 80 | _Trivial_destructor; 81 | __destroy_aux(__first, __last, _Trivial_destructor()); 82 | } 83 | 84 | template 85 | inline void _Destroy(_ForwardIterator __first, _ForwardIterator __last) { 86 | __destroy(__first, __last, __VALUE_TYPE(__first)); 87 | } 88 | 89 | inline void _Destroy(char*, char*) {} 90 | inline void _Destroy(int*, int*) {} 91 | inline void _Destroy(long*, long*) {} 92 | inline void _Destroy(float*, float*) {} 93 | inline void _Destroy(double*, double*) {} 94 | #ifdef __STL_HAS_WCHAR_T 95 | inline void _Destroy(wchar_t*, wchar_t*) {} 96 | #endif /* __STL_HAS_WCHAR_T */ 97 | 98 | // -------------------------------------------------- 99 | // Old names from the HP STL. 100 | 101 | template 102 | inline void construct(_T1* __p, const _T2& __value) { 103 | _Construct(__p, __value); 104 | } 105 | 106 | template 107 | inline void construct(_T1* __p) { 108 | _Construct(__p); 109 | } 110 | 111 | template 112 | inline void destroy(_Tp* __pointer) { 113 | _Destroy(__pointer); 114 | } 115 | 116 | template 117 | inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { 118 | _Destroy(__first, __last); 119 | } 120 | 121 | __STL_END_NAMESPACE 122 | 123 | #endif /* __SGI_STL_INTERNAL_CONSTRUCT_H */ 124 | 125 | // Local Variables: 126 | // mode:C++ 127 | // End: 128 | -------------------------------------------------------------------------------- /include/iosfwd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __AVR__ 25 | class HardwareSerial; 26 | class LiquidCrystal; 27 | #endif 28 | 29 | #ifndef __HEADER_STD_IOSFWD 30 | #define __HEADER_STD_IOSFWD 1 31 | 32 | #pragma GCC visibility push(default) 33 | 34 | namespace std { 35 | class ios_base; 36 | template<> class char_traits; 37 | 38 | template > class basic_ios; 39 | 40 | template > class basic_streambuf; 41 | template > class basic_istream; 42 | template > class basic_ostream; 43 | template > class basic_iostream; 44 | 45 | template , 46 | class Allocator = allocator > class basic_stringbuf; 47 | 48 | template , 49 | class Allocator = allocator > class basic_istringstream; 50 | 51 | template , 52 | class Allocator = allocator > class basic_ostringstream; 53 | 54 | template , 55 | class Allocator = allocator > class basic_stringstream; 56 | 57 | template > class basic_filebuf; 58 | 59 | template > class basic_ifstream; 60 | 61 | template > class basic_ofstream; 62 | 63 | template > class basic_fstream; 64 | 65 | template > class basic_istreambuf_iterator; 66 | 67 | template > class basic_ostreambuf_iterator; 68 | 69 | typedef basic_ios ios; 70 | 71 | typedef basic_streambuf streambuf; 72 | typedef basic_istream istream; 73 | typedef basic_ostream ostream; 74 | typedef basic_iostream iostream; 75 | 76 | typedef basic_stringbuf stringbuf; 77 | typedef basic_istringstream istringstream; 78 | typedef basic_ostringstream ostringstream; 79 | typedef basic_stringstream stringstream; 80 | 81 | typedef basic_filebuf filebuf; 82 | typedef basic_ifstream ifstream; 83 | typedef basic_ofstream ofstream; 84 | typedef basic_fstream fstream; 85 | 86 | #ifdef __AVR__ 87 | // specialisations for HardwareSerial 88 | 89 | template , class Tserial=HardwareSerial> class basic_serialbuf; 90 | template , class Tserial=HardwareSerial> class basic_iserialstream; 91 | template , class Tserial=HardwareSerial> class basic_oserialstream; 92 | 93 | typedef basic_iserialstream ihserialstream; 94 | typedef basic_oserialstream ohserialstream; 95 | 96 | // specialisations for LiquidCrystal 97 | 98 | template > class basic_lcdbuf; 99 | template > class basic_olcdstream; 100 | 101 | typedef basic_olcdstream olcdstream; 102 | #endif 103 | 104 | template class fpos; 105 | typedef fpos::state_type> streampos; 106 | } 107 | 108 | #pragma GCC visibility pop 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /include/iomanip: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __AVR__ 21 | #include 22 | #endif 23 | 24 | #include 25 | 26 | #ifndef __STD_IOMANIP 27 | #define __STD_IOMANIP 1 28 | 29 | #pragma GCC visibility push(default) 30 | 31 | namespace std{ 32 | 33 | // These are the helper classes which we are going to be using to 34 | // hold the required data 35 | 36 | class _UCXXEXPORT __resetiosflags{ 37 | public: 38 | ios_base::fmtflags m; 39 | _UCXXEXPORT __resetiosflags(ios_base::fmtflags mask) : m(mask){ } 40 | }; 41 | 42 | class _UCXXEXPORT __setiosflags{ 43 | public: 44 | ios_base::fmtflags m; 45 | _UCXXEXPORT __setiosflags(ios_base::fmtflags mask) : m(mask){ } 46 | }; 47 | 48 | class _UCXXEXPORT __setbase{ 49 | public: 50 | int base; 51 | _UCXXEXPORT __setbase(int b) : base(b){ } 52 | }; 53 | 54 | class _UCXXEXPORT __setfill{ 55 | public: 56 | int character; 57 | _UCXXEXPORT __setfill(int c): character(c){ } 58 | }; 59 | 60 | class _UCXXEXPORT __setprecision{ 61 | public: 62 | int digits; 63 | _UCXXEXPORT __setprecision(int n): digits(n) { } 64 | }; 65 | 66 | class _UCXXEXPORT __setw{ 67 | public: 68 | int width; 69 | _UCXXEXPORT __setw(int n): width(n) { } 70 | }; 71 | 72 | 73 | //Actual manipulator functions 74 | 75 | inline __resetiosflags resetiosflags(ios_base::fmtflags mask){ 76 | return __resetiosflags(mask); 77 | } 78 | 79 | inline __setiosflags setiosflags(ios_base::fmtflags mask){ 80 | return __setiosflags(mask); 81 | } 82 | 83 | inline __setbase setbase(int b){ 84 | return __setbase(b); 85 | } 86 | 87 | inline __setfill setfill(int c){ 88 | return __setfill(c); 89 | } 90 | 91 | inline __setprecision setprecision(int n){ 92 | return __setprecision(n); 93 | } 94 | 95 | inline __setw setw(int n){ 96 | return __setw(n); 97 | } 98 | 99 | 100 | //How to handle interaction with [i|o]stream classes 101 | 102 | template _UCXXEXPORT basic_ostream& 103 | operator<<(basic_ostream& os, const __resetiosflags s) 104 | { 105 | os.setf(ios_base::fmtflags(0),s.m); 106 | return os; 107 | } 108 | 109 | template _UCXXEXPORT basic_istream& 110 | operator>>(basic_istream& is, const __resetiosflags s) 111 | { 112 | is.setf(ios_base::fmtflags(0),s.m); 113 | return is; 114 | } 115 | 116 | template _UCXXEXPORT basic_ostream& 117 | operator<<(basic_ostream& os, const __setiosflags s) 118 | { 119 | os.setf(s.m); 120 | return os; 121 | } 122 | 123 | template _UCXXEXPORT basic_ostream& 124 | operator<<(basic_ostream& os, const __setbase s) 125 | { 126 | ios_base::fmtflags f(0); 127 | switch(s.base){ 128 | case 8: 129 | f = ios_base::oct; 130 | break; 131 | case 10: 132 | f = ios_base::dec; 133 | break; 134 | case 16: 135 | f = ios_base::hex; 136 | break; 137 | default: 138 | break; 139 | 140 | } 141 | os.setf(f, ios_base::basefield); 142 | return os; 143 | } 144 | 145 | template _UCXXEXPORT basic_ostream& 146 | operator<<(basic_ostream& os, const __setfill s) 147 | { 148 | os.fill(s.character); 149 | return os; 150 | } 151 | 152 | template _UCXXEXPORT basic_ostream& 153 | operator<<(basic_ostream& os, const __setprecision s) 154 | { 155 | os.precision(s.digits); 156 | return os; 157 | } 158 | 159 | template _UCXXEXPORT basic_ostream& 160 | operator<<(basic_ostream& os, const __setw s) 161 | { 162 | os.width(s.width); 163 | return os; 164 | } 165 | 166 | 167 | 168 | } 169 | 170 | #pragma GCC visibility pop 171 | 172 | #endif 173 | 174 | -------------------------------------------------------------------------------- /include/stl_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_STACK_H 32 | #define __SGI_STL_INTERNAL_STACK_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | // Forward declarations of operators == and <, needed for friend declaration. 39 | 40 | template ) > 42 | class stack; 43 | 44 | template 45 | bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); 46 | 47 | template 48 | bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y); 49 | 50 | 51 | template 52 | class stack { 53 | 54 | // requirements: 55 | 56 | __STL_CLASS_REQUIRES(_Tp, _Assignable); 57 | __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence); 58 | typedef typename _Sequence::value_type _Sequence_value_type; 59 | __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); 60 | 61 | 62 | #ifdef __STL_MEMBER_TEMPLATES 63 | template 64 | friend bool operator== (const stack<_Tp1, _Seq1>&, 65 | const stack<_Tp1, _Seq1>&); 66 | template 67 | friend bool operator< (const stack<_Tp1, _Seq1>&, 68 | const stack<_Tp1, _Seq1>&); 69 | #else /* __STL_MEMBER_TEMPLATES */ 70 | friend bool __STD_QUALIFIER 71 | operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&); 72 | friend bool __STD_QUALIFIER 73 | operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&); 74 | #endif /* __STL_MEMBER_TEMPLATES */ 75 | 76 | public: 77 | typedef typename _Sequence::value_type value_type; 78 | typedef typename _Sequence::size_type size_type; 79 | typedef _Sequence container_type; 80 | 81 | typedef typename _Sequence::reference reference; 82 | typedef typename _Sequence::const_reference const_reference; 83 | protected: 84 | _Sequence c; 85 | public: 86 | stack() : c() {} 87 | explicit stack(const _Sequence& __s) : c(__s) {} 88 | 89 | bool empty() const { return c.empty(); } 90 | size_type size() const { return c.size(); } 91 | reference top() { return c.back(); } 92 | const_reference top() const { return c.back(); } 93 | void push(const value_type& __x) { c.push_back(__x); } 94 | void pop() { c.pop_back(); } 95 | }; 96 | 97 | template 98 | bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 99 | { 100 | return __x.c == __y.c; 101 | } 102 | 103 | template 104 | bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 105 | { 106 | return __x.c < __y.c; 107 | } 108 | 109 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 110 | 111 | template 112 | bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 113 | { 114 | return !(__x == __y); 115 | } 116 | 117 | template 118 | bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 119 | { 120 | return __y < __x; 121 | } 122 | 123 | template 124 | bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 125 | { 126 | return !(__y < __x); 127 | } 128 | 129 | template 130 | bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) 131 | { 132 | return !(__x < __y); 133 | } 134 | 135 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 136 | 137 | __STL_END_NAMESPACE 138 | 139 | #endif /* __SGI_STL_INTERNAL_STACK_H */ 140 | 141 | // Local Variables: 142 | // mode:C++ 143 | // End: 144 | -------------------------------------------------------------------------------- /include/char_traits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __SGI_STL_CHAR_TRAITS_H 15 | #define __SGI_STL_CHAR_TRAITS_H 16 | 17 | #include 18 | 19 | #ifndef __AVR__ 20 | #include 21 | #endif 22 | 23 | #ifndef __AVR__ 24 | #if defined(__STL_USE_NEW_IOSTREAMS) && !defined(__SGI_STL_IOSFWD) 25 | #include 26 | #endif /* use new iostreams */ 27 | #endif 28 | 29 | __STL_BEGIN_NAMESPACE 30 | 31 | // Class __char_traits_base. 32 | 33 | template class __char_traits_base { 34 | public: 35 | typedef _CharT char_type; 36 | typedef _IntT int_type; 37 | 38 | #ifdef __AVR__ 39 | typedef signed int char_traits_off_type; 40 | typedef char state_type; 41 | typedef char_traits_off_type off_type; 42 | typedef char_traits_off_type pos_type; 43 | #else 44 | #ifdef __STL_USE_NEW_IOSTREAMS 45 | typedef streamoff off_type; 46 | typedef streampos pos_type; 47 | typedef mbstate_t state_type; 48 | #endif /* __STL_USE_NEW_IOSTREAMS */ 49 | #endif // __AVR__ 50 | 51 | static void assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; } 52 | static bool eq(const _CharT& __c1, const _CharT& __c2) 53 | { return __c1 == __c2; } 54 | static bool lt(const _CharT& __c1, const _CharT& __c2) 55 | { return __c1 < __c2; } 56 | 57 | static int compare(const _CharT* __s1, const _CharT* __s2, size_t __n) { 58 | for (size_t __i = 0; __i < __n; ++__i) 59 | if (!eq(__s1[__i], __s2[__i])) 60 | return __s1[__i] < __s2[__i] ? -1 : 1; 61 | return 0; 62 | } 63 | 64 | static size_t length(const _CharT* __s) { 65 | const _CharT __nullchar = _CharT(); 66 | size_t __i; 67 | for (__i = 0; !eq(__s[__i], __nullchar); ++__i) 68 | {} 69 | return __i; 70 | } 71 | 72 | static const _CharT* find(const _CharT* __s, size_t __n, const _CharT& __c) 73 | { 74 | for ( ; __n > 0 ; ++__s, --__n) 75 | if (eq(*__s, __c)) 76 | return __s; 77 | return 0; 78 | } 79 | 80 | static _CharT* move(_CharT* __s1, const _CharT* __s2, size_t __n) { 81 | memmove(__s1, __s2, __n * sizeof(_CharT)); 82 | return __s1; 83 | } 84 | 85 | static _CharT* copy(_CharT* __s1, const _CharT* __s2, size_t __n) { 86 | memcpy(__s1, __s2, __n * sizeof(_CharT)); 87 | return __s1; 88 | } 89 | 90 | static _CharT* assign(_CharT* __s, size_t __n, _CharT __c) { 91 | for (size_t __i = 0; __i < __n; ++__i) 92 | __s[__i] = __c; 93 | return __s; 94 | } 95 | 96 | static int_type not_eof(const int_type& __c) { 97 | return !eq_int_type(__c, eof()) ? __c : 0; 98 | } 99 | 100 | static char_type to_char_type(const int_type& __c) { 101 | return static_cast(__c); 102 | } 103 | 104 | static int_type to_int_type(const char_type& __c) { 105 | return static_cast(__c); 106 | } 107 | 108 | static bool eq_int_type(const int_type& __c1, const int_type& __c2) { 109 | return __c1 == __c2; 110 | } 111 | 112 | static int_type eof() { 113 | return static_cast(-1); 114 | } 115 | }; 116 | 117 | // Generic char_traits class. Note that this class is provided only 118 | // as a base for explicit specialization; it is unlikely to be useful 119 | // as is for any particular user-defined type. In particular, it 120 | // *will not work* for a non-POD type. 121 | 122 | template class char_traits 123 | : public __char_traits_base<_CharT, _CharT> 124 | {}; 125 | 126 | // Specialization for char. 127 | 128 | __STL_TEMPLATE_NULL class char_traits 129 | : public __char_traits_base 130 | { 131 | public: 132 | static char_type to_char_type(const int_type& __c) { 133 | return static_cast(static_cast(__c)); 134 | } 135 | 136 | static int_type to_int_type(const char_type& __c) { 137 | return static_cast(__c); 138 | } 139 | 140 | static int compare(const char* __s1, const char* __s2, size_t __n) 141 | { return memcmp(__s1, __s2, __n); } 142 | 143 | static size_t length(const char* __s) { return strlen(__s); } 144 | 145 | static void assign(char& __c1, const char& __c2) { __c1 = __c2; } 146 | 147 | static char* assign(char* __s, size_t __n, char __c) 148 | { memset(__s, __c, __n); return __s; } 149 | }; 150 | 151 | #ifndef __AVR__ 152 | // Specialization for wchar_t. 153 | 154 | __STL_TEMPLATE_NULL class char_traits 155 | : public __char_traits_base 156 | {}; 157 | #endif // ! __AVR__ 158 | 159 | __STL_END_NAMESPACE 160 | 161 | #endif /* __SGI_STL_CHAR_TRAITS_H */ 162 | 163 | // Local Variables: 164 | // mode:C++ 165 | // End: 166 | 167 | -------------------------------------------------------------------------------- /include/stl_tempbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_TEMPBUF_H 32 | #define __SGI_STL_INTERNAL_TEMPBUF_H 33 | 34 | 35 | __STL_BEGIN_NAMESPACE 36 | 37 | template 38 | pair<_Tp*, ptrdiff_t> 39 | __get_temporary_buffer(ptrdiff_t __len, _Tp*) 40 | { 41 | if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) 42 | __len = INT_MAX / sizeof(_Tp); 43 | 44 | while (__len > 0) { 45 | _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp)); 46 | if (__tmp != 0) 47 | return pair<_Tp*, ptrdiff_t>(__tmp, __len); 48 | __len /= 2; 49 | } 50 | 51 | return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); 52 | } 53 | 54 | #ifdef __STL_EXPLICIT_FUNCTION_TMPL_ARGS 55 | 56 | template 57 | inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) { 58 | return __get_temporary_buffer(__len, (_Tp*) 0); 59 | } 60 | 61 | #endif /* __STL_EXPLICIT_FUNCTION_TMPL_ARGS */ 62 | 63 | // This overload is not required by the standard; it is an extension. 64 | // It is supported for backward compatibility with the HP STL, and 65 | // because not all compilers support the language feature (explicit 66 | // function template arguments) that is required for the standard 67 | // version of get_temporary_buffer. 68 | template 69 | inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len, _Tp*) { 70 | return __get_temporary_buffer(__len, (_Tp*) 0); 71 | } 72 | 73 | template 74 | void return_temporary_buffer(_Tp* __p) { 75 | free(__p); 76 | } 77 | 78 | template 79 | class _Temporary_buffer { 80 | private: 81 | ptrdiff_t _M_original_len; 82 | ptrdiff_t _M_len; 83 | _Tp* _M_buffer; 84 | 85 | void _M_allocate_buffer() { 86 | _M_original_len = _M_len; 87 | _M_buffer = 0; 88 | 89 | if (_M_len > (ptrdiff_t)(INT_MAX / sizeof(_Tp))) 90 | _M_len = INT_MAX / sizeof(_Tp); 91 | 92 | while (_M_len > 0) { 93 | _M_buffer = (_Tp*) malloc(_M_len * sizeof(_Tp)); 94 | if (_M_buffer) 95 | break; 96 | _M_len /= 2; 97 | } 98 | } 99 | 100 | void _M_initialize_buffer(const _Tp&, __true_type) {} 101 | void _M_initialize_buffer(const _Tp& val, __false_type) { 102 | uninitialized_fill_n(_M_buffer, _M_len, val); 103 | } 104 | 105 | public: 106 | ptrdiff_t size() const { return _M_len; } 107 | ptrdiff_t requested_size() const { return _M_original_len; } 108 | _Tp* begin() { return _M_buffer; } 109 | _Tp* end() { return _M_buffer + _M_len; } 110 | 111 | _Temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) { 112 | // Workaround for a __type_traits bug in the pre-7.3 compiler. 113 | # if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION < 730 114 | typedef typename __type_traits<_Tp>::is_POD_type _Trivial; 115 | # else 116 | typedef typename __type_traits<_Tp>::has_trivial_default_constructor 117 | _Trivial; 118 | # endif 119 | 120 | __STL_TRY { 121 | _M_len = 0; 122 | distance(__first, __last, _M_len); 123 | _M_allocate_buffer(); 124 | if (_M_len > 0) 125 | _M_initialize_buffer(*__first, _Trivial()); 126 | } 127 | __STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0); 128 | } 129 | 130 | ~_Temporary_buffer() { 131 | destroy(_M_buffer, _M_buffer + _M_len); 132 | free(_M_buffer); 133 | } 134 | 135 | private: 136 | // Disable copy constructor and assignment operator. 137 | _Temporary_buffer(const _Temporary_buffer&) {} 138 | void operator=(const _Temporary_buffer&) {} 139 | }; 140 | 141 | // Class temporary_buffer is not part of the standard. It is an extension. 142 | 143 | template ::value_type 147 | #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */ 148 | > 149 | struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp> 150 | { 151 | temporary_buffer(_ForwardIterator __first, _ForwardIterator __last) 152 | : _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) {} 153 | ~temporary_buffer() {} 154 | }; 155 | 156 | __STL_END_NAMESPACE 157 | 158 | #endif /* __SGI_STL_INTERNAL_TEMPBUF_H */ 159 | 160 | // Local Variables: 161 | // mode:C++ 162 | // End: 163 | -------------------------------------------------------------------------------- /include/serstream: -------------------------------------------------------------------------------- 1 | /* 2 | * serstream 3 | * Implementation of input/output streams for the Arduino serial classes 4 | * 5 | * Created on: 2 Jan 2011 6 | * Author: Andy Brown 7 | * 8 | * http://andybrown.me.uk/ws/terms-and-conditions 9 | */ 10 | 11 | #ifndef __810370EC_AD69_4ef7_91F5_B1AA16F14712 12 | #define __810370EC_AD69_4ef7_91F5_B1AA16F14712 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | namespace std 25 | { 26 | /* 27 | * basic_serialbuf implements an unbuffered basic_streambuf as a backing buffer 28 | * for the IO classes 29 | */ 30 | 31 | template 32 | class basic_serialbuf : public basic_streambuf 33 | { 34 | public: 35 | 36 | /* 37 | * Types used here 38 | */ 39 | 40 | typedef charT char_type; 41 | typedef typename traits::int_type int_type; 42 | 43 | /* 44 | * constructor - wraps an existing Tserial class instance 45 | */ 46 | 47 | explicit basic_serialbuf(Tserial& serial_,ios_base::openmode which_ = ios_base::in | ios_base::out) 48 | : _serial(serial_) 49 | { 50 | basic_streambuf::openedFor = which_; 51 | } 52 | 53 | /* 54 | * Required to maintain the chain 55 | */ 56 | 57 | virtual ~basic_serialbuf() { } 58 | 59 | /* 60 | * Get a reference to the wrapped object 61 | */ 62 | 63 | Tserial& serial() { return _serial; } 64 | 65 | protected: 66 | 67 | /* 68 | * Get how many bytes available 69 | */ 70 | 71 | virtual int showmanyc(){ 72 | return _serial.available(); 73 | } 74 | 75 | /* 76 | * Read up to n chars 77 | */ 78 | 79 | virtual streamsize xsgetn(char_type* c, streamsize n) { 80 | 81 | streamsize i = 0; 82 | char_type data; 83 | 84 | while((data=_serial.read())!=-1 && i < n ) { 85 | c[i] = data; 86 | ++i; 87 | } 88 | return i; 89 | } 90 | 91 | /* 92 | * Write up to n chars 93 | */ 94 | 95 | virtual streamsize xsputn(const char_type* s, streamsize n){ 96 | 97 | for(streamsize i=0;i class basic_iserialstream 160 | : public basic_istream 161 | { 162 | public: 163 | 164 | /* 165 | * Types used here 166 | */ 167 | 168 | typedef charT char_type; 169 | 170 | /* 171 | * Constructor - default the serial object to #1 172 | * Mega users can explicity initialise with one of 173 | * the others 174 | */ 175 | 176 | explicit basic_iserialstream(Tserial& serial_) 177 | : basic_ios(&sb), basic_istream(&sb), sb(serial_,ios_base::in) 178 | { 179 | } 180 | 181 | /* 182 | * Required to maintain the chain 183 | */ 184 | 185 | virtual ~basic_iserialstream() { } 186 | 187 | /* 188 | * Initialise the baud rate 189 | */ 190 | 191 | void begin(long speed_) { 192 | sb.serial().begin(speed_); 193 | } 194 | 195 | /* 196 | * The wrapped object 197 | */ 198 | 199 | private: 200 | basic_serialbuf sb; 201 | }; 202 | 203 | 204 | /* 205 | * Output stream 206 | */ 207 | 208 | template class basic_oserialstream 209 | : public basic_ostream 210 | { 211 | public: 212 | 213 | /* 214 | * Types used here 215 | */ 216 | 217 | typedef charT char_type; 218 | 219 | /* 220 | * Constructor - default the serial object to #1 221 | * Mega users can explicity initialise with one of 222 | * the others 223 | */ 224 | 225 | explicit basic_oserialstream(Tserial& serial_) 226 | : basic_ios(&sb), basic_ostream(&sb), sb(serial_,ios_base::out) 227 | { 228 | } 229 | 230 | /* 231 | * Required to maintain the chain 232 | */ 233 | 234 | virtual ~basic_oserialstream() { } 235 | 236 | /* 237 | * Initialise the baud rate 238 | */ 239 | 240 | void begin(long speed_) { 241 | sb.serial().begin(speed_); 242 | } 243 | 244 | /* 245 | * The wrapped object 246 | */ 247 | 248 | private: 249 | basic_serialbuf sb; 250 | }; 251 | 252 | 253 | /* 254 | * Input/output stream 255 | */ 256 | 257 | template class basic_ioserialstream 258 | : public basic_iostream 259 | { 260 | public: 261 | 262 | /* 263 | * Types used here 264 | */ 265 | 266 | typedef charT char_type; 267 | 268 | /* 269 | * Constructor - default the serial object to #1 270 | * Mega users can explicity initialise with one of 271 | * the others 272 | */ 273 | 274 | explicit basic_ioserialstream(Tserial& serial_) 275 | : basic_ios(&sb), basic_iostream(&sb), sb(serial_,ios_base::in | ios_base::out) 276 | { 277 | } 278 | 279 | /* 280 | * Required to maintain the chain 281 | */ 282 | 283 | virtual ~basic_ioserialstream(){ } 284 | 285 | /* 286 | * Initialise the baud rate 287 | */ 288 | 289 | void begin(long speed_) { 290 | sb.serial().begin(speed_); 291 | } 292 | 293 | /* 294 | * The wrapped object 295 | */ 296 | 297 | private: 298 | basic_serialbuf sb; 299 | }; 300 | } 301 | 302 | 303 | #endif 304 | -------------------------------------------------------------------------------- /include/sequence_concepts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef STL_SEQUENCE_CONCEPTS_H 15 | #define STL_SEQUENCE_CONCEPTS_H 16 | 17 | #include 18 | 19 | #ifdef __STL_USE_CONCEPT_CHECKS 20 | 21 | // This file covers the following concepts: 22 | // _Sequence 23 | // _FrontInsertionSequence 24 | // _BackInsertionSequence 25 | 26 | struct _ERROR_IN_STL_SEQ { 27 | 28 | template 29 | static void 30 | __fill_constructor_requirement_violation(_XX& __s) { 31 | typename _XX::value_type __t = typename _XX::value_type(); 32 | typename _XX::difference_type __n = typename _XX::difference_type(); 33 | _XX __x(__n, __t); 34 | __sink_unused_warning(__x); 35 | } 36 | template 37 | static void 38 | __fill_default_constructor_requirement_violation(_XX& __s) { 39 | _STL_ERROR::__default_constructor_requirement_violation(*__s.begin()); 40 | typename _XX::difference_type __n = typename _XX::difference_type(); 41 | _XX __x(__n); 42 | __sink_unused_warning(__x); 43 | } 44 | template 45 | static void 46 | __range_constructor_requirement_violation(_XX& __s) { 47 | _XX __x(__s.begin(), __s.end()); 48 | __sink_unused_warning(__x); 49 | } 50 | template 51 | static void 52 | __insert_function_requirement_violation(_XX& __s) { 53 | typename _XX::value_type __t = typename _XX::value_type(); 54 | typename _XX::iterator __p = typename _XX::iterator(); 55 | __p = __s.insert(__p, __t); 56 | } 57 | template 58 | static void 59 | __fill_insert_function_requirement_violation(_XX& __s) { 60 | typename _XX::value_type __t = typename _XX::value_type(); 61 | typename _XX::iterator __p = typename _XX::iterator(); 62 | typename _XX::difference_type __n = typename _XX::difference_type(); 63 | __s.insert(__p, __n, __t); 64 | } 65 | template 66 | static void 67 | __range_insert_function_requirement_violation(_XX& __s) { 68 | typename _XX::iterator __p = typename _XX::iterator(); 69 | typename _XX::iterator __i = typename _XX::iterator(); 70 | typename _XX::iterator __j = typename _XX::iterator(); 71 | __s.insert(__p, __i, __j); 72 | } 73 | template 74 | static void 75 | __insert_element_function_requirement_violation(_XX& __s) { 76 | typename _XX::value_type __t = typename _XX::value_type(); 77 | std::pair __r; 78 | __r = __s.insert(__t); 79 | __sink_unused_warning(__r); 80 | } 81 | template 82 | static void 83 | __unconditional_insert_element_function_requirement_violation(_XX& __s) { 84 | typename _XX::value_type __t = typename _XX::value_type(); 85 | typename _XX::iterator __p; 86 | __p = __s.insert(__t); 87 | __sink_unused_warning(__p); 88 | } 89 | template 90 | static void 91 | __erase_function_requirement_violation(_XX& __s) { 92 | typename _XX::iterator __p = typename _XX::iterator(); 93 | __p = __s.erase(__p); 94 | } 95 | template 96 | static void 97 | __range_erase_function_requirement_violation(_XX& __s) { 98 | typename _XX::iterator __p = typename _XX::iterator(); 99 | typename _XX::iterator __q = typename _XX::iterator(); 100 | __p = __s.erase(__p, __q); 101 | } 102 | template 103 | static void 104 | __const_front_function_requirement_violation(const _XX& __s) { 105 | typename _XX::const_reference __t = __s.front(); 106 | __sink_unused_warning(__t); 107 | } 108 | template 109 | static void 110 | __front_function_requirement_violation(_XX& __s) { 111 | typename _XX::reference __t = __s.front(); 112 | __const_front_function_requirement_violation(__s); 113 | __sink_unused_warning(__t); 114 | } 115 | template 116 | static void 117 | __const_back_function_requirement_violation(const _XX& __s) { 118 | typename _XX::const_reference __t = __s.back(); 119 | __sink_unused_warning(__t); 120 | } 121 | template 122 | static void 123 | __back_function_requirement_violation(_XX& __s) { 124 | typename _XX::reference __t = __s.back(); 125 | __const_back_function_requirement_violation(__s); 126 | __sink_unused_warning(__t); 127 | } 128 | template 129 | static void 130 | __push_front_function_requirement_violation(_XX& __s) { 131 | typename _XX::value_type __t = typename _XX::value_type(); 132 | __s.push_front(__t); 133 | } 134 | template 135 | static void 136 | __pop_front_function_requirement_violation(_XX& __s) { 137 | __s.pop_front(); 138 | } 139 | template 140 | static void 141 | __push_back_function_requirement_violation(_XX& __s) { 142 | typename _XX::value_type __t = typename _XX::value_type(); 143 | __s.push_back(__t); 144 | } 145 | template 146 | static void 147 | __pop_back_function_requirement_violation(_XX& __s) { 148 | __s.pop_back(); 149 | } 150 | 151 | }; 152 | 153 | /* Sequence Containers */ 154 | 155 | template 156 | struct _Sequence_concept_specification { 157 | static void 158 | _Sequence_requirement_violation(_Sequence __s) { 159 | // Refinement of ForwardContainer 160 | _ForwardContainer_concept_specification<_Sequence>::_ForwardContainer_requirement_violation(__s); 161 | // Refinement of DefaultConstructible 162 | _DefaultConstructible_concept_specification<_Sequence>::_DefaultConstructible_requirement_violation(__s); 163 | // Valid Expressions 164 | _ERROR_IN_STL_SEQ::__fill_constructor_requirement_violation(__s); 165 | _ERROR_IN_STL_SEQ::__fill_default_constructor_requirement_violation(__s); 166 | _ERROR_IN_STL_SEQ::__range_constructor_requirement_violation(__s); 167 | _ERROR_IN_STL_SEQ::__insert_function_requirement_violation(__s); 168 | _ERROR_IN_STL_SEQ::__fill_insert_function_requirement_violation(__s); 169 | _ERROR_IN_STL_SEQ::__range_insert_function_requirement_violation(__s); 170 | _ERROR_IN_STL_SEQ::__erase_function_requirement_violation(__s); 171 | _ERROR_IN_STL_SEQ::__range_erase_function_requirement_violation(__s); 172 | _ERROR_IN_STL_SEQ::__front_function_requirement_violation(__s); 173 | } 174 | }; 175 | 176 | template 177 | struct _FrontInsertionSequence_concept_specification { 178 | static void 179 | _FrontInsertionSequence_requirement_violation(_FrontInsertionSequence __s) { 180 | // Refinement of Sequence 181 | _Sequence_concept_specification<_FrontInsertionSequence>::_Sequence_requirement_violation(__s); 182 | // Valid Expressions 183 | _ERROR_IN_STL_SEQ::__push_front_function_requirement_violation(__s); 184 | _ERROR_IN_STL_SEQ::__pop_front_function_requirement_violation(__s); 185 | } 186 | }; 187 | 188 | template 189 | struct _BackInsertionSequence_concept_specification { 190 | static void 191 | _BackInsertionSequence_requirement_violation(_BackInsertionSequence __s) { 192 | // Refinement of Sequence 193 | _Sequence_concept_specification<_BackInsertionSequence>::_Sequence_requirement_violation(__s); 194 | // Valid Expressions 195 | _ERROR_IN_STL_SEQ::__back_function_requirement_violation(__s); 196 | _ERROR_IN_STL_SEQ::__push_back_function_requirement_violation(__s); 197 | _ERROR_IN_STL_SEQ::__pop_back_function_requirement_violation(__s); 198 | } 199 | }; 200 | 201 | #endif /* if __STL_USE_CONCEPT_CHECKS */ 202 | 203 | 204 | #endif /* STL_SEQUENCE_CONCEPTS_H */ 205 | -------------------------------------------------------------------------------- /include/stl_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_QUEUE_H 32 | #define __SGI_STL_INTERNAL_QUEUE_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | // Forward declarations of operators < and ==, needed for friend declaration. 39 | 40 | template ) > 42 | class queue; 43 | 44 | template 45 | inline bool operator==(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&); 46 | 47 | template 48 | inline bool operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&); 49 | 50 | 51 | template 52 | class queue { 53 | 54 | // requirements: 55 | 56 | __STL_CLASS_REQUIRES(_Tp, _Assignable); 57 | __STL_CLASS_REQUIRES(_Sequence, _FrontInsertionSequence); 58 | __STL_CLASS_REQUIRES(_Sequence, _BackInsertionSequence); 59 | typedef typename _Sequence::value_type _Sequence_value_type; 60 | __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); 61 | 62 | 63 | #ifdef __STL_MEMBER_TEMPLATES 64 | template 65 | friend bool operator== (const queue<_Tp1, _Seq1>&, 66 | const queue<_Tp1, _Seq1>&); 67 | template 68 | friend bool operator< (const queue<_Tp1, _Seq1>&, 69 | const queue<_Tp1, _Seq1>&); 70 | #else /* __STL_MEMBER_TEMPLATES */ 71 | friend bool __STD_QUALIFIER 72 | operator== __STL_NULL_TMPL_ARGS (const queue&, const queue&); 73 | friend bool __STD_QUALIFIER 74 | operator< __STL_NULL_TMPL_ARGS (const queue&, const queue&); 75 | #endif /* __STL_MEMBER_TEMPLATES */ 76 | 77 | public: 78 | typedef typename _Sequence::value_type value_type; 79 | typedef typename _Sequence::size_type size_type; 80 | typedef _Sequence container_type; 81 | 82 | typedef typename _Sequence::reference reference; 83 | typedef typename _Sequence::const_reference const_reference; 84 | protected: 85 | _Sequence c; 86 | public: 87 | queue() : c() {} 88 | explicit queue(const _Sequence& __c) : c(__c) {} 89 | 90 | bool empty() const { return c.empty(); } 91 | size_type size() const { return c.size(); } 92 | reference front() { return c.front(); } 93 | const_reference front() const { return c.front(); } 94 | reference back() { return c.back(); } 95 | const_reference back() const { return c.back(); } 96 | void push(const value_type& __x) { c.push_back(__x); } 97 | void pop() { c.pop_front(); } 98 | }; 99 | 100 | template 101 | bool 102 | operator==(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 103 | { 104 | return __x.c == __y.c; 105 | } 106 | 107 | template 108 | bool 109 | operator<(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 110 | { 111 | return __x.c < __y.c; 112 | } 113 | 114 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 115 | 116 | template 117 | bool 118 | operator!=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 119 | { 120 | return !(__x == __y); 121 | } 122 | 123 | template 124 | bool 125 | operator>(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 126 | { 127 | return __y < __x; 128 | } 129 | 130 | template 131 | bool 132 | operator<=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 133 | { 134 | return !(__y < __x); 135 | } 136 | 137 | template 138 | bool 139 | operator>=(const queue<_Tp, _Sequence>& __x, const queue<_Tp, _Sequence>& __y) 140 | { 141 | return !(__x < __y); 142 | } 143 | 144 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 145 | 146 | template ), 148 | class _Compare 149 | __STL_DEPENDENT_DEFAULT_TMPL(less) > 150 | class priority_queue { 151 | 152 | // requirements: 153 | 154 | __STL_CLASS_REQUIRES(_Tp, _Assignable); 155 | __STL_CLASS_REQUIRES(_Sequence, _Sequence); 156 | __STL_CLASS_REQUIRES(_Sequence, _RandomAccessContainer); 157 | typedef typename _Sequence::value_type _Sequence_value_type; 158 | __STL_CLASS_REQUIRES_SAME_TYPE(_Tp, _Sequence_value_type); 159 | __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Tp, _Tp); 160 | 161 | public: 162 | typedef typename _Sequence::value_type value_type; 163 | typedef typename _Sequence::size_type size_type; 164 | typedef _Sequence container_type; 165 | 166 | typedef typename _Sequence::reference reference; 167 | typedef typename _Sequence::const_reference const_reference; 168 | protected: 169 | _Sequence c; 170 | _Compare comp; 171 | public: 172 | priority_queue() : c() {} 173 | explicit priority_queue(const _Compare& __x) : c(), comp(__x) {} 174 | priority_queue(const _Compare& __x, const _Sequence& __s) 175 | : c(__s), comp(__x) 176 | { make_heap(c.begin(), c.end(), comp); } 177 | 178 | #ifdef __STL_MEMBER_TEMPLATES 179 | template 180 | priority_queue(_InputIterator __first, _InputIterator __last) 181 | : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } 182 | 183 | template 184 | priority_queue(_InputIterator __first, 185 | _InputIterator __last, const _Compare& __x) 186 | : c(__first, __last), comp(__x) 187 | { make_heap(c.begin(), c.end(), comp); } 188 | 189 | template 190 | priority_queue(_InputIterator __first, _InputIterator __last, 191 | const _Compare& __x, const _Sequence& __s) 192 | : c(__s), comp(__x) 193 | { 194 | c.insert(c.end(), __first, __last); 195 | make_heap(c.begin(), c.end(), comp); 196 | } 197 | 198 | #else /* __STL_MEMBER_TEMPLATES */ 199 | priority_queue(const value_type* __first, const value_type* __last) 200 | : c(__first, __last) { make_heap(c.begin(), c.end(), comp); } 201 | 202 | priority_queue(const value_type* __first, const value_type* __last, 203 | const _Compare& __x) 204 | : c(__first, __last), comp(__x) 205 | { make_heap(c.begin(), c.end(), comp); } 206 | 207 | priority_queue(const value_type* __first, const value_type* __last, 208 | const _Compare& __x, const _Sequence& __c) 209 | : c(__c), comp(__x) 210 | { 211 | c.insert(c.end(), __first, __last); 212 | make_heap(c.begin(), c.end(), comp); 213 | } 214 | #endif /* __STL_MEMBER_TEMPLATES */ 215 | 216 | bool empty() const { return c.empty(); } 217 | size_type size() const { return c.size(); } 218 | const_reference top() const { return c.front(); } 219 | void push(const value_type& __x) { 220 | __STL_TRY { 221 | c.push_back(__x); 222 | push_heap(c.begin(), c.end(), comp); 223 | } 224 | __STL_UNWIND(c.clear()); 225 | } 226 | void pop() { 227 | __STL_TRY { 228 | pop_heap(c.begin(), c.end(), comp); 229 | c.pop_back(); 230 | } 231 | __STL_UNWIND(c.clear()); 232 | } 233 | }; 234 | 235 | // no equality is provided 236 | 237 | __STL_END_NAMESPACE 238 | 239 | #endif /* __SGI_STL_INTERNAL_QUEUE_H */ 240 | 241 | // Local Variables: 242 | // mode:C++ 243 | // End: 244 | -------------------------------------------------------------------------------- /include/stl_numeric.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | 32 | #ifndef __SGI_STL_INTERNAL_NUMERIC_H 33 | #define __SGI_STL_INTERNAL_NUMERIC_H 34 | 35 | __STL_BEGIN_NAMESPACE 36 | 37 | template 38 | _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) 39 | { 40 | __STL_REQUIRES(_InputIterator, _InputIterator); 41 | for ( ; __first != __last; ++__first) 42 | __init = __init + *__first; 43 | return __init; 44 | } 45 | 46 | template 47 | _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, 48 | _BinaryOperation __binary_op) 49 | { 50 | __STL_REQUIRES(_InputIterator, _InputIterator); 51 | for ( ; __first != __last; ++__first) 52 | __init = __binary_op(__init, *__first); 53 | return __init; 54 | } 55 | 56 | template 57 | _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, 58 | _InputIterator2 __first2, _Tp __init) 59 | { 60 | __STL_REQUIRES(_InputIterator2, _InputIterator); 61 | __STL_REQUIRES(_InputIterator2, _InputIterator); 62 | for ( ; __first1 != __last1; ++__first1, ++__first2) 63 | __init = __init + (*__first1 * *__first2); 64 | return __init; 65 | } 66 | 67 | template 69 | _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, 70 | _InputIterator2 __first2, _Tp __init, 71 | _BinaryOperation1 __binary_op1, 72 | _BinaryOperation2 __binary_op2) 73 | { 74 | __STL_REQUIRES(_InputIterator2, _InputIterator); 75 | __STL_REQUIRES(_InputIterator2, _InputIterator); 76 | for ( ; __first1 != __last1; ++__first1, ++__first2) 77 | __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); 78 | return __init; 79 | } 80 | 81 | template 82 | _OutputIterator 83 | __partial_sum(_InputIterator __first, _InputIterator __last, 84 | _OutputIterator __result, _Tp*) 85 | { 86 | _Tp __value = *__first; 87 | while (++__first != __last) { 88 | __value = __value + *__first; 89 | *++__result = __value; 90 | } 91 | return ++__result; 92 | } 93 | 94 | template 95 | _OutputIterator 96 | partial_sum(_InputIterator __first, _InputIterator __last, 97 | _OutputIterator __result) 98 | { 99 | __STL_REQUIRES(_InputIterator, _InputIterator); 100 | __STL_REQUIRES(_OutputIterator, _OutputIterator); 101 | if (__first == __last) return __result; 102 | *__result = *__first; 103 | return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first)); 104 | } 105 | 106 | template 108 | _OutputIterator 109 | __partial_sum(_InputIterator __first, _InputIterator __last, 110 | _OutputIterator __result, _Tp*, _BinaryOperation __binary_op) 111 | { 112 | _Tp __value = *__first; 113 | while (++__first != __last) { 114 | __value = __binary_op(__value, *__first); 115 | *++__result = __value; 116 | } 117 | return ++__result; 118 | } 119 | 120 | template 121 | _OutputIterator 122 | partial_sum(_InputIterator __first, _InputIterator __last, 123 | _OutputIterator __result, _BinaryOperation __binary_op) 124 | { 125 | __STL_REQUIRES(_InputIterator, _InputIterator); 126 | __STL_REQUIRES(_OutputIterator, _OutputIterator); 127 | if (__first == __last) return __result; 128 | *__result = *__first; 129 | return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first), 130 | __binary_op); 131 | } 132 | 133 | template 134 | _OutputIterator 135 | __adjacent_difference(_InputIterator __first, _InputIterator __last, 136 | _OutputIterator __result, _Tp*) 137 | { 138 | _Tp __value = *__first; 139 | while (++__first != __last) { 140 | _Tp __tmp = *__first; 141 | *++__result = __tmp - __value; 142 | __value = __tmp; 143 | } 144 | return ++__result; 145 | } 146 | 147 | template 148 | _OutputIterator 149 | adjacent_difference(_InputIterator __first, 150 | _InputIterator __last, _OutputIterator __result) 151 | { 152 | __STL_REQUIRES(_InputIterator, _InputIterator); 153 | __STL_REQUIRES(_OutputIterator, _OutputIterator); 154 | if (__first == __last) return __result; 155 | *__result = *__first; 156 | return __adjacent_difference(__first, __last, __result, 157 | __VALUE_TYPE(__first)); 158 | } 159 | 160 | template 162 | _OutputIterator 163 | __adjacent_difference(_InputIterator __first, _InputIterator __last, 164 | _OutputIterator __result, _Tp*, 165 | _BinaryOperation __binary_op) { 166 | _Tp __value = *__first; 167 | while (++__first != __last) { 168 | _Tp __tmp = *__first; 169 | *++__result = __binary_op(__tmp, __value); 170 | __value = __tmp; 171 | } 172 | return ++__result; 173 | } 174 | 175 | template 176 | _OutputIterator 177 | adjacent_difference(_InputIterator __first, _InputIterator __last, 178 | _OutputIterator __result, _BinaryOperation __binary_op) 179 | { 180 | __STL_REQUIRES(_InputIterator, _InputIterator); 181 | __STL_REQUIRES(_OutputIterator, _OutputIterator); 182 | if (__first == __last) return __result; 183 | *__result = *__first; 184 | return __adjacent_difference(__first, __last, __result, 185 | __VALUE_TYPE(__first), 186 | __binary_op); 187 | } 188 | 189 | // Returns __x ** __n, where __n >= 0. _Note that "multiplication" 190 | // is required to be associative, but not necessarily commutative. 191 | 192 | 193 | template 194 | _Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr) 195 | { 196 | if (__n == 0) 197 | return identity_element(__opr); 198 | else { 199 | while ((__n & 1) == 0) { 200 | __n >>= 1; 201 | __x = __opr(__x, __x); 202 | } 203 | 204 | _Tp __result = __x; 205 | __n >>= 1; 206 | while (__n != 0) { 207 | __x = __opr(__x, __x); 208 | if ((__n & 1) != 0) 209 | __result = __opr(__result, __x); 210 | __n >>= 1; 211 | } 212 | return __result; 213 | } 214 | } 215 | 216 | template 217 | inline _Tp __power(_Tp __x, _Integer __n) 218 | { 219 | return __power(__x, __n, multiplies<_Tp>()); 220 | } 221 | 222 | // Alias for the internal name __power. Note that power is an extension, 223 | // not part of the C++ standard. 224 | 225 | template 226 | inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) 227 | { 228 | return __power(__x, __n, __opr); 229 | } 230 | 231 | template 232 | inline _Tp power(_Tp __x, _Integer __n) 233 | { 234 | return __power(__x, __n); 235 | } 236 | 237 | // iota is not part of the C++ standard. It is an extension. 238 | 239 | template 240 | void 241 | iota(_ForwardIter __first, _ForwardIter __last, _Tp __value) 242 | { 243 | __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator); 244 | __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type); 245 | while (__first != __last) 246 | *__first++ = __value++; 247 | } 248 | 249 | __STL_END_NAMESPACE 250 | 251 | #endif /* __SGI_STL_INTERNAL_NUMERIC_H */ 252 | 253 | // Local Variables: 254 | // mode:C++ 255 | // End: 256 | -------------------------------------------------------------------------------- /include/streambuf: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef HEADER_STD_STREAMBUF 26 | #define HEADER_STD_STREAMBUF 1 27 | 28 | #include 29 | 30 | #pragma GCC visibility push(default) 31 | 32 | namespace std{ 33 | 34 | template class _UCXXEXPORT basic_streambuf{ 35 | public: 36 | #ifdef __UCLIBCXX_SUPPORT_CDIR__ 37 | friend ios_base::Init::Init(); 38 | #endif 39 | // Types: 40 | typedef charT char_type; 41 | typedef typename traits::int_type int_type; 42 | typedef typename traits::pos_type pos_type; 43 | typedef typename traits::off_type off_type; 44 | typedef traits traits_type; 45 | 46 | virtual ~basic_streambuf(); 47 | 48 | locale pubimbue(const locale &loc); 49 | 50 | locale getloc() const{ 51 | return myLocale; 52 | } 53 | 54 | basic_streambuf* pubsetbuf(char_type* s, streamsize n){ 55 | return setbuf(s,n); 56 | } 57 | pos_type pubseekoff(off_type off, 58 | typename ios_base::seekdir way, 59 | ios_base::openmode which = ios_base::in | 60 | ios_base::out 61 | ) 62 | { 63 | return seekoff(off,way,which); 64 | } 65 | pos_type pubseekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out){ 66 | return seekpos(sp,which); 67 | } 68 | int pubsync(){ 69 | return sync(); 70 | } 71 | 72 | streamsize in_avail(); 73 | 74 | int_type snextc(); 75 | 76 | int_type sbumpc(); 77 | 78 | int_type sgetc(); 79 | 80 | streamsize sgetn(char_type* s, streamsize n){ 81 | return xsgetn(s,n); 82 | } 83 | 84 | int_type sputbackc(char_type c); 85 | 86 | int_type sungetc(); 87 | 88 | int_type sputc(char_type c); 89 | 90 | streamsize sputn(const char_type* s, streamsize n){ 91 | if(openedFor & ios_base::app){ 92 | seekoff(0, ios_base::end, ios_base::out); 93 | } 94 | return xsputn(s, n); 95 | } 96 | 97 | protected: 98 | locale myLocale; 99 | //Pointers for the "get" buffers 100 | charT * mgbeg; 101 | charT * mgnext; 102 | charT * mgend; 103 | 104 | //Pointers for the "put" buffers 105 | charT * mpbeg; 106 | charT * mpnext; 107 | charT * mpend; 108 | 109 | //In the event of null buffers Lets us know what the buffer is opened for 110 | ios_base::openmode openedFor; 111 | 112 | basic_streambuf(); 113 | 114 | basic_streambuf(const basic_streambuf > &) 115 | : myLocale(), 116 | mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), 117 | openedFor(0) 118 | { } 119 | basic_streambuf > & operator=(const basic_streambuf > &){ 120 | return *this; 121 | } 122 | 123 | char_type* eback() const{ 124 | return mgbeg; 125 | } 126 | char_type* gptr() const{ 127 | return mgnext; 128 | } 129 | char_type* egptr() const{ 130 | return mgend; 131 | } 132 | void gbump(int n){ 133 | mgnext+=n; 134 | } 135 | void setg(char_type* gbeg, char_type* gnext, char_type* gend){ 136 | mgbeg = gbeg; 137 | mgnext = gnext; 138 | mgend = gend; 139 | } 140 | 141 | char_type* pbase() const{ 142 | return mpbeg; 143 | } 144 | char_type* pptr() const{ 145 | return mpnext; 146 | } 147 | char_type* epptr() const{ 148 | return mpend; 149 | } 150 | void pbump(int n){ 151 | mpnext+=n; 152 | } 153 | void setp(char_type* pbeg, char_type* pend){ 154 | mpbeg = pbeg; 155 | mpnext = pbeg; 156 | mpend = pend; 157 | } 158 | 159 | virtual void imbue(const locale &loc){ 160 | myLocale = loc; 161 | } 162 | 163 | //Virtual functions which we will not implement 164 | 165 | virtual basic_streambuf* setbuf(char_type* , streamsize){ 166 | return 0; 167 | } 168 | virtual pos_type seekoff(off_type , ios_base::seekdir, 169 | ios_base::openmode = ios_base::in | ios_base::out) 170 | { 171 | return 0; 172 | } 173 | virtual pos_type seekpos(pos_type , ios_base::openmode = ios_base::in | ios_base::out){ 174 | return 0; 175 | } 176 | virtual int sync(){ 177 | return 0; 178 | } 179 | 180 | virtual int showmanyc(){ 181 | return 0; 182 | } 183 | virtual streamsize xsgetn(char_type* , streamsize ){ 184 | return 0; 185 | } 186 | virtual int_type underflow(){ 187 | return traits_type::eof(); 188 | } 189 | virtual int_type uflow(){ 190 | int_type ret = underflow(); 191 | if (!traits_type::eq_int_type(ret, traits_type::eof())) 192 | gbump(1); 193 | return ret; 194 | } 195 | 196 | virtual int_type pbackfail(int_type c = traits::eof()){ 197 | return c; 198 | } 199 | virtual streamsize xsputn(const char_type* c, streamsize n){ 200 | //This function is designed to be replaced by subclasses 201 | for(streamsize i = 0; i< n; ++i){ 202 | if(sputc(c[i]) == traits::eof()){ 203 | return i; 204 | } 205 | } 206 | return n; 207 | } 208 | virtual int_type overflow (int_type c = traits::eof()){ 209 | return c; 210 | } 211 | }; 212 | 213 | typedef basic_streambuf streambuf; 214 | #ifdef __UCLIBCXX_HAS_WCHAR__ 215 | typedef basic_streambuf wstreambuf; 216 | #endif 217 | 218 | 219 | //Definitions put below to allow for easy expansion of code 220 | 221 | template basic_streambuf::~basic_streambuf(){ } 222 | 223 | template locale basic_streambuf::pubimbue(const locale &loc){ 224 | locale temp = myLocale; 225 | myLocale = loc; 226 | return temp; 227 | } 228 | 229 | template streamsize basic_streambuf::in_avail(){ 230 | if(mgend !=0 && mgnext !=0){ 231 | return mgend - mgnext; 232 | } 233 | return showmanyc(); 234 | } 235 | 236 | template typename basic_streambuf::int_type basic_streambuf::sbumpc(){ 237 | if(mgbeg == 0 || mgnext == mgend){ 238 | return uflow(); 239 | } 240 | int_type retval = T::to_int_type(*gptr()); 241 | gbump(1); 242 | return retval; 243 | } 244 | 245 | template typename basic_streambuf::int_type basic_streambuf::snextc(){ 246 | if(sbumpc() == T::eof() ){ 247 | return T::eof() ; 248 | } 249 | return sgetc(); 250 | } 251 | 252 | template typename basic_streambuf::int_type basic_streambuf::sgetc(){ 253 | if(mgbeg == 0 || mgnext == mgend){ 254 | return underflow(); 255 | } 256 | return T::to_int_type(*gptr()); 257 | } 258 | 259 | template typename basic_streambuf::int_type basic_streambuf::sputbackc(char_type c){ 260 | if(mgbeg == 0 || mgnext == mgbeg || !T::eq(c, gptr()[-1] )){ 261 | return pbackfail(T::to_int_type(c)); 262 | } 263 | gbump(-1); 264 | return T::to_int_type(*gptr()); 265 | } 266 | 267 | template typename basic_streambuf::int_type basic_streambuf::sungetc(){ 268 | if(mgbeg == 0 || mgnext == mgbeg){ 269 | return ios_base::failbit; 270 | } 271 | gbump(-1); 272 | return T::to_int_type(*gptr()); 273 | } 274 | 275 | template typename basic_streambuf::int_type basic_streambuf::sputc(char_type c){ 276 | if(openedFor & ios_base::app){ 277 | seekoff(0, ios_base::end, ios_base::out); 278 | } 279 | if(mpnext < mpend){ 280 | *mpnext = c; 281 | ++mpnext; 282 | }else{ 283 | return overflow( T::to_int_type(c) ); 284 | } 285 | return T::to_int_type(c); 286 | } 287 | 288 | template basic_streambuf::basic_streambuf() 289 | : myLocale(), 290 | mgbeg(0), mgnext(0), mgend(0), mpbeg(0), mpnext(0), mpend(0), 291 | openedFor(0) 292 | { } 293 | 294 | 295 | 296 | 297 | 298 | 299 | #ifdef __UCLIBCXX_EXPAND_STREAMBUF_CHAR__ 300 | #ifndef __UCLIBCXX_COMPILE_STREAMBUF__ 301 | 302 | #ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 303 | 304 | template <> _UCXXEXPORT streambuf::basic_streambuf(); 305 | template <> _UCXXEXPORT streambuf::~basic_streambuf(); 306 | 307 | #endif //__UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__ 308 | 309 | template <> _UCXXEXPORT locale streambuf::pubimbue(const locale &loc); 310 | template <> _UCXXEXPORT streamsize streambuf::in_avail(); 311 | template <> _UCXXEXPORT streambuf::int_type streambuf::sbumpc(); 312 | template <> _UCXXEXPORT streambuf::int_type streambuf::snextc(); 313 | template <> _UCXXEXPORT streambuf::int_type streambuf::sgetc(); 314 | template <> _UCXXEXPORT streambuf::int_type streambuf::sputbackc(char_type c); 315 | template <> _UCXXEXPORT streambuf::int_type streambuf::sungetc(); 316 | template <> _UCXXEXPORT streambuf::int_type streambuf::sputc(char_type c); 317 | 318 | #endif 319 | #endif 320 | 321 | 322 | 323 | 324 | 325 | } 326 | 327 | #pragma GCC visibility pop 328 | 329 | #endif 330 | -------------------------------------------------------------------------------- /include/stl_uninitialized.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_UNINITIALIZED_H 32 | #define __SGI_STL_INTERNAL_UNINITIALIZED_H 33 | 34 | __STL_BEGIN_NAMESPACE 35 | 36 | // uninitialized_copy 37 | 38 | // Valid if copy construction is equivalent to assignment, and if the 39 | // destructor is trivial. 40 | template 41 | inline _ForwardIter 42 | __uninitialized_copy_aux(_InputIter __first, _InputIter __last, 43 | _ForwardIter __result, 44 | __true_type) 45 | { 46 | return copy(__first, __last, __result); 47 | } 48 | 49 | template 50 | _ForwardIter 51 | __uninitialized_copy_aux(_InputIter __first, _InputIter __last, 52 | _ForwardIter __result, 53 | __false_type) 54 | { 55 | _ForwardIter __cur = __result; 56 | __STL_TRY { 57 | for ( ; __first != __last; ++__first, ++__cur) 58 | _Construct(&*__cur, *__first); 59 | return __cur; 60 | } 61 | __STL_UNWIND(_Destroy(__result, __cur)); 62 | } 63 | 64 | 65 | template 66 | inline _ForwardIter 67 | __uninitialized_copy(_InputIter __first, _InputIter __last, 68 | _ForwardIter __result, _Tp*) 69 | { 70 | typedef typename __type_traits<_Tp>::is_POD_type _Is_POD; 71 | return __uninitialized_copy_aux(__first, __last, __result, _Is_POD()); 72 | } 73 | 74 | template 75 | inline _ForwardIter 76 | uninitialized_copy(_InputIter __first, _InputIter __last, 77 | _ForwardIter __result) 78 | { 79 | return __uninitialized_copy(__first, __last, __result, 80 | __VALUE_TYPE(__result)); 81 | } 82 | 83 | inline char* uninitialized_copy(const char* __first, const char* __last, 84 | char* __result) { 85 | memmove(__result, __first, __last - __first); 86 | return __result + (__last - __first); 87 | } 88 | 89 | inline wchar_t* 90 | uninitialized_copy(const wchar_t* __first, const wchar_t* __last, 91 | wchar_t* __result) 92 | { 93 | memmove(__result, __first, sizeof(wchar_t) * (__last - __first)); 94 | return __result + (__last - __first); 95 | } 96 | 97 | // uninitialized_copy_n (not part of the C++ standard) 98 | 99 | template 100 | pair<_InputIter, _ForwardIter> 101 | __uninitialized_copy_n(_InputIter __first, _Size __count, 102 | _ForwardIter __result, 103 | input_iterator_tag) 104 | { 105 | _ForwardIter __cur = __result; 106 | __STL_TRY { 107 | for ( ; __count > 0 ; --__count, ++__first, ++__cur) 108 | _Construct(&*__cur, *__first); 109 | return pair<_InputIter, _ForwardIter>(__first, __cur); 110 | } 111 | __STL_UNWIND(_Destroy(__result, __cur)); 112 | } 113 | 114 | template 115 | inline pair<_RandomAccessIter, _ForwardIter> 116 | __uninitialized_copy_n(_RandomAccessIter __first, _Size __count, 117 | _ForwardIter __result, 118 | random_access_iterator_tag) { 119 | _RandomAccessIter __last = __first + __count; 120 | return pair<_RandomAccessIter, _ForwardIter>( 121 | __last, 122 | uninitialized_copy(__first, __last, __result)); 123 | } 124 | 125 | template 126 | inline pair<_InputIter, _ForwardIter> 127 | __uninitialized_copy_n(_InputIter __first, _Size __count, 128 | _ForwardIter __result) { 129 | return __uninitialized_copy_n(__first, __count, __result, 130 | __ITERATOR_CATEGORY(__first)); 131 | } 132 | 133 | template 134 | inline pair<_InputIter, _ForwardIter> 135 | uninitialized_copy_n(_InputIter __first, _Size __count, 136 | _ForwardIter __result) { 137 | return __uninitialized_copy_n(__first, __count, __result, 138 | __ITERATOR_CATEGORY(__first)); 139 | } 140 | 141 | // Valid if copy construction is equivalent to assignment, and if the 142 | // destructor is trivial. 143 | template 144 | inline void 145 | __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, 146 | const _Tp& __x, __true_type) 147 | { 148 | fill(__first, __last, __x); 149 | } 150 | 151 | template 152 | void 153 | __uninitialized_fill_aux(_ForwardIter __first, _ForwardIter __last, 154 | const _Tp& __x, __false_type) 155 | { 156 | _ForwardIter __cur = __first; 157 | __STL_TRY { 158 | for ( ; __cur != __last; ++__cur) 159 | _Construct(&*__cur, __x); 160 | } 161 | __STL_UNWIND(_Destroy(__first, __cur)); 162 | } 163 | 164 | template 165 | inline void __uninitialized_fill(_ForwardIter __first, 166 | _ForwardIter __last, const _Tp& __x, _Tp1*) 167 | { 168 | typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; 169 | __uninitialized_fill_aux(__first, __last, __x, _Is_POD()); 170 | 171 | } 172 | 173 | template 174 | inline void uninitialized_fill(_ForwardIter __first, 175 | _ForwardIter __last, 176 | const _Tp& __x) 177 | { 178 | __uninitialized_fill(__first, __last, __x, __VALUE_TYPE(__first)); 179 | } 180 | 181 | // Valid if copy construction is equivalent to assignment, and if the 182 | // destructor is trivial. 183 | template 184 | inline _ForwardIter 185 | __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, 186 | const _Tp& __x, __true_type) 187 | { 188 | return fill_n(__first, __n, __x); 189 | } 190 | 191 | template 192 | _ForwardIter 193 | __uninitialized_fill_n_aux(_ForwardIter __first, _Size __n, 194 | const _Tp& __x, __false_type) 195 | { 196 | _ForwardIter __cur = __first; 197 | __STL_TRY { 198 | for ( ; __n > 0; --__n, ++__cur) 199 | _Construct(&*__cur, __x); 200 | return __cur; 201 | } 202 | __STL_UNWIND(_Destroy(__first, __cur)); 203 | } 204 | 205 | template 206 | inline _ForwardIter 207 | __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x, _Tp1*) 208 | { 209 | typedef typename __type_traits<_Tp1>::is_POD_type _Is_POD; 210 | return __uninitialized_fill_n_aux(__first, __n, __x, _Is_POD()); 211 | } 212 | 213 | template 214 | inline _ForwardIter 215 | uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) 216 | { 217 | return __uninitialized_fill_n(__first, __n, __x, __VALUE_TYPE(__first)); 218 | } 219 | 220 | // Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, 221 | // __uninitialized_fill_copy. 222 | 223 | // __uninitialized_copy_copy 224 | // Copies [first1, last1) into [result, result + (last1 - first1)), and 225 | // copies [first2, last2) into 226 | // [result, result + (last1 - first1) + (last2 - first2)). 227 | 228 | template 229 | inline _ForwardIter 230 | __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, 231 | _InputIter2 __first2, _InputIter2 __last2, 232 | _ForwardIter __result) 233 | { 234 | _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result); 235 | __STL_TRY { 236 | return uninitialized_copy(__first2, __last2, __mid); 237 | } 238 | __STL_UNWIND(_Destroy(__result, __mid)); 239 | } 240 | 241 | // __uninitialized_fill_copy 242 | // Fills [result, mid) with x, and copies [first, last) into 243 | // [mid, mid + (last - first)). 244 | template 245 | inline _ForwardIter 246 | __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, 247 | const _Tp& __x, 248 | _InputIter __first, _InputIter __last) 249 | { 250 | uninitialized_fill(__result, __mid, __x); 251 | __STL_TRY { 252 | return uninitialized_copy(__first, __last, __mid); 253 | } 254 | __STL_UNWIND(_Destroy(__result, __mid)); 255 | } 256 | 257 | // __uninitialized_copy_fill 258 | // Copies [first1, last1) into [first2, first2 + (last1 - first1)), and 259 | // fills [first2 + (last1 - first1), last2) with x. 260 | template 261 | inline void 262 | __uninitialized_copy_fill(_InputIter __first1, _InputIter __last1, 263 | _ForwardIter __first2, _ForwardIter __last2, 264 | const _Tp& __x) 265 | { 266 | _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2); 267 | __STL_TRY { 268 | uninitialized_fill(__mid2, __last2, __x); 269 | } 270 | __STL_UNWIND(_Destroy(__first2, __mid2)); 271 | } 272 | 273 | __STL_END_NAMESPACE 274 | 275 | #endif /* __SGI_STL_INTERNAL_UNINITIALIZED_H */ 276 | 277 | // Local Variables: 278 | // mode:C++ 279 | // End: 280 | -------------------------------------------------------------------------------- /include/stl_set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_SET_H 32 | #define __SGI_STL_INTERNAL_SET_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 39 | #pragma set woff 1174 40 | #pragma set woff 1375 41 | #endif 42 | 43 | // Forward declarations of operators < and ==, needed for friend declaration. 44 | 45 | template ), 46 | class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > 47 | class set; 48 | 49 | template 50 | inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, 51 | const set<_Key,_Compare,_Alloc>& __y); 52 | 53 | template 54 | inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, 55 | const set<_Key,_Compare,_Alloc>& __y); 56 | 57 | 58 | template 59 | class set { 60 | // requirements: 61 | 62 | __STL_CLASS_REQUIRES(_Key, _Assignable); 63 | __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); 64 | 65 | public: 66 | // typedefs: 67 | 68 | typedef _Key key_type; 69 | typedef _Key value_type; 70 | typedef _Compare key_compare; 71 | typedef _Compare value_compare; 72 | private: 73 | typedef _Rb_tree, key_compare, _Alloc> _Rep_type; 75 | _Rep_type _M_t; // red-black tree representing set 76 | public: 77 | typedef typename _Rep_type::const_pointer pointer; 78 | typedef typename _Rep_type::const_pointer const_pointer; 79 | typedef typename _Rep_type::const_reference reference; 80 | typedef typename _Rep_type::const_reference const_reference; 81 | typedef typename _Rep_type::const_iterator iterator; 82 | typedef typename _Rep_type::const_iterator const_iterator; 83 | typedef typename _Rep_type::const_reverse_iterator reverse_iterator; 84 | typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; 85 | typedef typename _Rep_type::size_type size_type; 86 | typedef typename _Rep_type::difference_type difference_type; 87 | typedef typename _Rep_type::allocator_type allocator_type; 88 | 89 | // allocation/deallocation 90 | 91 | set() : _M_t(_Compare(), allocator_type()) {} 92 | explicit set(const _Compare& __comp, 93 | const allocator_type& __a = allocator_type()) 94 | : _M_t(__comp, __a) {} 95 | 96 | #ifdef __STL_MEMBER_TEMPLATES 97 | template 98 | set(_InputIterator __first, _InputIterator __last) 99 | : _M_t(_Compare(), allocator_type()) 100 | { _M_t.insert_unique(__first, __last); } 101 | 102 | template 103 | set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, 104 | const allocator_type& __a = allocator_type()) 105 | : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 106 | #else 107 | set(const value_type* __first, const value_type* __last) 108 | : _M_t(_Compare(), allocator_type()) 109 | { _M_t.insert_unique(__first, __last); } 110 | 111 | set(const value_type* __first, 112 | const value_type* __last, const _Compare& __comp, 113 | const allocator_type& __a = allocator_type()) 114 | : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 115 | 116 | set(const_iterator __first, const_iterator __last) 117 | : _M_t(_Compare(), allocator_type()) 118 | { _M_t.insert_unique(__first, __last); } 119 | 120 | set(const_iterator __first, const_iterator __last, const _Compare& __comp, 121 | const allocator_type& __a = allocator_type()) 122 | : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 123 | #endif /* __STL_MEMBER_TEMPLATES */ 124 | 125 | set(const set<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} 126 | set<_Key,_Compare,_Alloc>& operator=(const set<_Key, _Compare, _Alloc>& __x) 127 | { 128 | _M_t = __x._M_t; 129 | return *this; 130 | } 131 | 132 | // accessors: 133 | 134 | key_compare key_comp() const { return _M_t.key_comp(); } 135 | value_compare value_comp() const { return _M_t.key_comp(); } 136 | allocator_type get_allocator() const { return _M_t.get_allocator(); } 137 | 138 | iterator begin() const { return _M_t.begin(); } 139 | iterator end() const { return _M_t.end(); } 140 | reverse_iterator rbegin() const { return _M_t.rbegin(); } 141 | reverse_iterator rend() const { return _M_t.rend(); } 142 | bool empty() const { return _M_t.empty(); } 143 | size_type size() const { return _M_t.size(); } 144 | size_type max_size() const { return _M_t.max_size(); } 145 | void swap(set<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } 146 | 147 | // insert/erase 148 | pair insert(const value_type& __x) { 149 | pair __p = _M_t.insert_unique(__x); 150 | return pair(__p.first, __p.second); 151 | } 152 | iterator insert(iterator __position, const value_type& __x) { 153 | typedef typename _Rep_type::iterator _Rep_iterator; 154 | return _M_t.insert_unique((_Rep_iterator&)__position, __x); 155 | } 156 | #ifdef __STL_MEMBER_TEMPLATES 157 | template 158 | void insert(_InputIterator __first, _InputIterator __last) { 159 | _M_t.insert_unique(__first, __last); 160 | } 161 | #else 162 | void insert(const_iterator __first, const_iterator __last) { 163 | _M_t.insert_unique(__first, __last); 164 | } 165 | void insert(const value_type* __first, const value_type* __last) { 166 | _M_t.insert_unique(__first, __last); 167 | } 168 | #endif /* __STL_MEMBER_TEMPLATES */ 169 | void erase(iterator __position) { 170 | typedef typename _Rep_type::iterator _Rep_iterator; 171 | _M_t.erase((_Rep_iterator&)__position); 172 | } 173 | size_type erase(const key_type& __x) { 174 | return _M_t.erase(__x); 175 | } 176 | void erase(iterator __first, iterator __last) { 177 | typedef typename _Rep_type::iterator _Rep_iterator; 178 | _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); 179 | } 180 | void clear() { _M_t.clear(); } 181 | 182 | // set operations: 183 | 184 | iterator find(const key_type& __x) const { return _M_t.find(__x); } 185 | size_type count(const key_type& __x) const { 186 | return _M_t.find(__x) == _M_t.end() ? 0 : 1; 187 | } 188 | iterator lower_bound(const key_type& __x) const { 189 | return _M_t.lower_bound(__x); 190 | } 191 | iterator upper_bound(const key_type& __x) const { 192 | return _M_t.upper_bound(__x); 193 | } 194 | pair equal_range(const key_type& __x) const { 195 | return _M_t.equal_range(__x); 196 | } 197 | 198 | #ifdef __STL_TEMPLATE_FRIENDS 199 | template 200 | friend bool operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); 201 | template 202 | friend bool operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); 203 | #else /* __STL_TEMPLATE_FRIENDS */ 204 | friend bool __STD_QUALIFIER 205 | operator== __STL_NULL_TMPL_ARGS (const set&, const set&); 206 | friend bool __STD_QUALIFIER 207 | operator< __STL_NULL_TMPL_ARGS (const set&, const set&); 208 | #endif /* __STL_TEMPLATE_FRIENDS */ 209 | }; 210 | 211 | template 212 | inline bool operator==(const set<_Key,_Compare,_Alloc>& __x, 213 | const set<_Key,_Compare,_Alloc>& __y) { 214 | return __x._M_t == __y._M_t; 215 | } 216 | 217 | template 218 | inline bool operator<(const set<_Key,_Compare,_Alloc>& __x, 219 | const set<_Key,_Compare,_Alloc>& __y) { 220 | return __x._M_t < __y._M_t; 221 | } 222 | 223 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 224 | 225 | template 226 | inline bool operator!=(const set<_Key,_Compare,_Alloc>& __x, 227 | const set<_Key,_Compare,_Alloc>& __y) { 228 | return !(__x == __y); 229 | } 230 | 231 | template 232 | inline bool operator>(const set<_Key,_Compare,_Alloc>& __x, 233 | const set<_Key,_Compare,_Alloc>& __y) { 234 | return __y < __x; 235 | } 236 | 237 | template 238 | inline bool operator<=(const set<_Key,_Compare,_Alloc>& __x, 239 | const set<_Key,_Compare,_Alloc>& __y) { 240 | return !(__y < __x); 241 | } 242 | 243 | template 244 | inline bool operator>=(const set<_Key,_Compare,_Alloc>& __x, 245 | const set<_Key,_Compare,_Alloc>& __y) { 246 | return !(__x < __y); 247 | } 248 | 249 | template 250 | inline void swap(set<_Key,_Compare,_Alloc>& __x, 251 | set<_Key,_Compare,_Alloc>& __y) { 252 | __x.swap(__y); 253 | } 254 | 255 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 256 | 257 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 258 | #pragma reset woff 1174 259 | #pragma reset woff 1375 260 | #endif 261 | 262 | __STL_END_NAMESPACE 263 | 264 | #endif /* __SGI_STL_INTERNAL_SET_H */ 265 | 266 | // Local Variables: 267 | // mode:C++ 268 | // End: 269 | -------------------------------------------------------------------------------- /include/container_concepts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999 3 | * Silicon Graphics Computer Systems, Inc. 4 | * 5 | * Permission to use, copy, modify, distribute and sell this software 6 | * and its documentation for any purpose is hereby granted without fee, 7 | * provided that the above copyright notice appear in all copies and 8 | * that both that copyright notice and this permission notice appear 9 | * in supporting documentation. Silicon Graphics makes no 10 | * representations about the suitability of this software for any 11 | * purpose. It is provided "as is" without express or implied warranty. 12 | */ 13 | 14 | #ifndef __STL_CONTAINER_CONCEPTS_H 15 | #define __STL_CONTAINER_CONCEPTS_H 16 | 17 | 18 | #include 19 | 20 | #ifdef __STL_USE_CONCEPT_CHECKS 21 | 22 | 23 | // This file covers the following concepts: 24 | // _Container 25 | // _ForwardContainer 26 | // _ReversibleContainer 27 | // _const_ReversibleContainer 28 | // _RandomAccessContainer 29 | // 30 | 31 | struct _ERROR_IN_STL_CONTAINER { 32 | 33 | /* Container expresssions */ 34 | 35 | template 36 | static void 37 | __begin_iterator_accessor_requirement_violation(_Container __c) { 38 | __c.begin(); 39 | } 40 | template 41 | static void 42 | __const_begin_iterator_accessor_requirement_violation(const _Container& __c) { 43 | __c.begin(); 44 | } 45 | template 46 | static void 47 | __end_iterator_accessor_requirement_violation(_Container __c) { 48 | __c.end(); 49 | } 50 | template 51 | static void 52 | __const_end_iterator_accessor_requirement_violation(const _Container& __c) { 53 | __c.end(); 54 | } 55 | 56 | template 57 | static void 58 | __rbegin_iterator_accessor_requirement_violation(_Container __c) { 59 | __c.rbegin(); 60 | } 61 | template 62 | static void 63 | __const_rbegin_iterator_accessor_requirement_violation(const _Container& __c) { 64 | __c.rbegin(); 65 | } 66 | template 67 | static void 68 | __rend_iterator_accessor_requirement_violation(_Container __c) { 69 | __c.rend(); 70 | } 71 | template 72 | static void 73 | __const_rend_iterator_accessor_requirement_violation(const _Container& __c) { 74 | __c.rend(); 75 | } 76 | template 77 | static void 78 | __size_function_must_be_const(const _Container& __c) { 79 | __c.size(); 80 | } 81 | template 82 | static void 83 | __size_function_requirement_violation(_Container& __c) { 84 | __c.size(); 85 | __size_function_must_be_const(__c); 86 | } 87 | template 88 | static void 89 | __max_size_function_must_be_const(const _Container& __c) { 90 | __c.max_size(); 91 | } 92 | template 93 | static void 94 | __max_size_function_requirement_violation(_Container& __c) { 95 | __c.max_size(); 96 | __max_size_function_must_be_const(__c); 97 | } 98 | template 99 | static void 100 | __empty_function_must_be_const(const _Container& __c) { 101 | __c.empty(); 102 | } 103 | template 104 | static void 105 | __empty_function_requirement_violation(_Container& __c) { 106 | __c.empty(); 107 | __empty_function_must_be_const(__c); 108 | } 109 | template 110 | static void 111 | __swap_function_requirement_violation(_Container& __c) { 112 | __c.swap(__c); 113 | } 114 | 115 | }; 116 | 117 | 118 | __STL_TYPEDEF_REQUIREMENT(iterator); 119 | __STL_TYPEDEF_REQUIREMENT(const_iterator); 120 | 121 | /* Containers */ 122 | 123 | template 124 | struct _Container_concept_specification { 125 | static void 126 | _Container_requirement_violation(_Container __c) { 127 | // Refinement of Assignable 128 | _Assignable_concept_specification<_Container>::_Assignable_requirement_violation(__c); 129 | // Associated Types 130 | __value_type__typedef_requirement_violation<_Container>(); 131 | __difference_type__typedef_requirement_violation<_Container>(); 132 | __size_type__typedef_requirement_violation<_Container>(); 133 | __reference__typedef_requirement_violation<_Container>(); 134 | __const_reference__typedef_requirement_violation<_Container>(); 135 | __pointer__typedef_requirement_violation<_Container>(); 136 | __const_pointer__typedef_requirement_violation<_Container>(); 137 | __iterator__typedef_requirement_violation<_Container>(); 138 | __const_iterator__typedef_requirement_violation<_Container>(); 139 | // Valid Expressions 140 | _ERROR_IN_STL_CONTAINER::__const_begin_iterator_accessor_requirement_violation(__c); 141 | _ERROR_IN_STL_CONTAINER::__const_end_iterator_accessor_requirement_violation(__c); 142 | _ERROR_IN_STL_CONTAINER::__begin_iterator_accessor_requirement_violation(__c); 143 | _ERROR_IN_STL_CONTAINER::__end_iterator_accessor_requirement_violation(__c); 144 | _ERROR_IN_STL_CONTAINER::__size_function_requirement_violation(__c); 145 | _ERROR_IN_STL_CONTAINER::__max_size_function_requirement_violation(__c); 146 | _ERROR_IN_STL_CONTAINER::__empty_function_requirement_violation(__c); 147 | _ERROR_IN_STL_CONTAINER::__swap_function_requirement_violation(__c); 148 | // Requirements on Iterators 149 | typedef typename _Container::iterator iter; 150 | typedef typename _Container::const_iterator const_iter; 151 | _InputIterator_concept_specification::_InputIterator_requirement_violation(const_iter()); 152 | _InputIterator_concept_specification::_InputIterator_requirement_violation(iter()); 153 | } 154 | }; 155 | 156 | template 157 | struct _ForwardContainer_concept_specification { 158 | static void 159 | _ForwardContainer_requirement_violation(_ForwardContainer __c) { 160 | // Refinement of Container 161 | _Container_concept_specification<_ForwardContainer>::_Container_requirement_violation(__c); 162 | // Requirements on Iterators 163 | typedef typename _ForwardContainer::iterator iter; 164 | typedef typename _ForwardContainer::const_iterator const_iter; 165 | _ForwardIterator_concept_specification::_ForwardIterator_requirement_violation(const_iter()); 166 | _Mutable_ForwardIterator_concept_specification::_Mutable_ForwardIterator_requirement_violation(iter()); 167 | } 168 | }; 169 | 170 | 171 | __STL_TYPEDEF_REQUIREMENT(reverse_iterator); 172 | __STL_TYPEDEF_REQUIREMENT(const_reverse_iterator); 173 | 174 | template 175 | struct _ReversibleContainer_concept_specification { 176 | static void 177 | _ReversibleContainer_requirement_violation(_ReversibleContainer __c) { 178 | // Refinement of ForwardContainer 179 | _ForwardContainer_concept_specification<_ReversibleContainer>::_ForwardContainer_requirement_violation(__c); 180 | // Associated types 181 | __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); 182 | __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); 183 | // Valid Expressions 184 | _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); 185 | _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); 186 | _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); 187 | _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); 188 | // Requirements on Iterators 189 | typedef typename _ReversibleContainer::iterator iter; 190 | typedef typename _ReversibleContainer::const_iterator const_iter; 191 | _BidirectionalIterator_concept_specification::_BidirectionalIterator_requirement_violation(const_iter()); 192 | _Mutable_BidirectionalIterator_concept_specification::_Mutable_BidirectionalIterator_requirement_violation(iter()); 193 | } 194 | }; 195 | 196 | template 197 | struct _const_ReversibleContainer_concept_specification { 198 | static void 199 | _const_ReversibleContainer_requirement_violation(_ReversibleContainer __c) { 200 | // Refinement of Container (JGS, not ForwardContainer) 201 | _Container_concept_specification<_ReversibleContainer>::_Container_requirement_violation(__c); 202 | // Associated types 203 | __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); 204 | __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); 205 | // Valid Expressions 206 | _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); 207 | _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); 208 | _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); 209 | _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); 210 | // Requirements on Iterators 211 | typedef typename _ReversibleContainer::iterator iter; 212 | typedef typename _ReversibleContainer::const_iterator const_iter; 213 | 214 | // This line won't compile on gcc 2.91 due to a compiler bug 215 | // Doesn't seem happy on avr-gcc 4.5.1 either 216 | 217 | #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 91) && !defined(__AVR__) 218 | __BidirectionalIterator_concept_specification::_BidirectionalIterator_requirement_violation(const_iter()); 219 | #endif 220 | } 221 | }; 222 | 223 | 224 | template 225 | struct _RandomAccessContainer_concept_specification { 226 | static void 227 | _RandomAccessContainer_requirement_violation(_RandomAccessContainer __c) { 228 | // Refinement of ReversibleContainer 229 | _ReversibleContainer_concept_specification<_RandomAccessContainer>::_ReversibleContainer_requirement_violation(__c); 230 | // Valid Expressions 231 | typedef typename _RandomAccessContainer::value_type __T; 232 | typedef typename _RandomAccessContainer::difference_type _Dist; 233 | typedef typename _Mutable_trait<__T>::_Type Type; 234 | typedef Type* _TypePtr; 235 | typedef typename _Mutable_trait<_Dist>::_Type Dist; 236 | _STL_ERROR::__element_access_operator_requirement_violation(__c, 237 | _TypePtr(), 238 | Dist()); 239 | // Requirements on Iterators 240 | typedef typename _RandomAccessContainer::iterator iter; 241 | typedef typename _RandomAccessContainer::const_iterator const_iter; 242 | _RandomAccessIterator_concept_specification::_RandomAccessIterator_requirement_violation(const_iter()); 243 | _Mutable_RandomAccessIterator_concept_specification::_Mutable_RandomAccessIterator_requirement_violation(iter()); 244 | } 245 | }; 246 | 247 | #endif /* if __STL_USE_CONCEPT_CHECKS */ 248 | 249 | #endif /* __STL_CONTAINER_CONCEPTS_H */ 250 | -------------------------------------------------------------------------------- /include/stl_multiset.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_MULTISET_H 32 | #define __SGI_STL_INTERNAL_MULTISET_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 39 | #pragma set woff 1174 40 | #pragma set woff 1375 41 | #endif 42 | 43 | // Forward declaration of operators < and ==, needed for friend declaration. 44 | 45 | template ), 46 | class _Alloc = __STL_DEFAULT_ALLOCATOR(_Key) > 47 | class multiset; 48 | 49 | template 50 | inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, 51 | const multiset<_Key,_Compare,_Alloc>& __y); 52 | 53 | template 54 | inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, 55 | const multiset<_Key,_Compare,_Alloc>& __y); 56 | 57 | template 58 | class multiset { 59 | // requirements: 60 | 61 | __STL_CLASS_REQUIRES(_Key, _Assignable); 62 | __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); 63 | 64 | public: 65 | 66 | // typedefs: 67 | 68 | typedef _Key key_type; 69 | typedef _Key value_type; 70 | typedef _Compare key_compare; 71 | typedef _Compare value_compare; 72 | private: 73 | typedef _Rb_tree, key_compare, _Alloc> _Rep_type; 75 | _Rep_type _M_t; // red-black tree representing multiset 76 | public: 77 | typedef typename _Rep_type::const_pointer pointer; 78 | typedef typename _Rep_type::const_pointer const_pointer; 79 | typedef typename _Rep_type::const_reference reference; 80 | typedef typename _Rep_type::const_reference const_reference; 81 | typedef typename _Rep_type::const_iterator iterator; 82 | typedef typename _Rep_type::const_iterator const_iterator; 83 | typedef typename _Rep_type::const_reverse_iterator reverse_iterator; 84 | typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; 85 | typedef typename _Rep_type::size_type size_type; 86 | typedef typename _Rep_type::difference_type difference_type; 87 | typedef typename _Rep_type::allocator_type allocator_type; 88 | 89 | // allocation/deallocation 90 | 91 | multiset() : _M_t(_Compare(), allocator_type()) {} 92 | explicit multiset(const _Compare& __comp, 93 | const allocator_type& __a = allocator_type()) 94 | : _M_t(__comp, __a) {} 95 | 96 | #ifdef __STL_MEMBER_TEMPLATES 97 | 98 | template 99 | multiset(_InputIterator __first, _InputIterator __last) 100 | : _M_t(_Compare(), allocator_type()) 101 | { _M_t.insert_equal(__first, __last); } 102 | 103 | template 104 | multiset(_InputIterator __first, _InputIterator __last, 105 | const _Compare& __comp, 106 | const allocator_type& __a = allocator_type()) 107 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 108 | 109 | #else 110 | 111 | multiset(const value_type* __first, const value_type* __last) 112 | : _M_t(_Compare(), allocator_type()) 113 | { _M_t.insert_equal(__first, __last); } 114 | 115 | multiset(const value_type* __first, const value_type* __last, 116 | const _Compare& __comp, 117 | const allocator_type& __a = allocator_type()) 118 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 119 | 120 | multiset(const_iterator __first, const_iterator __last) 121 | : _M_t(_Compare(), allocator_type()) 122 | { _M_t.insert_equal(__first, __last); } 123 | 124 | multiset(const_iterator __first, const_iterator __last, 125 | const _Compare& __comp, 126 | const allocator_type& __a = allocator_type()) 127 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 128 | 129 | #endif /* __STL_MEMBER_TEMPLATES */ 130 | 131 | multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {} 132 | multiset<_Key,_Compare,_Alloc>& 133 | operator=(const multiset<_Key,_Compare,_Alloc>& __x) { 134 | _M_t = __x._M_t; 135 | return *this; 136 | } 137 | 138 | // accessors: 139 | 140 | key_compare key_comp() const { return _M_t.key_comp(); } 141 | value_compare value_comp() const { return _M_t.key_comp(); } 142 | allocator_type get_allocator() const { return _M_t.get_allocator(); } 143 | 144 | iterator begin() const { return _M_t.begin(); } 145 | iterator end() const { return _M_t.end(); } 146 | reverse_iterator rbegin() const { return _M_t.rbegin(); } 147 | reverse_iterator rend() const { return _M_t.rend(); } 148 | bool empty() const { return _M_t.empty(); } 149 | size_type size() const { return _M_t.size(); } 150 | size_type max_size() const { return _M_t.max_size(); } 151 | void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } 152 | 153 | // insert/erase 154 | iterator insert(const value_type& __x) { 155 | return _M_t.insert_equal(__x); 156 | } 157 | iterator insert(iterator __position, const value_type& __x) { 158 | typedef typename _Rep_type::iterator _Rep_iterator; 159 | return _M_t.insert_equal((_Rep_iterator&)__position, __x); 160 | } 161 | 162 | #ifdef __STL_MEMBER_TEMPLATES 163 | template 164 | void insert(_InputIterator __first, _InputIterator __last) { 165 | _M_t.insert_equal(__first, __last); 166 | } 167 | #else 168 | void insert(const value_type* __first, const value_type* __last) { 169 | _M_t.insert_equal(__first, __last); 170 | } 171 | void insert(const_iterator __first, const_iterator __last) { 172 | _M_t.insert_equal(__first, __last); 173 | } 174 | #endif /* __STL_MEMBER_TEMPLATES */ 175 | void erase(iterator __position) { 176 | typedef typename _Rep_type::iterator _Rep_iterator; 177 | _M_t.erase((_Rep_iterator&)__position); 178 | } 179 | size_type erase(const key_type& __x) { 180 | return _M_t.erase(__x); 181 | } 182 | void erase(iterator __first, iterator __last) { 183 | typedef typename _Rep_type::iterator _Rep_iterator; 184 | _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last); 185 | } 186 | void clear() { _M_t.clear(); } 187 | 188 | // multiset operations: 189 | 190 | iterator find(const key_type& __x) const { return _M_t.find(__x); } 191 | size_type count(const key_type& __x) const { return _M_t.count(__x); } 192 | iterator lower_bound(const key_type& __x) const { 193 | return _M_t.lower_bound(__x); 194 | } 195 | iterator upper_bound(const key_type& __x) const { 196 | return _M_t.upper_bound(__x); 197 | } 198 | pair equal_range(const key_type& __x) const { 199 | return _M_t.equal_range(__x); 200 | } 201 | 202 | #ifdef __STL_TEMPLATE_FRIENDS 203 | template 204 | friend bool operator== (const multiset<_K1,_C1,_A1>&, 205 | const multiset<_K1,_C1,_A1>&); 206 | template 207 | friend bool operator< (const multiset<_K1,_C1,_A1>&, 208 | const multiset<_K1,_C1,_A1>&); 209 | #else /* __STL_TEMPLATE_FRIENDS */ 210 | friend bool __STD_QUALIFIER 211 | operator== __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); 212 | friend bool __STD_QUALIFIER 213 | operator< __STL_NULL_TMPL_ARGS (const multiset&, const multiset&); 214 | #endif /* __STL_TEMPLATE_FRIENDS */ 215 | }; 216 | 217 | template 218 | inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x, 219 | const multiset<_Key,_Compare,_Alloc>& __y) { 220 | return __x._M_t == __y._M_t; 221 | } 222 | 223 | template 224 | inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x, 225 | const multiset<_Key,_Compare,_Alloc>& __y) { 226 | return __x._M_t < __y._M_t; 227 | } 228 | 229 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 230 | 231 | template 232 | inline bool operator!=(const multiset<_Key,_Compare,_Alloc>& __x, 233 | const multiset<_Key,_Compare,_Alloc>& __y) { 234 | return !(__x == __y); 235 | } 236 | 237 | template 238 | inline bool operator>(const multiset<_Key,_Compare,_Alloc>& __x, 239 | const multiset<_Key,_Compare,_Alloc>& __y) { 240 | return __y < __x; 241 | } 242 | 243 | template 244 | inline bool operator<=(const multiset<_Key,_Compare,_Alloc>& __x, 245 | const multiset<_Key,_Compare,_Alloc>& __y) { 246 | return !(__y < __x); 247 | } 248 | 249 | template 250 | inline bool operator>=(const multiset<_Key,_Compare,_Alloc>& __x, 251 | const multiset<_Key,_Compare,_Alloc>& __y) { 252 | return !(__x < __y); 253 | } 254 | 255 | template 256 | inline void swap(multiset<_Key,_Compare,_Alloc>& __x, 257 | multiset<_Key,_Compare,_Alloc>& __y) { 258 | __x.swap(__y); 259 | } 260 | 261 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 262 | 263 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 264 | #pragma reset woff 1174 265 | #pragma reset woff 1375 266 | #endif 267 | 268 | __STL_END_NAMESPACE 269 | 270 | #endif /* __SGI_STL_INTERNAL_MULTISET_H */ 271 | 272 | // Local Variables: 273 | // mode:C++ 274 | // End: 275 | -------------------------------------------------------------------------------- /include/stl_heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * Copyright (c) 1997 15 | * Silicon Graphics Computer Systems, Inc. 16 | * 17 | * Permission to use, copy, modify, distribute and sell this software 18 | * and its documentation for any purpose is hereby granted without fee, 19 | * provided that the above copyright notice appear in all copies and 20 | * that both that copyright notice and this permission notice appear 21 | * in supporting documentation. Silicon Graphics makes no 22 | * representations about the suitability of this software for any 23 | * purpose. It is provided "as is" without express or implied warranty. 24 | */ 25 | 26 | /* NOTE: This is an internal header file, included by other STL headers. 27 | * You should not attempt to use it directly. 28 | */ 29 | 30 | #ifndef __SGI_STL_INTERNAL_HEAP_H 31 | #define __SGI_STL_INTERNAL_HEAP_H 32 | 33 | __STL_BEGIN_NAMESPACE 34 | 35 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 36 | #pragma set woff 1209 37 | #endif 38 | 39 | // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. 40 | 41 | template 42 | void 43 | __push_heap(_RandomAccessIterator __first, 44 | _Distance __holeIndex, _Distance __topIndex, _Tp __value) 45 | { 46 | _Distance __parent = (__holeIndex - 1) / 2; 47 | while (__holeIndex > __topIndex && *(__first + __parent) < __value) { 48 | *(__first + __holeIndex) = *(__first + __parent); 49 | __holeIndex = __parent; 50 | __parent = (__holeIndex - 1) / 2; 51 | } 52 | *(__first + __holeIndex) = __value; 53 | } 54 | 55 | template 56 | inline void 57 | __push_heap_aux(_RandomAccessIterator __first, 58 | _RandomAccessIterator __last, _Distance*, _Tp*) 59 | { 60 | __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), 61 | _Tp(*(__last - 1))); 62 | } 63 | 64 | template 65 | inline void 66 | push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) 67 | { 68 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 69 | __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, 70 | _LessThanComparable); 71 | __push_heap_aux(__first, __last, 72 | __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); 73 | } 74 | 75 | template 77 | void 78 | __push_heap(_RandomAccessIterator __first, _Distance __holeIndex, 79 | _Distance __topIndex, _Tp __value, _Compare __comp) 80 | { 81 | _Distance __parent = (__holeIndex - 1) / 2; 82 | while (__holeIndex > __topIndex && __comp(*(__first + __parent), __value)) { 83 | *(__first + __holeIndex) = *(__first + __parent); 84 | __holeIndex = __parent; 85 | __parent = (__holeIndex - 1) / 2; 86 | } 87 | *(__first + __holeIndex) = __value; 88 | } 89 | 90 | template 92 | inline void 93 | __push_heap_aux(_RandomAccessIterator __first, 94 | _RandomAccessIterator __last, _Compare __comp, 95 | _Distance*, _Tp*) 96 | { 97 | __push_heap(__first, _Distance((__last - __first) - 1), _Distance(0), 98 | _Tp(*(__last - 1)), __comp); 99 | } 100 | 101 | template 102 | inline void 103 | push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, 104 | _Compare __comp) 105 | { 106 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 107 | __push_heap_aux(__first, __last, __comp, 108 | __DISTANCE_TYPE(__first), __VALUE_TYPE(__first)); 109 | } 110 | 111 | template 112 | void 113 | __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, 114 | _Distance __len, _Tp __value) 115 | { 116 | _Distance __topIndex = __holeIndex; 117 | _Distance __secondChild = 2 * __holeIndex + 2; 118 | while (__secondChild < __len) { 119 | if (*(__first + __secondChild) < *(__first + (__secondChild - 1))) 120 | __secondChild--; 121 | *(__first + __holeIndex) = *(__first + __secondChild); 122 | __holeIndex = __secondChild; 123 | __secondChild = 2 * (__secondChild + 1); 124 | } 125 | if (__secondChild == __len) { 126 | *(__first + __holeIndex) = *(__first + (__secondChild - 1)); 127 | __holeIndex = __secondChild - 1; 128 | } 129 | __push_heap(__first, __holeIndex, __topIndex, __value); 130 | } 131 | 132 | template 133 | inline void 134 | __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, 135 | _RandomAccessIterator __result, _Tp __value, _Distance*) 136 | { 137 | *__result = *__first; 138 | __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value); 139 | } 140 | 141 | template 142 | inline void 143 | __pop_heap_aux(_RandomAccessIterator __first, _RandomAccessIterator __last, 144 | _Tp*) 145 | { 146 | __pop_heap(__first, __last - 1, __last - 1, 147 | _Tp(*(__last - 1)), __DISTANCE_TYPE(__first)); 148 | } 149 | 150 | template 151 | inline void pop_heap(_RandomAccessIterator __first, 152 | _RandomAccessIterator __last) 153 | { 154 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 155 | __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, 156 | _LessThanComparable); 157 | __pop_heap_aux(__first, __last, __VALUE_TYPE(__first)); 158 | } 159 | 160 | template 162 | void 163 | __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, 164 | _Distance __len, _Tp __value, _Compare __comp) 165 | { 166 | _Distance __topIndex = __holeIndex; 167 | _Distance __secondChild = 2 * __holeIndex + 2; 168 | while (__secondChild < __len) { 169 | if (__comp(*(__first + __secondChild), *(__first + (__secondChild - 1)))) 170 | __secondChild--; 171 | *(__first + __holeIndex) = *(__first + __secondChild); 172 | __holeIndex = __secondChild; 173 | __secondChild = 2 * (__secondChild + 1); 174 | } 175 | if (__secondChild == __len) { 176 | *(__first + __holeIndex) = *(__first + (__secondChild - 1)); 177 | __holeIndex = __secondChild - 1; 178 | } 179 | __push_heap(__first, __holeIndex, __topIndex, __value, __comp); 180 | } 181 | 182 | template 184 | inline void 185 | __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, 186 | _RandomAccessIterator __result, _Tp __value, _Compare __comp, 187 | _Distance*) 188 | { 189 | *__result = *__first; 190 | __adjust_heap(__first, _Distance(0), _Distance(__last - __first), 191 | __value, __comp); 192 | } 193 | 194 | template 195 | inline void 196 | __pop_heap_aux(_RandomAccessIterator __first, 197 | _RandomAccessIterator __last, _Tp*, _Compare __comp) 198 | { 199 | __pop_heap(__first, __last - 1, __last - 1, _Tp(*(__last - 1)), __comp, 200 | __DISTANCE_TYPE(__first)); 201 | } 202 | 203 | template 204 | inline void 205 | pop_heap(_RandomAccessIterator __first, 206 | _RandomAccessIterator __last, _Compare __comp) 207 | { 208 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 209 | __pop_heap_aux(__first, __last, __VALUE_TYPE(__first), __comp); 210 | } 211 | 212 | template 213 | void 214 | __make_heap(_RandomAccessIterator __first, 215 | _RandomAccessIterator __last, _Tp*, _Distance*) 216 | { 217 | if (__last - __first < 2) return; 218 | _Distance __len = __last - __first; 219 | _Distance __parent = (__len - 2)/2; 220 | 221 | while (true) { 222 | __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent))); 223 | if (__parent == 0) return; 224 | __parent--; 225 | } 226 | } 227 | 228 | template 229 | inline void 230 | make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) 231 | { 232 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 233 | __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, 234 | _LessThanComparable); 235 | __make_heap(__first, __last, 236 | __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); 237 | } 238 | 239 | template 241 | void 242 | __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, 243 | _Compare __comp, _Tp*, _Distance*) 244 | { 245 | if (__last - __first < 2) return; 246 | _Distance __len = __last - __first; 247 | _Distance __parent = (__len - 2)/2; 248 | 249 | while (true) { 250 | __adjust_heap(__first, __parent, __len, _Tp(*(__first + __parent)), 251 | __comp); 252 | if (__parent == 0) return; 253 | __parent--; 254 | } 255 | } 256 | 257 | template 258 | inline void 259 | make_heap(_RandomAccessIterator __first, 260 | _RandomAccessIterator __last, _Compare __comp) 261 | { 262 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 263 | __make_heap(__first, __last, __comp, 264 | __VALUE_TYPE(__first), __DISTANCE_TYPE(__first)); 265 | } 266 | 267 | template 268 | void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) 269 | { 270 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 271 | __STL_REQUIRES(typename iterator_traits<_RandomAccessIterator>::value_type, 272 | _LessThanComparable); 273 | while (__last - __first > 1) 274 | pop_heap(__first, __last--); 275 | } 276 | 277 | template 278 | void 279 | sort_heap(_RandomAccessIterator __first, 280 | _RandomAccessIterator __last, _Compare __comp) 281 | { 282 | __STL_REQUIRES(_RandomAccessIterator, _Mutable_RandomAccessIterator); 283 | while (__last - __first > 1) 284 | pop_heap(__first, __last--, __comp); 285 | } 286 | 287 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 288 | #pragma reset woff 1209 289 | #endif 290 | 291 | __STL_END_NAMESPACE 292 | 293 | #endif /* __SGI_STL_INTERNAL_HEAP_H */ 294 | 295 | // Local Variables: 296 | // mode:C++ 297 | // End: 298 | -------------------------------------------------------------------------------- /include/istream_helpers: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Garrett A. Kajmowicz 2 | 3 | This file is part of the uClibc++ Library. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #ifndef __STD_HEADER_ISTREAM_HELPERS 26 | #define __STD_HEADER_ISTREAM_HELPERS 1 27 | 28 | #pragma GCC visibility push(default) 29 | 30 | namespace std{ 31 | 32 | 33 | /* We are making the following template class for serveral reasons. Firstly, 34 | * we want to keep the main istream code neat and tidy. Secondly, we want it 35 | * to be easy to do partial specialization of the istream code so that it can 36 | * be expanded and put into the library. This will allow us to make application 37 | * code smaller at the expense of increased library size. This is a fair 38 | * trade-off when there are multiple applications being compiled. Also, this 39 | * feature will be used optionally via configuration options. It will also 40 | * allow us to keep the code bases in sync, dramatically simplifying the 41 | * maintenance required. We specialized for char because wchar and others 42 | * require different scanf functions 43 | */ 44 | 45 | template _UCXXEXPORT 46 | basic_string _readToken(basic_istream& stream) 47 | { 48 | basic_string temp; 49 | typename traits::int_type c; 50 | while(true){ 51 | c = stream.rdbuf()->sgetc(); 52 | if(c != traits::eof() && isspace(c) == false){ 53 | stream.rdbuf()->sbumpc(); 54 | temp.append(1, traits::to_char_type(c)); 55 | }else{ 56 | break; 57 | } 58 | } 59 | if (temp.size() == 0) 60 | stream.setstate(ios_base::eofbit|ios_base::failbit); 61 | 62 | return temp; 63 | } 64 | 65 | template _UCXXEXPORT 66 | basic_string _readTokenDecimal(basic_istream& stream) 67 | { 68 | basic_string temp; 69 | typename traits::int_type c; 70 | while(true){ 71 | c = stream.rdbuf()->sgetc(); 72 | if(c != traits::eof() && isspace(c) == false && (isdigit(c) || c == '.' || c == ',' )){ 73 | stream.rdbuf()->sbumpc(); 74 | temp.append(1, traits::to_char_type(c)); 75 | }else{ 76 | break; 77 | } 78 | } 79 | if (temp.size() == 0) 80 | stream.setstate(ios_base::eofbit|ios_base::failbit); 81 | 82 | return temp; 83 | } 84 | 85 | #ifdef __UCLIBCXX_EXPAND_ISTREAM_CHAR__ 86 | 87 | template <> _UCXXEXPORT string _readToken >(istream & stream); 88 | 89 | #endif 90 | 91 | 92 | template class _UCXXEXPORT __istream_readin{ 93 | public: 94 | static void readin(basic_istream& stream, dataType & var); 95 | }; 96 | 97 | template class _UCXXEXPORT __istream_readin{ 98 | public: 99 | inline static void readin(basic_istream& stream, bool & var) 100 | { 101 | basic_string temp; 102 | temp = _readToken( stream); 103 | if(temp == "true" || temp == "True" || temp == "TRUE" || temp == "1"){ 104 | var = true; 105 | }else{ 106 | var = false; 107 | } 108 | } 109 | }; 110 | 111 | 112 | template class _UCXXEXPORT __istream_readin{ 113 | public: 114 | inline static void readin(basic_istream& stream, short & var) 115 | { 116 | basic_string temp; 117 | 118 | if(stream.flags() & ios_base::dec){ 119 | temp = _readTokenDecimal( stream); 120 | sscanf(temp.c_str(), "%hd", &var ); 121 | }else{ 122 | temp = _readToken( stream); 123 | if( stream.flags() & ios_base::oct){ 124 | sscanf(temp.c_str(), "%ho", (unsigned short int *)(&var) ); 125 | }else if(stream.flags() & ios_base::hex){ 126 | if(stream.flags() & ios_base::uppercase){ 127 | sscanf(temp.c_str(), "%hX", (unsigned short int *)(&var) ); 128 | }else{ 129 | sscanf(temp.c_str(), "%hx", (unsigned short int *)(&var) ); 130 | } 131 | }else{ 132 | sscanf(temp.c_str(), "%hi", &var); 133 | 134 | } 135 | } 136 | } 137 | }; 138 | 139 | template class _UCXXEXPORT __istream_readin{ 140 | public: 141 | inline static void readin(basic_istream& stream, unsigned short & var) 142 | { 143 | basic_string temp; 144 | 145 | if(stream.flags() & ios_base::dec){ 146 | temp = _readTokenDecimal( stream); 147 | sscanf(temp.c_str(), "%hu", &var ); 148 | }else{ 149 | temp = _readToken( stream); 150 | if( stream.flags() & ios_base::oct){ 151 | sscanf(temp.c_str(), "%ho", &var); 152 | }else if(stream.flags() & ios_base::hex){ 153 | if(stream.flags() & ios_base::uppercase){ 154 | sscanf(temp.c_str(), "%hX", &var ); 155 | }else{ 156 | sscanf(temp.c_str(), "%hx", &var); 157 | } 158 | }else{ 159 | sscanf(temp.c_str(), "%hi", (signed short int*)(&var) ); 160 | } 161 | } 162 | } 163 | }; 164 | 165 | template class _UCXXEXPORT __istream_readin{ 166 | public: 167 | inline static void readin(basic_istream& stream, int & var) 168 | { 169 | basic_string temp; 170 | 171 | if(stream.flags() & ios_base::dec){ 172 | temp = _readTokenDecimal( stream); 173 | sscanf(temp.c_str(), "%d", &var ); 174 | }else{ 175 | temp = _readToken( stream); 176 | if( stream.flags() & ios_base::oct){ 177 | sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); 178 | }else if(stream.flags() & ios_base::hex){ 179 | if(stream.flags() & ios_base::uppercase){ 180 | sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); 181 | }else{ 182 | sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); 183 | } 184 | }else{ 185 | sscanf(temp.c_str(), "%i", &var); 186 | } 187 | } 188 | } 189 | }; 190 | 191 | template class _UCXXEXPORT __istream_readin{ 192 | public: 193 | inline static void readin(basic_istream& stream, unsigned int & var) 194 | { 195 | basic_string temp; 196 | 197 | if(stream.flags() & ios_base::dec){ 198 | temp = _readTokenDecimal( stream); 199 | sscanf(temp.c_str(), "%u", &var ); 200 | }else{ 201 | temp = _readToken( stream); 202 | if( stream.flags() & ios_base::oct){ 203 | sscanf(temp.c_str(), "%o", (unsigned int *)(&var) ); 204 | }else if(stream.flags() & ios_base::hex){ 205 | if(stream.flags() & ios_base::uppercase){ 206 | sscanf(temp.c_str(), "%X", (unsigned int *)(&var) ); 207 | }else{ 208 | sscanf(temp.c_str(), "%x", (unsigned int *)(&var) ); 209 | } 210 | }else{ 211 | sscanf(temp.c_str(), "%i", (int *)(&var) ); 212 | } 213 | } 214 | 215 | } 216 | }; 217 | 218 | 219 | template class _UCXXEXPORT __istream_readin{ 220 | public: 221 | inline static void readin(basic_istream& stream, long int & var) 222 | { 223 | basic_string temp; 224 | 225 | if(stream.flags() & ios_base::dec){ 226 | temp = _readTokenDecimal( stream); 227 | sscanf(temp.c_str(), "%ld", &var ); 228 | }else{ 229 | temp = _readToken( stream); 230 | if( stream.flags() & ios_base::oct){ 231 | sscanf(temp.c_str(), "%lo", (unsigned long int *)(&var) ); 232 | }else if(stream.flags() & ios_base::hex){ 233 | if(stream.flags() & ios_base::uppercase){ 234 | sscanf(temp.c_str(), "%lX", (unsigned long int *)(&var) ); 235 | }else{ 236 | sscanf(temp.c_str(), "%lx", (unsigned long int *)(&var) ); 237 | } 238 | }else{ 239 | sscanf(temp.c_str(), "%li", (long int *)(&var) ); 240 | } 241 | } 242 | 243 | } 244 | }; 245 | 246 | 247 | template class _UCXXEXPORT __istream_readin{ 248 | public: 249 | inline static void readin(basic_istream& stream, unsigned long int & var) 250 | { 251 | basic_string temp; 252 | 253 | if(stream.flags() & ios_base::dec){ 254 | temp = _readTokenDecimal( stream); 255 | sscanf(temp.c_str(), "%lu", &var ); 256 | }else{ 257 | temp = _readToken( stream); 258 | if( stream.flags() & ios_base::oct){ 259 | sscanf(temp.c_str(), "%lo", &var ); 260 | }else if(stream.flags() & ios_base::hex){ 261 | if(stream.flags() & ios_base::uppercase){ 262 | sscanf(temp.c_str(), "%lX", &var ); 263 | }else{ 264 | sscanf(temp.c_str(), "%lx", &var); 265 | } 266 | }else{ 267 | sscanf(temp.c_str(), "%li", (long int *)(&var) ); 268 | } 269 | } 270 | } 271 | }; 272 | 273 | 274 | #ifdef __UCLIBCXX_HAS_FLOATS__ 275 | 276 | template class _UCXXEXPORT __istream_readin{ 277 | public: 278 | inline static void readin(basic_istream& stream, float & var) 279 | { 280 | basic_string temp; 281 | temp = _readTokenDecimal( stream); 282 | 283 | sscanf(temp.c_str(), "%g", &var); 284 | } 285 | }; 286 | 287 | template class _UCXXEXPORT __istream_readin{ 288 | public: 289 | inline static void readin(basic_istream& stream, double & var) 290 | { 291 | basic_string temp; 292 | temp = _readTokenDecimal( stream); 293 | sscanf(temp.c_str(), "%lg", &var); 294 | } 295 | }; 296 | 297 | template class _UCXXEXPORT __istream_readin{ 298 | public: 299 | inline static void readin(basic_istream& stream, long double & var) 300 | { 301 | basic_string temp; 302 | temp = _readTokenDecimal( stream); 303 | sscanf(temp.c_str(), "%Lg", &var); 304 | } 305 | }; 306 | 307 | #endif // ifdef __UCLIBCXX_HAS_FLOATS__ 308 | 309 | template class _UCXXEXPORT __istream_readin{ 310 | public: 311 | inline static void readin(basic_istream& stream, void* & var) 312 | { 313 | basic_string temp; 314 | temp = _readToken( stream); 315 | sscanf(temp.c_str(), "%p", &var); 316 | } 317 | }; 318 | 319 | 320 | template void __skipws(basic_istream& is){ 321 | const typename basic_istream::int_type eof = traits::eof(); 322 | typename basic_istream::int_type c; 323 | //While the next character normally read doesn't equal eof 324 | //and that character is a space, advance to the next read position 325 | //Thus itterating through all whitespace until we get to the meaty stuff 326 | while ( 327 | !traits::eq_int_type((c = is.rdbuf()->sgetc()), eof) 328 | && isspace(c) 329 | ) 330 | { 331 | is.rdbuf()->sbumpc(); 332 | } 333 | if(traits::eq_int_type(c, eof)){ 334 | is.setstate(ios_base::eofbit); 335 | } 336 | } 337 | } 338 | 339 | #pragma GCC visibility pop 340 | 341 | #endif 342 | 343 | 344 | 345 | -------------------------------------------------------------------------------- /include/stl_multimap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1994 4 | * Hewlett-Packard Company 5 | * 6 | * Permission to use, copy, modify, distribute and sell this software 7 | * and its documentation for any purpose is hereby granted without fee, 8 | * provided that the above copyright notice appear in all copies and 9 | * that both that copyright notice and this permission notice appear 10 | * in supporting documentation. Hewlett-Packard Company makes no 11 | * representations about the suitability of this software for any 12 | * purpose. It is provided "as is" without express or implied warranty. 13 | * 14 | * 15 | * Copyright (c) 1996,1997 16 | * Silicon Graphics Computer Systems, Inc. 17 | * 18 | * Permission to use, copy, modify, distribute and sell this software 19 | * and its documentation for any purpose is hereby granted without fee, 20 | * provided that the above copyright notice appear in all copies and 21 | * that both that copyright notice and this permission notice appear 22 | * in supporting documentation. Silicon Graphics makes no 23 | * representations about the suitability of this software for any 24 | * purpose. It is provided "as is" without express or implied warranty. 25 | */ 26 | 27 | /* NOTE: This is an internal header file, included by other STL headers. 28 | * You should not attempt to use it directly. 29 | */ 30 | 31 | #ifndef __SGI_STL_INTERNAL_MULTIMAP_H 32 | #define __SGI_STL_INTERNAL_MULTIMAP_H 33 | 34 | #include 35 | 36 | __STL_BEGIN_NAMESPACE 37 | 38 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 39 | #pragma set woff 1174 40 | #pragma set woff 1375 41 | #endif 42 | 43 | // Forward declaration of operators < and ==, needed for friend declaration. 44 | 45 | template ), 47 | class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) > 48 | class multimap; 49 | 50 | template 51 | inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 52 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y); 53 | 54 | template 55 | inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 56 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y); 57 | 58 | template 59 | class multimap { 60 | // requirements: 61 | 62 | __STL_CLASS_REQUIRES(_Tp, _Assignable); 63 | __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key); 64 | 65 | public: 66 | 67 | // typedefs: 68 | 69 | typedef _Key key_type; 70 | typedef _Tp data_type; 71 | typedef _Tp mapped_type; 72 | typedef pair value_type; 73 | typedef _Compare key_compare; 74 | 75 | class value_compare : public binary_function { 76 | friend class multimap<_Key,_Tp,_Compare,_Alloc>; 77 | protected: 78 | _Compare comp; 79 | value_compare(_Compare __c) : comp(__c) {} 80 | public: 81 | bool operator()(const value_type& __x, const value_type& __y) const { 82 | return comp(__x.first, __y.first); 83 | } 84 | }; 85 | 86 | private: 87 | typedef _Rb_tree, key_compare, _Alloc> _Rep_type; 89 | _Rep_type _M_t; // red-black tree representing multimap 90 | public: 91 | typedef typename _Rep_type::pointer pointer; 92 | typedef typename _Rep_type::const_pointer const_pointer; 93 | typedef typename _Rep_type::reference reference; 94 | typedef typename _Rep_type::const_reference const_reference; 95 | typedef typename _Rep_type::iterator iterator; 96 | typedef typename _Rep_type::const_iterator const_iterator; 97 | typedef typename _Rep_type::reverse_iterator reverse_iterator; 98 | typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; 99 | typedef typename _Rep_type::size_type size_type; 100 | typedef typename _Rep_type::difference_type difference_type; 101 | typedef typename _Rep_type::allocator_type allocator_type; 102 | 103 | // allocation/deallocation 104 | 105 | multimap() : _M_t(_Compare(), allocator_type()) { } 106 | explicit multimap(const _Compare& __comp, 107 | const allocator_type& __a = allocator_type()) 108 | : _M_t(__comp, __a) { } 109 | 110 | #ifdef __STL_MEMBER_TEMPLATES 111 | template 112 | multimap(_InputIterator __first, _InputIterator __last) 113 | : _M_t(_Compare(), allocator_type()) 114 | { _M_t.insert_equal(__first, __last); } 115 | 116 | template 117 | multimap(_InputIterator __first, _InputIterator __last, 118 | const _Compare& __comp, 119 | const allocator_type& __a = allocator_type()) 120 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 121 | #else 122 | multimap(const value_type* __first, const value_type* __last) 123 | : _M_t(_Compare(), allocator_type()) 124 | { _M_t.insert_equal(__first, __last); } 125 | multimap(const value_type* __first, const value_type* __last, 126 | const _Compare& __comp, 127 | const allocator_type& __a = allocator_type()) 128 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 129 | 130 | multimap(const_iterator __first, const_iterator __last) 131 | : _M_t(_Compare(), allocator_type()) 132 | { _M_t.insert_equal(__first, __last); } 133 | multimap(const_iterator __first, const_iterator __last, 134 | const _Compare& __comp, 135 | const allocator_type& __a = allocator_type()) 136 | : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 137 | #endif /* __STL_MEMBER_TEMPLATES */ 138 | 139 | multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { } 140 | multimap<_Key,_Tp,_Compare,_Alloc>& 141 | operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) { 142 | _M_t = __x._M_t; 143 | return *this; 144 | } 145 | 146 | // accessors: 147 | 148 | key_compare key_comp() const { return _M_t.key_comp(); } 149 | value_compare value_comp() const { return value_compare(_M_t.key_comp()); } 150 | allocator_type get_allocator() const { return _M_t.get_allocator(); } 151 | 152 | iterator begin() { return _M_t.begin(); } 153 | const_iterator begin() const { return _M_t.begin(); } 154 | iterator end() { return _M_t.end(); } 155 | const_iterator end() const { return _M_t.end(); } 156 | reverse_iterator rbegin() { return _M_t.rbegin(); } 157 | const_reverse_iterator rbegin() const { return _M_t.rbegin(); } 158 | reverse_iterator rend() { return _M_t.rend(); } 159 | const_reverse_iterator rend() const { return _M_t.rend(); } 160 | bool empty() const { return _M_t.empty(); } 161 | size_type size() const { return _M_t.size(); } 162 | size_type max_size() const { return _M_t.max_size(); } 163 | void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); } 164 | 165 | // insert/erase 166 | 167 | iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); } 168 | iterator insert(iterator __position, const value_type& __x) { 169 | return _M_t.insert_equal(__position, __x); 170 | } 171 | #ifdef __STL_MEMBER_TEMPLATES 172 | template 173 | void insert(_InputIterator __first, _InputIterator __last) { 174 | _M_t.insert_equal(__first, __last); 175 | } 176 | #else 177 | void insert(const value_type* __first, const value_type* __last) { 178 | _M_t.insert_equal(__first, __last); 179 | } 180 | void insert(const_iterator __first, const_iterator __last) { 181 | _M_t.insert_equal(__first, __last); 182 | } 183 | #endif /* __STL_MEMBER_TEMPLATES */ 184 | void erase(iterator __position) { _M_t.erase(__position); } 185 | size_type erase(const key_type& __x) { return _M_t.erase(__x); } 186 | void erase(iterator __first, iterator __last) 187 | { _M_t.erase(__first, __last); } 188 | void clear() { _M_t.clear(); } 189 | 190 | // multimap operations: 191 | 192 | iterator find(const key_type& __x) { return _M_t.find(__x); } 193 | const_iterator find(const key_type& __x) const { return _M_t.find(__x); } 194 | size_type count(const key_type& __x) const { return _M_t.count(__x); } 195 | iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); } 196 | const_iterator lower_bound(const key_type& __x) const { 197 | return _M_t.lower_bound(__x); 198 | } 199 | iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); } 200 | const_iterator upper_bound(const key_type& __x) const { 201 | return _M_t.upper_bound(__x); 202 | } 203 | pair equal_range(const key_type& __x) { 204 | return _M_t.equal_range(__x); 205 | } 206 | pair equal_range(const key_type& __x) const { 207 | return _M_t.equal_range(__x); 208 | } 209 | 210 | #ifdef __STL_TEMPLATE_FRIENDS 211 | template 212 | friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&, 213 | const multimap<_K1, _T1, _C1, _A1>&); 214 | template 215 | friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&, 216 | const multimap<_K1, _T1, _C1, _A1>&); 217 | #else /* __STL_TEMPLATE_FRIENDS */ 218 | friend bool __STD_QUALIFIER 219 | operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); 220 | friend bool __STD_QUALIFIER 221 | operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&); 222 | #endif /* __STL_TEMPLATE_FRIENDS */ 223 | }; 224 | 225 | template 226 | inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 227 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 228 | return __x._M_t == __y._M_t; 229 | } 230 | 231 | template 232 | inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 233 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 234 | return __x._M_t < __y._M_t; 235 | } 236 | 237 | #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER 238 | 239 | template 240 | inline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 241 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 242 | return !(__x == __y); 243 | } 244 | 245 | template 246 | inline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 247 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 248 | return __y < __x; 249 | } 250 | 251 | template 252 | inline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 253 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 254 | return !(__y < __x); 255 | } 256 | 257 | template 258 | inline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x, 259 | const multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 260 | return !(__x < __y); 261 | } 262 | 263 | template 264 | inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x, 265 | multimap<_Key,_Tp,_Compare,_Alloc>& __y) { 266 | __x.swap(__y); 267 | } 268 | 269 | #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ 270 | 271 | #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32) 272 | #pragma reset woff 1174 273 | #pragma reset woff 1375 274 | #endif 275 | 276 | __STL_END_NAMESPACE 277 | 278 | #endif /* __SGI_STL_INTERNAL_MULTIMAP_H */ 279 | 280 | // Local Variables: 281 | // mode:C++ 282 | // End: 283 | --------------------------------------------------------------------------------