diff options
author | Susheel Yadagiri <syadagir@codeaurora.org> | 2010-08-06 18:45:20 -0700 |
---|---|---|
committer | Susheel Yadagiri <syadagir@codeaurora.org> | 2010-08-06 18:45:20 -0700 |
commit | 6e17133a1f068cce3d21240df1e7d7b67a302633 (patch) | |
tree | 21037565dfc4f280662393d466d254b131e31d07 | |
parent | 887f8a5551856214d78af965433dd8a635977b7d (diff) | |
download | android_external_connectivity-6e17133a1f068cce3d21240df1e7d7b67a302633.tar.gz android_external_connectivity-6e17133a1f068cce3d21240df1e7d7b67a302633.tar.bz2 android_external_connectivity-6e17133a1f068cce3d21240df1e7d7b67a302633.zip |
connectivity: Add stlport for connectivity project.
Change-Id: I64e9744d797261e473e5900cda444d2c0f53727f
76 files changed, 16543 insertions, 18 deletions
diff --git a/cnd/src/Android.mk b/cnd/src/Android.mk index c4f5517..5d12680 100644 --- a/cnd/src/Android.mk +++ b/cnd/src/Android.mk @@ -3,10 +3,6 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -include external/stlport/libstlport.mk - -#this is needed to make sure that the path for stlport is specified before stdc++ -LOCAL_NO_DEFAULT_COMPILER_FLAGS :=true LOCAL_SRC_FILES:= \ cnd.c \ @@ -20,24 +16,15 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ libhardware_legacy \ - libstlport LOCAL_C_INCLUDES := \ external/connectivity/cnd/inc \ - external/connectivity/include/cne \ - external/stlport/stlport \ - system/core/include \ - frameworks/base/include \ - bionic \ - bionic/libc/arch-arm/include \ - bionic/libc/include \ - bionic/libstdc++/include \ - bionic/libc/kernel/common \ - bionic/libc/kernel/arch-arm \ - bionic/libm/include - + external/connectivity/include/cne +LOCAL_CFLAGS := -UNDEBUG -DDEBUG -LOCAL_CFLAGS+= -fno-exceptions -fno-short-enums -include system/core/include/arch/linux-arm/AndroidConfig.h -DANDROID +include external/connectivity/stlport/libstlport.mk include $(BUILD_EXECUTABLE) + +# vim: et diff --git a/stlport/README b/stlport/README new file mode 100644 index 0000000..a759495 --- /dev/null +++ b/stlport/README @@ -0,0 +1,64 @@ +********************************************************************** +* README file for STLport 5.0 * +* * +********************************************************************** + +This directory contains the STLport-5.0 release. + +What's inside : + +README - this file +INSTALL - installation instructions + +bin - installation directory for STLport unit tests; + it may contain more subdirs, if you use + crosscompilation +build/lib - build directory for STLport library (if you use + STLport iostreams and/or locale only) +build/test/unit - build directory for regression (unit) tests +build/test/eh - build directory for exception handling tests +stlport - main STLport include directory +src - source for iostreams implementation and other parts + that aren't pure template code +lib - installation directory for STLport library (if you + use STLport iostreams and/or locale only); + it may contain more subdirs, if you use + crosscompilation +test/unit - unit (regression) tests +test/eh - exception handling test using STLport iostreams +etc - miscellanous files (ChangeLog, TODO, scripts, etc.) + +GETTING STLPORT + +To download the latest version of STLport, please be sure to visit +https://sourceforge.net/project/showfiles.php?group_id=146814 + +LEGALESE + +This software is being distributed under the following terms: + + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999-2003 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + +********************************************************************** diff --git a/stlport/libstlport.mk b/stlport/libstlport.mk new file mode 100644 index 0000000..8321d4a --- /dev/null +++ b/stlport/libstlport.mk @@ -0,0 +1,12 @@ +# Add a couple include paths to use stlport. + +# Only use this on the device or emulator. +ifeq ($(TARGET_SIMULATOR),true) +$(error STLPort not suitable for the simulator! $(LOCAL_PATH)) +endif + +# Make sure bionic is first so we can include system headers. +LOCAL_C_INCLUDES := \ + bionic \ + external/connectivity/stlport/stlport \ + $(LOCAL_C_INCLUDES) diff --git a/stlport/stlport/assert.h b/stlport/stlport/assert.h new file mode 100644 index 0000000..112dd26 --- /dev/null +++ b/stlport/stlport/assert.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x202 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x202) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +/* evc3 doesn't have assert.h; macro assert() is defined in stl_evc.h */ +#ifndef _STLP_WCE_EVC3 +# if !defined (assert) +# define _STLP_NATIVE_ASSERT_H_INCLUDED +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <assert.h> +# else +# include _STLP_NATIVE_C_HEADER(assert.h) +# endif +# endif +# if !defined (_STLP_NATIVE_ASSERT_H_INCLUDED) +/* See errno.h for additional information about this #error */ +# error assert has been defined before inclusion of assert.h header. +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x202) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + +/* Local Variables: + * mode:C++ + * End: + */ diff --git a/stlport/stlport/climits b/stlport/stlport/climits new file mode 100644 index 0000000..86bc413 --- /dev/null +++ b/stlport/stlport/climits @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CLIMITS +# define _STLP_CLIMITS + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x108 +# include <stl/_prolog.h> +#endif + +#if defined (__SUNPRO_CC) && ((__SUNPRO_CC == 0x500) && (__SUNPRO_CC_COMPAT > 4)) +# include </usr/include/limits.h> +#elif defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <climits> +# else +# include _STLP_NATIVE_CPP_C_HEADER(climits) +# endif +#else +# if defined (__BORLANDC__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <limits.h> +# else +# include _STLP_NATIVE_C_HEADER(limits.h) +# endif +# else +# include <limits.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x108 ) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CLIMITS */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/cstdarg b/stlport/stlport/cstdarg new file mode 100644 index 0000000..6882bbd --- /dev/null +++ b/stlport/stlport/cstdarg @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDARG + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x113 +# define _STLP_CSTDARG +# include <stl/_prolog.h> +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x113) +# ifndef _STLP_INTERNAL_CSTDARG +# include <stl/_cstdarg.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x113) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstdarg> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdarg) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x113 ) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTDARG */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/cstddef b/stlport/stlport/cstddef new file mode 100644 index 0000000..0a66f0e --- /dev/null +++ b/stlport/stlport/cstddef @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CSTDDEF + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x114 +# define _STLP_CSTDDEF +# include <stl/_prolog.h> +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x114) +# ifndef _STLP_INTERNAL_CSTDDEF +# include <stl/_cstddef.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x114) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstddef> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstddef) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x114 ) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_CSTDDEF */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/ctype.h b/stlport/stlport/ctype.h new file mode 100644 index 0000000..f9d1000 --- /dev/null +++ b/stlport/stlport/ctype.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_CTYPE_H + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include ctype.h, which results in warnings and errors + */ +#if !defined(RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x219 +# include <stl/_prolog.h> +# elif (_STLP_OUTERMOST_HEADER_ID == 0x219) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_CTYPE_H +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <ctype.h> +# else +# include _STLP_NATIVE_C_HEADER(ctype.h) +# endif + +/* on evc4 including ctype.h also defines setjmp macro */ +# if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +# ifndef _STLP_CTYPE_H_SEEN +# define _STLP_CTYPE_H_SEEN + +/* Undef convenience interfaces */ +# undef isspace +# undef isprint +# undef iscntrl +# undef isupper +# undef islower +# undef isalpha +# undef isdigit +# undef ispunct +# undef isxdigit +# undef isalnum +# undef isgraph +# undef toupper +# undef tolower + +# if defined (UNDER_CE) + +# if (_WIN32_WCE < 300) /* Only wide chars for older versions */ +# define _isctype iswctype +# endif + +__inline int (isalpha)(int c) { return _isctype(c, _ALPHA); } +__inline int (isupper)(int c) { return _isctype(c, _UPPER); } +__inline int (islower)(int c) { return _isctype(c, _LOWER); } +__inline int (isdigit)(int c) { return _isctype(c, _DIGIT); } +__inline int (isxdigit)(int c) { return _isctype(c, _HEX); } +__inline int (isspace)(int c) { return _isctype(c, _SPACE); } +__inline int (ispunct)(int c) { return _isctype(c, _PUNCT); } +__inline int (isalnum)(int c) { return _isctype(c, _ALPHA|_DIGIT); } +__inline int (isprint)(int c) { return _isctype(c, _BLANK|_PUNCT|_ALPHA|_DIGIT); } +__inline int (isgraph)(int c) { return _isctype(c, _PUNCT|_ALPHA|_DIGIT); } +__inline int (iscntrl)(int c) { return _isctype(c, _CONTROL); } +__inline int (isascii)(int c) { return ((unsigned)(c) < 0x80); } + +# undef _isctype + +__inline int (iswalpha)(int c) { return iswctype((unsigned short)(c), _ALPHA); } +__inline int (iswupper)(int c) { return iswctype((unsigned short)(c), _UPPER); } +__inline int (iswlower)(int c) { return iswctype((unsigned short)(c), _LOWER); } +__inline int (iswdigit)(int c) { return iswctype((unsigned short)(c), _DIGIT); } +__inline int (iswxdigit)(int c) { return iswctype((unsigned short)(c), _HEX); } +__inline int (iswspace)(int c) { return iswctype((unsigned short)(c), _SPACE); } +__inline int (iswpunct)(int c) { return iswctype((unsigned short)(c), _PUNCT); } +__inline int (iswalnum)(int c) { return iswctype((unsigned short)(c), _ALPHA|_DIGIT); } +__inline int (iswprint)(int c) { return iswctype((unsigned short)(c), _BLANK|_PUNCT|_ALPHA|_DIGIT); } +__inline int (iswgraph)(int c) { return iswctype((unsigned short)(c), _PUNCT|_ALPHA|_DIGIT); } +__inline int (iswcntrl)(int c) { return iswctype((unsigned short)(c), _CONTROL); } +__inline int (iswascii)(int c) { return ((unsigned)(c) < 0x80); } + +# endif /* UNDER_CE */ + +# endif /* _STLP_CTYPE_H_SEEN */ + +# if (_STLP_OUTERMOST_HEADER_ID == 0x219) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ + +#endif /* _STLP_CTYPE_H */ diff --git a/stlport/stlport/errno.h b/stlport/stlport/errno.h new file mode 100644 index 0000000..bb7999b --- /dev/null +++ b/stlport/stlport/errno.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x205 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x205) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#ifdef _STLP_WCE +/* only show message when directly including this file in a non-library build */ +# if !defined(__BUILDING_STLPORT) && (_STLP_OUTERMOST_HEADER_ID == 0x205) +# pragma message("eMbedded Visual C++ 3 and .NET don't have a errno.h header; STLport won't include native errno.h here") +# endif +#else +# ifndef errno +/* We define the following macro first to guaranty the header reentrancy: */ +# define _STLP_NATIVE_ERRNO_H_INCLUDED +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <errno.h> +# else +# include _STLP_NATIVE_C_HEADER(errno.h) +# endif +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x590) && defined (__cplusplus) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::__errno; +_STLP_END_NAMESPACE +# endif +# endif /* errno */ + +# if !defined (_STLP_NATIVE_ERRNO_H_INCLUDED) +/* If errno has been defined before inclusion of native errno.h including it from STLport errno.h + * becomes impossible because if: + * #define errno foo + * then + * #include _STLP_NATIVE_C_HEADER(errno.h) + * becomes: + * #include _STLP_NATIVE_C_HEADER(foo.h) + * + * To fix this problem you have to find where this definition comes from and include errno.h before it. + */ +# error errno has been defined before inclusion of errno.h header. +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x205) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + +/* Local Variables: + * mode: C + * End: + */ diff --git a/stlport/stlport/iterator b/stlport/stlport/iterator new file mode 100644 index 0000000..f8d3dee --- /dev/null +++ b/stlport/stlport/iterator @@ -0,0 +1,61 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_ITERATOR + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x38 +# include <stl/_prolog.h> +# define _STLP_ITERATOR +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x38) +# ifndef _STLP_INTERNAL_ITERATOR_H +# include <stl/_iterator.h> +# endif + +# ifndef _STLP_INTERNAL_STREAM_ITERATOR_H +# include <stl/_stream_iterator.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x38) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <iterator> +# else +# include _STLP_NATIVE_HEADER(iterator) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x38) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_ITERATOR */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/limits.h b/stlport/stlport/limits.h new file mode 100644 index 0000000..aab553b --- /dev/null +++ b/stlport/stlport/limits.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x201 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x201) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if defined(_STLP_WCE_EVC3) +struct _exception; +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <limits.h> +#else +# include _STLP_NATIVE_C_HEADER(limits.h) +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x201) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif diff --git a/stlport/stlport/list b/stlport/stlport/list new file mode 100644 index 0000000..647a8be --- /dev/null +++ b/stlport/stlport/list @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_LIST + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x40 +# include <stl/_prolog.h> +# define _STLP_LIST +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x40) +# ifndef _STLP_INTERNAL_LIST_H +# include <stl/_list.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x40) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <list> +# else +# include _STLP_NATIVE_HEADER(list) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x40) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_LIST */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/map b/stlport/stlport/map new file mode 100644 index 0000000..f30c400 --- /dev/null +++ b/stlport/stlport/map @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_MAP + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x43 +# include <stl/_prolog.h> +# define _STLP_MAP +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x43) +# ifndef _STLP_INTERNAL_MAP_H +# include <stl/_map.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x43) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <map> +# else +# include _STLP_NATIVE_HEADER(map) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x43) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_MAP */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/math.h b/stlport/stlport/math.h new file mode 100644 index 0000000..32b666f --- /dev/null +++ b/stlport/stlport/math.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x244 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x244) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if !defined (exception) && (!defined (__KCC) || (__KCC_VERSION < 4000)) && \ + !(defined(__IBMCPP__) && (500 <= __IBMCPP__)) && !defined(_STLP_WCE_EVC3) +# define _STLP_EXCEPTION_WAS_REDEFINED 1 +# define exception __math_exception +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <math.h> +#else +# include _STLP_NATIVE_C_HEADER(math.h) +#endif + +#if defined (_STLP_EXCEPTION_WAS_REDEFINED) +# undef exception +# undef _STLP_EXCEPTION_WAS_REDEFINED +#endif + +#ifdef _STLP_WCE_EVC3 +# undef _exception +# define _exception exception +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x244) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + diff --git a/stlport/stlport/new b/stlport/stlport/new new file mode 100644 index 0000000..974ca44 --- /dev/null +++ b/stlport/stlport/new @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_NEW_HEADER + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x447 +# define _STLP_NEW_HEADER +# include <stl/_prolog.h> +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x447) +# ifndef _STLP_NEW_H_HEADER +# include <stl/_new.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x447) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <new> +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x447) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_NEW */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/pthread.h b/stlport/stlport/pthread.h new file mode 100644 index 0000000..4f0d90c --- /dev/null +++ b/stlport/stlport/pthread.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x280 +# include <stl/_prolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x280) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if defined (__SUNPRO_CC) || defined (__HP_aCC) +# include "/usr/include/pthread.h" +#else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <pthread.h> +# else +# include _STLP_NATIVE_C_HEADER(pthread.h) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x280) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif + +/* + Local Variables: + mode:C++ + End: +*/ diff --git a/stlport/stlport/set b/stlport/stlport/set new file mode 100644 index 0000000..ed79d89 --- /dev/null +++ b/stlport/stlport/set @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_SET + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x55 +# include <stl/_prolog.h> +# define _STLP_SET +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x55) +# ifndef _STLP_INTERNAL_SET_H +# include <stl/_set.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x55) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <set> +# else +# include _STLP_NATIVE_HEADER(set) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x55) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_SET */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/signal.h b/stlport/stlport/signal.h new file mode 100644 index 0000000..27f91be --- /dev/null +++ b/stlport/stlport/signal.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x257 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x257) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +/* evc3 and evc4 don't have signal.h */ +#ifndef _STLP_WCE +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <signal.h> +# else +# include _STLP_NATIVE_C_HEADER(signal.h) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x257) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# endif +# undef _STLP_DONT_POP_HEADER_ID +#endif + diff --git a/stlport/stlport/stdarg.h b/stlport/stlport/stdarg.h new file mode 100644 index 0000000..368e672 --- /dev/null +++ b/stlport/stlport/stdarg.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdarg.h, which results in warnings and errors + */ +#if !defined (RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x261 +# include <stl/_cprolog.h> +# elif (_STLP_OUTERMOST_HEADER_ID == 0x261) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <stdarg.h> +# else +# include _STLP_NATIVE_C_HEADER(stdarg.h) +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x261) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif +#endif /* RC_INVOKED */ diff --git a/stlport/stlport/stddef.h b/stlport/stlport/stddef.h new file mode 100644 index 0000000..f959c23 --- /dev/null +++ b/stlport/stlport/stddef.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x262 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x262) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#if defined (_MSC_VER) || defined (__DMC__) +/* Native stddef.h contains errno macro definition making inclusion of native + * errno.h in STLport errno.h impossible. We are then forced to include errno.h + * first. + */ +# include "errno.h" +#endif + +#if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <stddef.h> +#else +# include _STLP_NATIVE_C_HEADER(stddef.h) +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x262) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif diff --git a/stlport/stlport/stdio.h b/stlport/stlport/stdio.h new file mode 100644 index 0000000..e2dbdea --- /dev/null +++ b/stlport/stlport/stdio.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdarg.h, which results in warnings and errors + */ +#if !defined(RC_INVOKED) + +# ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x264 +# include <stl/_cprolog.h> +# elif (_STLP_OUTERMOST_HEADER_ID == 0x264) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <stdio.h> +# else +# include _STLP_NATIVE_C_HEADER(stdio.h) +# endif + +# if defined (__SUNPRO_CC) && !defined (_STRUCT_FILE) +# define _STRUCT_FILE +# endif + +# if defined (__BORLANDC__) && defined (__cplusplus) && !defined (__linux__) +_STLP_BEGIN_NAMESPACE +using __std_alias::_streams; +_STLP_END_NAMESPACE +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x264) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ diff --git a/stlport/stlport/stdlib.h b/stlport/stlport/stdlib.h new file mode 100644 index 0000000..fd55f8a --- /dev/null +++ b/stlport/stlport/stdlib.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include stdlib.h, which results in warnings and errors + */ +#if !defined (RC_INVOKED) + +# if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x265 +# include <stl/_cprolog.h> +# elif (_STLP_OUTERMOST_HEADER_ID == 0x265) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# endif + +# if defined (_STLP_MSVC_LIB) || (defined (__GNUC__) && defined (__MINGW32__)) || \ + defined (__BORLANDC__) || defined (__DMC__) || \ + (defined (__HP_aCC) && defined (_REENTRANT)) +/* Native stdlib.h contains errno macro definition making inclusion of native + * errno.h in STLport errno.h impossible. We are then forced to include errno.h + * first. + */ +# include "errno.h" +# endif + +/* + forward-declaration for _exception struct; prevents warning message + ../include/stdlib.h(817) : warning C4115: '_exception' : named type definition in parentheses +*/ +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <stdlib.h> +# else +# include _STLP_NATIVE_C_HEADER(stdlib.h) +# endif + +/* on evc3/evc4 including stdlib.h also defines setjmp macro */ +# if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x265) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif + +#endif /* RC_INVOKED */ diff --git a/stlport/stlport/stl/_algobase.c b/stlport/stlport/stl/_algobase.c new file mode 100644 index 0000000..157e25c --- /dev/null +++ b/stlport/stlport/stl/_algobase.c @@ -0,0 +1,483 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_ALGOBASE_C +#define _STLP_ALGOBASE_C + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include <stl/_function_base.h> +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _InputIter1, class _InputIter2> +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + for ( ; __first1 != __last1 && __first2 != __last2 + ; ++__first1, ++__first2) { + if (*__first1 < *__first2) { + _STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return true; + } + if (*__first2 < *__first1) + return false; + } + return __first1 == __last1 && __first2 != __last2; +} + +template <class _InputIter1, class _InputIter2, class _Compare> +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _Compare __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + for ( ; __first1 != __last1 && __first2 != __last2 + ; ++__first1, ++__first2) { + if (__comp(*__first1, *__first2)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first2, *__first1), + _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return true; + } + if (__comp(*__first2, *__first1)) + return false; + } + return __first1 == __last1 && __first2 != __last2; +} + +#if !defined (_STLP_NO_EXTENSIONS) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter1, class _InputIter2> +int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + while (__first1 != __last1 && __first2 != __last2) { + if (*__first1 < *__first2) { + _STLP_VERBOSE_ASSERT(!(*__first2 < *__first1), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + return -1; + } + if (*__first2 < *__first1) + return 1; + ++__first1; + ++__first2; + } + if (__first2 == __last2) { + return !(__first1 == __last1); + } + else { + return -1; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter1, class _InputIter2> +int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __lexicographical_compare_3way(__first1, __last1, __first2, __last2); +} +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _RandomAccessIter, class _Tp> +_STLP_INLINE_LOOP _RandomAccessIter __find(_RandomAccessIter __first, _RandomAccessIter __last, + const _Tp& __val, + const random_access_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2; + + for ( ; __trip_count > 0 ; --__trip_count) { + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + + if (*__first == __val) return __first; + ++__first; + } + + switch (__last - __first) { + case 3: + if (*__first == __val) return __first; + ++__first; + case 2: + if (*__first == __val) return __first; + ++__first; + case 1: + if (*__first == __val) return __first; + //++__first; + case 0: + default: + return __last; + } +} + +inline char* +__find(char* __first, char* __last, char __val, const random_access_iterator_tag &) { + void *res = memchr(__first, __val, __last - __first); + return res != 0 ? __STATIC_CAST(char*, res) : __last; +} +inline const char* +__find(const char* __first, const char* __last, char __val, const random_access_iterator_tag &) { + const void *res = memchr(__first, __val, __last - __first); + return res != 0 ? __STATIC_CAST(const char*, res) : __last; +} + +template <class _RandomAccessIter, class _Predicate> +_STLP_INLINE_LOOP _RandomAccessIter __find_if(_RandomAccessIter __first, _RandomAccessIter __last, + _Predicate __pred, + const random_access_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_RandomAccessIter) __trip_count = (__last - __first) >> 2; + + for ( ; __trip_count > 0 ; --__trip_count) { + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + + if (__pred(*__first)) return __first; + ++__first; + } + + switch(__last - __first) { + case 3: + if (__pred(*__first)) return __first; + ++__first; + case 2: + if (__pred(*__first)) return __first; + ++__first; + case 1: + if (__pred(*__first)) return __first; + //++__first; + case 0: + default: + return __last; + } +} + +template <class _InputIter, class _Tp> +_STLP_INLINE_LOOP _InputIter __find(_InputIter __first, _InputIter __last, + const _Tp& __val, + const input_iterator_tag &) { + while (__first != __last && !(*__first == __val)) ++__first; + return __first; +} + +template <class _InputIter, class _Predicate> +_STLP_INLINE_LOOP _InputIter __find_if(_InputIter __first, _InputIter __last, + _Predicate __pred, + const input_iterator_tag &) { + while (__first != __last && !__pred(*__first)) + ++__first; + return __first; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _Predicate> +_InputIter find_if(_InputIter __first, _InputIter __last, + _Predicate __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __find_if(__first, __last, __pred, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} + +template <class _InputIter, class _Tp> +_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __find(__first, __last, __val, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} + +template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred> +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPred __pred) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + // Test for empty ranges + if (__first1 == __last1 || __first2 == __last2) + return __first1; + + // Test for a pattern of length 1. + _ForwardIter2 __p1(__first2); + + if ( ++__p1 == __last2 ) { + while (__first1 != __last1 && !__pred(*__first1, *__first2)) { + ++__first1; + } + return __first1; + } + + // General case. + + for ( ; ; ) { // __first1 != __last1 will be checked below + while (__first1 != __last1 && !__pred(*__first1, *__first2)) { + ++__first1; + } + if (__first1 == __last1) { + return __last1; + } + _ForwardIter2 __p = __p1; + _ForwardIter1 __current = __first1; + if (++__current == __last1) return __last1; + + while (__pred(*__current, *__p)) { + if (++__p == __last2) + return __first1; + if (++__current == __last1) + return __last1; + } + ++__first1; + } + return __first1; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE +template <class _Tp> +struct _IsCharLikeType +{ typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsCharLikeType<char> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsCharLikeType<unsigned char> +{ typedef __true_type _Ret; }; + +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_TEMPLATE_NULL struct _IsCharLikeType<signed char> +{ typedef __true_type _Ret; }; +# endif + +template <class _Tp1, class _Tp2> +inline bool __stlp_eq(_Tp1 __val1, _Tp2 __val2) +{ return __val1 == __val2; } + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template <class _Tp> +inline bool __stlp_eq(_Tp, _Tp) +{ return true; } +#endif + +template <class _InputIter, class _ForwardIter, class _Tp2, class _Predicate> +inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp2*, _Predicate __pred, + const __true_type& /* _UseStrcspnLikeAlgo */) { + unsigned char __hints[(UCHAR_MAX + 1) / CHAR_BIT]; + memset(__hints, 0, sizeof(__hints) / sizeof(unsigned char)); + for (; __first2 != __last2; ++__first2) { + unsigned char __tmp = (unsigned char)*__first2; + __hints[__tmp / CHAR_BIT] |= (1 << (__tmp % CHAR_BIT)); + } + + for (; __first1 != __last1; ++__first1) { + _Tp2 __tmp = (_Tp2)*__first1; + if (__stlp_eq(*__first1, __tmp) && + __pred((__hints[(unsigned char)__tmp / CHAR_BIT] & (1 << ((unsigned char)__tmp % CHAR_BIT))) != 0)) + break; + } + return __first1; +} + +template <class _InputIter, class _ForwardIter, class _Tp2, class _Predicate> +inline _InputIter __find_first_of_aux2(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp2* /* __dummy */, _Predicate /* __pred */, + const __false_type& /* _UseStrcspnLikeAlgo */) { + return _STLP_PRIV __find_first_of(__first1, __last1, __first2, __last2, + _STLP_PRIV __equal_to(_STLP_VALUE_TYPE(__first1, _InputIter))); +} + +template <class _InputIter, class _ForwardIter, class _Tp1, class _Tp2> +inline _InputIter __find_first_of_aux1(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _Tp1* __pt1, _Tp2* __pt2) { + typedef _STLP_TYPENAME _STLP_STD::_IsIntegral<_Tp1>::_Ret _IsIntegral; + typedef _STLP_TYPENAME _STLP_PRIV _IsCharLikeType<_Tp2>::_Ret _IsCharLike; + typedef _STLP_TYPENAME _STLP_STD::_Land2<_IsIntegral, _IsCharLike>::_Ret _UseStrcspnLikeAlgo; + return _STLP_PRIV __find_first_of_aux2(__first1, __last1, + __first2, __last2, + __pt2, _Identity<bool>(), _UseStrcspnLikeAlgo()); +} + +template <class _InputIter, class _ForwardIter> +inline _InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2) { + return _STLP_PRIV __find_first_of_aux1(__first1, __last1, __first2, __last2, + _STLP_VALUE_TYPE(__first1, _InputIter), + _STLP_VALUE_TYPE(__first2, _ForwardIter)); +} + +// find_first_of, with and without an explicitly supplied comparison function. +template <class _InputIter, class _ForwardIter, class _BinaryPredicate> +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _BinaryPredicate __comp) { + for ( ; __first1 != __last1; ++__first1) { + for (_ForwardIter __iter = __first2; __iter != __last2; ++__iter) { + if (__comp(*__first1, *__iter)) { + return __first1; + } + } + } + return __last1; +} + +// find_end, with and without an explicitly supplied comparison function. +// Search [first2, last2) as a subsequence in [first1, last1), and return +// the *last* possible match. Note that find_end for bidirectional iterators +// is much faster than for forward iterators. + +// find_end for forward iterators. +template <class _ForwardIter1, class _ForwardIter2, + class _BinaryPredicate> +_ForwardIter1 __find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + const forward_iterator_tag &, const forward_iterator_tag &, + _BinaryPredicate __comp) { + if (__first2 == __last2) + return __last1; + else { + _ForwardIter1 __result = __last1; + for (;;) { + _ForwardIter1 __new_result = _STLP_STD::search(__first1, __last1, __first2, __last2, __comp); + if (__new_result == __last1) + return __result; + else { + __result = __new_result; + __first1 = __new_result; + ++__first1; + } + } + } +} + +_STLP_MOVE_TO_STD_NAMESPACE + +// find_end for bidirectional iterators. Requires partial specialization. +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + +# ifndef _STLP_INTERNAL_ITERATOR_H +_STLP_END_NAMESPACE +# include <stl/_iterator.h> +_STLP_BEGIN_NAMESPACE +# endif /*_STLP_INTERNAL_ITERATOR_H*/ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _BidirectionalIter1, class _BidirectionalIter2, + class _BinaryPredicate> +_BidirectionalIter1 +__find_end(_BidirectionalIter1 __first1, _BidirectionalIter1 __last1, + _BidirectionalIter2 __first2, _BidirectionalIter2 __last2, + const bidirectional_iterator_tag &, const bidirectional_iterator_tag &, + _BinaryPredicate __comp) { + typedef _STLP_STD::reverse_iterator<_BidirectionalIter1> _RevIter1; + typedef _STLP_STD::reverse_iterator<_BidirectionalIter2> _RevIter2; + + _RevIter1 __rlast1(__first1); + _RevIter2 __rlast2(__first2); + _RevIter1 __rresult = _STLP_STD::search(_RevIter1(__last1), __rlast1, + _RevIter2(__last2), __rlast2, + __comp); + + if (__rresult == __rlast1) + return __last1; + else { + _BidirectionalIter1 __result = __rresult.base(); + _STLP_STD::advance(__result, -_STLP_STD::distance(__first2, __last2)); + return __result; + } +} + +_STLP_MOVE_TO_STD_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +template <class _ForwardIter1, class _ForwardIter2, + class _BinaryPredicate> +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPredicate __comp) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + return _STLP_PRIV __find_end(__first1, __last1, __first2, __last2, +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + _STLP_ITERATOR_CATEGORY(__first1, _ForwardIter1), + _STLP_ITERATOR_CATEGORY(__first2, _ForwardIter2), +#else + forward_iterator_tag(), + forward_iterator_tag(), +#endif + __comp); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance> +_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + _Compare1 __comp1, _Compare2 __comp2, _Distance*) { + _Distance __len = _STLP_STD::distance(__first, __last); + _Distance __half; + _ForwardIter __middle; + + while (__len > 0) { + __half = __len >> 1; + __middle = __first; + _STLP_STD::advance(__middle, __half); + if (__comp1(*__middle, __val)) { + _STLP_VERBOSE_ASSERT(!__comp2(__val, *__middle), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_ALGOBASE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_algobase.h b/stlport/stlport/stl/_algobase.h new file mode 100644 index 0000000..597dcbe --- /dev/null +++ b/stlport/stlport/stl/_algobase.h @@ -0,0 +1,728 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ALGOBASE_H +#define _STLP_INTERNAL_ALGOBASE_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include <stl/_cstddef.h> +#endif + +#ifndef _STLP_INTERNAL_CSTRING +# include <stl/_cstring.h> +#endif + +#ifndef _STLP_CLIMITS +# include <climits> +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include <stl/_cstdlib.h> +#endif + +#ifndef _STLP_INTERNAL_PAIR_H +# include <stl/_pair.h> +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include <stl/_iterator_base.h> +#endif + +#ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +_STLP_MOVE_TO_PRIV_NAMESPACE +template <class _Tp> +inline void __swap_aux(_Tp& __a, _Tp& __b, const __true_type& /*SwapImplemented*/) { + __a._M_swap_workaround(__b); +} + +template <class _Tp> +inline void __swap_aux(_Tp& __a, _Tp& __b, const __false_type& /*SwapImplemented*/) { + _Tp __tmp = __a; + __a = __b; + __b = __tmp; +} +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +// swap and iter_swap +template <class _Tp> +inline void swap(_Tp& __a, _Tp& __b) { +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +# if !defined(__BORLANDC__) + typedef typename _SwapImplemented<_Tp>::_Ret _Implemented; +# else + enum { _Is = _SwapImplemented<_Tp>::_Is }; + typedef typename __bool2type<_Is>::_Ret _Implemented; +# endif + _STLP_PRIV __swap_aux(__a, __b, _Implemented()); +#else + _Tp __tmp = __a; + __a = __b; + __b = __tmp; +#endif +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _ForwardIter1, class _ForwardIter2, class _Value> +inline void __iter_swap_aux_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, _Value *) { + _Value tmp = *__i1; + *__i1 = *__i2; + *__i2 = tmp; +} + +template <class _ForwardIter1, class _ForwardIter2> +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __true_type& /*OKToSwap*/) { + /* namespace specification breaks access to the right swap template overload (at least for gcc) */ + /*_STLP_STD::*/ swap(*__i1, *__i2); +} + +template <class _ForwardIter1, class _ForwardIter2> +inline void __iter_swap_aux(_ForwardIter1& __i1, _ForwardIter2& __i2, const __false_type& /*OKToSwap*/) { + _STLP_PRIV __iter_swap_aux_aux( __i1, __i2, _STLP_VALUE_TYPE(__i1,_ForwardIter1) ); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _ForwardIter1, class _ForwardIter2> +inline void iter_swap(_ForwardIter1 __i1, _ForwardIter2 __i2) { + _STLP_PRIV __iter_swap_aux( __i1, __i2, _IsOKToSwap(_STLP_VALUE_TYPE(__i1, _ForwardIter1), _STLP_VALUE_TYPE(__i2, _ForwardIter2), + _STLP_IS_REF_TYPE_REAL_REF(__i1, _ForwardIter1), + _STLP_IS_REF_TYPE_REAL_REF(__i2, _ForwardIter2))._Answer()); +} + +//-------------------------------------------------- +// min and max + +#if !defined (__BORLANDC__) || defined (_STLP_USE_OWN_NAMESPACE) +# if (defined (__BORLANDC__) && (__BORLANDC__ < 0x580)) && !defined (__STDC__) +//In not ANSI mode Borland import min/max in global namespace which conflict +//with STLport min/max when user does a 'using namespace std' in its code +//(see test/unit/alg_test.cpp). To avoid this clash we simply import Borland min/max +//in STLport namespace. +using _STLP_VENDOR_STD::min; +using _STLP_VENDOR_STD::max; +# else +template <class _Tp> +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b) { return __b < __a ? __b : __a; } +template <class _Tp> +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b) { return __a < __b ? __b : __a; } +# endif +#endif + +# if defined (__BORLANDC__) && defined (_STLP_USE_OWN_NAMESPACE) +inline unsigned long (min) (unsigned long __a, unsigned long __b) { return __b < __a ? __b : __a; } +inline unsigned long (max) (unsigned long __a, unsigned long __b) { return __a < __b ? __b : __a; } +# endif + +# if !defined (__BORLANDC__) || (__BORLANDC__ < 0x590) +template <class _Tp, class _Compare> +inline const _Tp& (min)(const _Tp& __a, const _Tp& __b, _Compare __comp) { + return __comp(__b, __a) ? __b : __a; +} + +template <class _Tp, class _Compare> +inline const _Tp& (max)(const _Tp& __a, const _Tp& __b, _Compare __comp) { + return __comp(__a, __b) ? __b : __a; +} +# else +template <class _Tp, class _Compare> +inline const _Tp (min)(const _Tp __a, const _Tp __b, _Compare __comp) { + return __comp(__b, __a) ? __b : __a; +} + +template <class _Tp, class _Compare> +inline const _Tp (max)(const _Tp __a, const _Tp __b, _Compare __comp) { + return __comp(__a, __b) ? __b : __a; +} +# endif + +//-------------------------------------------------- +// copy + +// All of these auxiliary functions serve two purposes. (1) Replace +// calls to copy with memmove whenever possible. (Memmove, not memcpy, +// because the input and output ranges are permitted to overlap.) +// (2) If we're using random access iterators, then write the loop as +// a for loop with an explicit count. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const input_iterator_tag &, _Distance*) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const forward_iterator_tag &, _Distance* ) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} + +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __copy(_InputIter __first, _InputIter __last, + _OutputIter __result, const bidirectional_iterator_tag &, _Distance* ) { + for ( ; __first != __last; ++__result, ++__first) + *__result = *__first; + return __result; +} +#endif + +template <class _RandomAccessIter, class _OutputIter, class _Distance> +inline _OutputIter +__copy(_RandomAccessIter __first, _RandomAccessIter __last, + _OutputIter __result, const random_access_iterator_tag &, _Distance*) { + for (_Distance __n = __last - __first; __n > 0; --__n) { + *__result = *__first; + ++__first; + ++__result; + } + return __result; +} + +inline void* +__copy_trivial(const void* __first, const void* __last, void* __result) { + size_t __n = (const char*)__last - (const char*)__first; + return __n ? (void *)((char*)memmove(__result, __first, __n) + __n) : __result; +} + +//-------------------------------------------------- +// copy_backward auxiliary functions + +template <class _BidirectionalIter1, class _BidirectionalIter2, + class _Distance> +inline _BidirectionalIter2 __copy_backward(_BidirectionalIter1 __first, + _BidirectionalIter1 __last, + _BidirectionalIter2 __result, + const bidirectional_iterator_tag &, + _Distance*) { + while (__first != __last) + *--__result = *--__last; + return __result; +} + +template <class _RandomAccessIter, class _BidirectionalIter, class _Distance> +inline _BidirectionalIter __copy_backward(_RandomAccessIter __first, + _RandomAccessIter __last, + _BidirectionalIter __result, + const random_access_iterator_tag &, + _Distance*) { + for (_Distance __n = __last - __first; __n > 0; --__n) + *--__result = *--__last; + return __result; +} + +inline void* +__copy_trivial_backward(const void* __first, const void* __last, void* __result) { + const ptrdiff_t _Num = (const char*)__last - (const char*)__first; + return (_Num > 0) ? memmove((char*)__result - _Num, __first, _Num) : __result ; +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*IsOKToMemCpy*/) { + return _STLP_PRIV __copy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); +} +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*IsOKToMemCpy*/) { + // we know they all pointers, so this cast is OK + // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result)); + return (_OutputIter)_STLP_PRIV __copy_trivial(__first, __last, __result); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*BothPtrType*/) { + return _STLP_PRIV __copy_ptrs(__first, __last, __result, + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*BothPtrType*/) { + return _STLP_PRIV __copy(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _OutputIter> +inline _OutputIter copy(_InputIter __first, _InputIter __last, _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __copy_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer()); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, + _OutputIter __result, const __false_type& /*TrivialAssignment*/) { + return _STLP_PRIV __copy_backward(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, + _OutputIter __result, const __true_type& /*TrivialAssignment*/) { + return (_OutputIter)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type&) { + return _STLP_PRIV __copy_backward(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first,_InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __copy_backward_aux(_InputIter __first, _InputIter __last, _OutputIter __result, const __true_type&) { + return _STLP_PRIV __copy_backward_ptrs(__first, __last, __result, + _UseTrivialCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _OutputIter> +inline _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + return _STLP_PRIV __copy_backward_aux(__first, __last, __result, _BothPtrType< _InputIter, _OutputIter>::_Answer() ); +} + +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +# define _STLP_DECLARE_COPY_TRIVIAL(_Tp) \ +inline _Tp* copy(const _Tp* __first, const _Tp* __last, _Tp* __result) \ +{ return (_Tp*)_STLP_PRIV __copy_trivial(__first, __last, __result); } \ +inline _Tp* copy_backward(const _Tp* __first, const _Tp* __last, _Tp* __result) \ +{ return (_Tp*)_STLP_PRIV __copy_trivial_backward(__first, __last, __result); } + +# if !defined (_STLP_NO_BOOL) +_STLP_DECLARE_COPY_TRIVIAL(bool) +# endif +_STLP_DECLARE_COPY_TRIVIAL(char) +# if !defined (_STLP_NO_SIGNED_BUILTINS) +_STLP_DECLARE_COPY_TRIVIAL(signed char) +# endif +_STLP_DECLARE_COPY_TRIVIAL(unsigned char) +_STLP_DECLARE_COPY_TRIVIAL(short) +_STLP_DECLARE_COPY_TRIVIAL(unsigned short) +_STLP_DECLARE_COPY_TRIVIAL(int) +_STLP_DECLARE_COPY_TRIVIAL(unsigned int) +_STLP_DECLARE_COPY_TRIVIAL(long) +_STLP_DECLARE_COPY_TRIVIAL(unsigned long) +# if !defined(_STLP_NO_WCHAR_T) && !defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_DECLARE_COPY_TRIVIAL(wchar_t) +# endif +# if defined (_STLP_LONG_LONG) +_STLP_DECLARE_COPY_TRIVIAL(_STLP_LONG_LONG) +_STLP_DECLARE_COPY_TRIVIAL(unsigned _STLP_LONG_LONG) +# endif +_STLP_DECLARE_COPY_TRIVIAL(float) +_STLP_DECLARE_COPY_TRIVIAL(double) +# if !defined (_STLP_NO_LONG_DOUBLE) +_STLP_DECLARE_COPY_TRIVIAL(long double) +# endif +# undef _STLP_DECLARE_COPY_TRIVIAL +#endif + +//-------------------------------------------------- +// copy_n (not part of the C++ standard) + +#if !defined (_STLP_NO_EXTENSIONS) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter, class _Size, class _OutputIter> +_STLP_INLINE_LOOP _STLP_STD::pair<_InputIter, _OutputIter> +__copy_n(_InputIter __first, _Size __count, _OutputIter __result, + const input_iterator_tag &) { + for ( ; __count > 0; --__count) { + *__result = *__first; + ++__first; + ++__result; + } + return _STLP_STD::pair<_InputIter, _OutputIter>(__first, __result); +} + +template <class _RAIter, class _Size, class _OutputIter> +inline _STLP_STD::pair<_RAIter, _OutputIter> +__copy_n(_RAIter __first, _Size __count, _OutputIter __result, + const random_access_iterator_tag &) { + _RAIter __last = __first + __count; + return _STLP_STD::pair<_RAIter, _OutputIter>(__last, _STLP_STD::copy(__first, __last, __result)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _Size, class _OutputIter> +inline pair<_InputIter, _OutputIter> +copy_n(_InputIter __first, _Size __count, _OutputIter __result) { + _STLP_FIX_LITERAL_BUG(__first) + return _STLP_PRIV __copy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); +} +#endif + +//-------------------------------------------------- +// fill and fill_n +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _ForwardIter, class _Tp> +_STLP_INLINE_LOOP +void __fill_fwd(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + for ( ; __first != __last; ++__first) + *__first = __val; +} + +template <class _ForwardIter, class _Tp, class _Distance> +inline void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const input_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _ForwardIter, class _Tp, class _Distance> +_STLP_INLINE_LOOP +void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const forward_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} + +template <class _ForwardIter, class _Tp, class _Distance> +_STLP_INLINE_LOOP +void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val, + const bidirectional_iterator_tag &, _Distance*) { + _STLP_PRIV __fill_fwd(__first, __last, __val); +} +#endif + +template <class _RandomAccessIter, class _Tp, class _Distance> +_STLP_INLINE_LOOP +void __fill(_RandomAccessIter __first, _RandomAccessIter __last, const _Tp& __val, + const random_access_iterator_tag &, _Distance*) { + for (_Distance __n = __last - __first ; __n > 0; ++__first, --__n) + *__first = __val; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _ForwardIter, class _Tp> +inline void fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_PRIV __fill(__first, __last, __val, + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +// Specialization: for one-byte types we can use memset. +inline void fill(unsigned char* __first, unsigned char* __last, + const unsigned char& __val) { + unsigned char __tmp = __val; + memset(__first, __tmp, __last - __first); +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +inline void fill(signed char* __first, signed char* __last, + const signed char& __val) { + signed char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} +#endif +inline void fill(char* __first, char* __last, const char& __val) { + char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _OutputIter, class _Size, class _Tp> +_STLP_INLINE_LOOP +_OutputIter __fill_n(_OutputIter __first, _Size __n, const _Tp& __val) { + _STLP_FIX_LITERAL_BUG(__first) + for ( ; __n > 0; --__n, ++__first) + *__first = __val; + return __first; +} + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template <class _Size> +inline unsigned char* __fill_n(unsigned char* __first, _Size __n, + const unsigned char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +template <class _Size> +inline signed char* __fill_n(signed char* __first, _Size __n, + const signed char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#endif +template <class _Size> +inline char* __fill_n(char* __first, _Size __n, + const char& __val) { + _STLP_STD::fill(__first, __first + __n, __val); + return __first + __n; +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _OutputIter, class _Size, class _Tp> +inline void fill_n(_OutputIter __first, _Size __n, const _Tp& __val) { + _STLP_FIX_LITERAL_BUG(__first) + _STLP_PRIV __fill_n(__first, __n, __val); +} + + +//-------------------------------------------------- +// equal and mismatch + +template <class _InputIter1, class _InputIter2> +_STLP_INLINE_LOOP +_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + while (__first1 != __last1 && *__first1 == *__first2) { + ++__first1; + ++__first2; + } + return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2); +} + +template <class _InputIter1, class _InputIter2, class _BinaryPredicate> +_STLP_INLINE_LOOP +_STLP_STD::pair<_InputIter1, _InputIter2> mismatch(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _BinaryPredicate __binary_pred) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) { + ++__first1; + ++__first2; + } + return _STLP_STD::pair<_InputIter1, _InputIter2>(__first1, __first2); +} + +template <class _InputIter1, class _InputIter2> +_STLP_INLINE_LOOP +bool equal(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2) { + _STLP_FIX_LITERAL_BUG(__first1) _STLP_FIX_LITERAL_BUG(__last1) _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + if (!(*__first1 == *__first2)) + return false; + return true; +} + +template <class _InputIter1, class _InputIter2, class _BinaryPredicate> +_STLP_INLINE_LOOP +bool equal(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _BinaryPredicate __binary_pred) { + _STLP_FIX_LITERAL_BUG(__first2) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + for ( ; __first1 != __last1; ++__first1, ++__first2) + if (!__binary_pred(*__first1, *__first2)) + return false; + return true; +} + +//-------------------------------------------------- +// lexicographical_compare and lexicographical_compare_3way. +// (the latter is not part of the C++ standard.) + +template <class _InputIter1, class _InputIter2> +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +template <class _InputIter1, class _InputIter2, class _Compare> +bool lexicographical_compare(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _Compare __comp); + +inline bool +lexicographical_compare(const unsigned char* __first1, + const unsigned char* __last1, + const unsigned char* __first2, + const unsigned char* __last2) { + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + + const int __result = memcmp(__first1, __first2, (min) (__len1, __len2)); + return __result != 0 ? (__result < 0) : (__len1 < __len2); +} + + +#if !(CHAR_MAX == SCHAR_MAX) +inline bool lexicographical_compare(const char* __first1, const char* __last1, + const char* __first2, const char* __last2) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first1, __last1)) + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first2, __last2)) + + return lexicographical_compare((const unsigned char*) __first1, + (const unsigned char*) __last1, + (const unsigned char*) __first2, + (const unsigned char*) __last2); +} +#endif /* CHAR_MAX == SCHAR_MAX */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter1, class _InputIter2> +int __lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +inline int +__lexicographical_compare_3way(const unsigned char* __first1, + const unsigned char* __last1, + const unsigned char* __first2, + const unsigned char* __last2) { + const ptrdiff_t __len1 = __last1 - __first1; + const ptrdiff_t __len2 = __last2 - __first2; + const int __result = memcmp(__first1, __first2, (min) (__len1, __len2)); + return __result != 0 ? __result + : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1)); +} + + +#if !(CHAR_MAX == SCHAR_MAX) +inline int +__lexicographical_compare_3way(const char* __first1, const char* __last1, + const char* __first2, const char* __last2) { + return __lexicographical_compare_3way((const unsigned char*) __first1, + (const unsigned char*) __last1, + (const unsigned char*) __first2, + (const unsigned char*) __last2); +} +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +#if !defined (_STLP_NO_EXTENSIONS) +template <class _InputIter1, class _InputIter2> +int lexicographical_compare_3way(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2); + +#endif + +// count +template <class _InputIter, class _Tp> +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_InputIter) +count(_InputIter __first, _InputIter __last, const _Tp& __val) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + _STLP_DIFFERENCE_TYPE(_InputIter) __n = 0; + for ( ; __first != __last; ++__first) + if (*__first == __val) + ++__n; + return __n; +} + +// find and find_if. Note find may be expressed in terms of find_if if appropriate binder was available. +template <class _InputIter, class _Tp> +_InputIter find(_InputIter __first, _InputIter __last, const _Tp& __val); + +template <class _InputIter, class _Predicate> +_InputIter find_if(_InputIter __first, _InputIter __last, _Predicate __pred); + +// search. +template <class _ForwardIter1, class _ForwardIter2, class _BinaryPred> +_ForwardIter1 search(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, _BinaryPred __predicate); + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// find_first_of +template <class _InputIter, class _ForwardIter> +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2); + +template <class _InputIter, class _ForwardIter, class _BinaryPredicate> +_InputIter __find_first_of(_InputIter __first1, _InputIter __last1, + _ForwardIter __first2, _ForwardIter __last2, + _BinaryPredicate __comp); + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _ForwardIter1, class _ForwardIter2, + class _BinaryPredicate> +_ForwardIter1 +find_end(_ForwardIter1 __first1, _ForwardIter1 __last1, + _ForwardIter2 __first2, _ForwardIter2 __last2, + _BinaryPredicate __comp); + +// replace +template <class _ForwardIter, class _Tp> +_STLP_INLINE_LOOP void +replace(_ForwardIter __first, _ForwardIter __last, + const _Tp& __old_value, const _Tp& __new_value) { + _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) + for ( ; __first != __last; ++__first) + if (*__first == __old_value) + *__first = __new_value; +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _ForwardIter, class _Tp, class _Compare1, class _Compare2, class _Distance> +_ForwardIter __lower_bound(_ForwardIter __first, _ForwardIter __last, + const _Tp& __val, _Compare1 __comp1, _Compare2 __comp2, _Distance*); + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/_algobase.c> +#endif + +#endif /* _STLP_INTERNAL_ALGOBASE_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/stlport/stlport/stl/_alloc.c b/stlport/stlport/stl/_alloc.c new file mode 100644 index 0000000..467405b --- /dev/null +++ b/stlport/stlport/stl/_alloc.c @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_ALLOC_C +#define _STLP_ALLOC_C + +#ifndef _STLP_INTERNAL_ALLOC_H +# include <stl/_alloc.h> +#endif + +#if defined (__WATCOMC__) +# pragma warning 13 9 +# pragma warning 367 9 +# pragma warning 368 9 +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _Alloc> +void * _STLP_CALL __debug_alloc<_Alloc>::allocate(size_t __n) { + size_t __total_extra = __extra_before_chunk() + __extra_after_chunk(); + size_t __real_n = __n + __total_extra; + if (__real_n < __n) { + //It means that we rolled on size_t, __n must be very large: + _STLP_THROW_BAD_ALLOC; + } + __alloc_header *__result = (__alloc_header *)__allocator_type::allocate(__real_n); + memset((char*)__result, __shred_byte, __real_n * sizeof(value_type)); + __result->__magic = __magic; + __result->__type_size = sizeof(value_type); + __result->_M_size = (_STLP_UINT32_T)__n; + return ((char*)__result) + (long)__extra_before; +} + +template <class _Alloc> +void _STLP_CALL +__debug_alloc<_Alloc>::deallocate(void *__p, size_t __n) { + __alloc_header * __real_p = (__alloc_header*)((char *)__p -(long)__extra_before); + // check integrity + _STLP_VERBOSE_ASSERT(__real_p->__magic != __deleted_magic, _StlMsg_DBA_DELETED_TWICE) + _STLP_VERBOSE_ASSERT(__real_p->__magic == __magic, _StlMsg_DBA_NEVER_ALLOCATED) + _STLP_VERBOSE_ASSERT(__real_p->__type_size == 1,_StlMsg_DBA_TYPE_MISMATCH) + _STLP_VERBOSE_ASSERT(__real_p->_M_size == __n, _StlMsg_DBA_SIZE_MISMATCH) + // check pads on both sides + unsigned char* __tmp; + for (__tmp = (unsigned char*)(__real_p + 1); __tmp < (unsigned char*)__p; ++__tmp) { + _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_UNDERRUN) + } + + size_t __real_n = __n + __extra_before_chunk() + __extra_after_chunk(); + + for (__tmp= ((unsigned char*)__p) + __n * sizeof(value_type); + __tmp < ((unsigned char*)__real_p) + __real_n ; ++__tmp) { + _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_OVERRUN) + } + + // that may be unfortunate, just in case + __real_p->__magic = __deleted_magic; + memset((char*)__p, __shred_byte, __n * sizeof(value_type)); + __allocator_type::deallocate(__real_p, __real_n); +} + +_STLP_END_NAMESPACE + +#endif /* _STLP_ALLOC_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_alloc.h b/stlport/stlport/stl/_alloc.h new file mode 100644 index 0000000..09b8af5 --- /dev/null +++ b/stlport/stlport/stl/_alloc.h @@ -0,0 +1,580 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ALLOC_H +#define _STLP_INTERNAL_ALLOC_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include <stl/_cstddef.h> +#endif + +#ifndef _STLP_INTERNAL_CSTDLIB +# include <stl/_cstdlib.h> +#endif + +#ifndef _STLP_INTERNAL_CSTRING +# include <stl/_cstring.h> +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_NEW_HEADER +# include <stl/_new.h> +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include <stl/_construct.h> +#endif + +_STLP_BEGIN_NAMESPACE + +// Malloc-based allocator. Typically slower than default alloc below. +// Typically thread-safe and more storage efficient. + +#if !defined (_STLP_USE_NO_IOSTREAMS) +typedef void (* __oom_handler_type)(); +#endif + +class _STLP_CLASS_DECLSPEC __malloc_alloc { +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + static void* _STLP_CALL allocate(size_t __n) +#if !defined (_STLP_USE_NO_IOSTREAMS) + ; +#else + { + void *__result = malloc(__n); + if (__result == 0) { + _STLP_THROW_BAD_ALLOC; + } + return __result; + } +#endif + + static void _STLP_CALL deallocate(void* __p, size_t /* __n */) { free((char*)__p); } +#if !defined (_STLP_USE_NO_IOSTREAMS) + static __oom_handler_type _STLP_CALL set_malloc_handler(__oom_handler_type __f); +#endif +}; + +// New-based allocator. Typically slower than default alloc below. +// Typically thread-safe and more storage efficient. +class _STLP_CLASS_DECLSPEC __new_alloc { +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + static void* _STLP_CALL allocate(size_t __n) { return __stl_new(__n); } + static void _STLP_CALL deallocate(void* __p, size_t) { __stl_delete(__p); } +}; + +// Allocator adaptor to check size arguments for debugging. +// Reports errors using assert. Checking can be disabled with +// NDEBUG, but it's far better to just use the underlying allocator +// instead when no checking is desired. +// There is some evidence that this can confuse Purify. +// This adaptor can only be applied to raw allocators + +template <class _Alloc> +class __debug_alloc : public _Alloc { +public: + typedef _Alloc __allocator_type; + typedef typename _Alloc::value_type value_type; +private: + struct __alloc_header { + size_t __magic: 16; + size_t __type_size:16; + _STLP_UINT32_T _M_size; + }; // that is 8 bytes for sure + // Sunpro CC has bug on enums, so extra_before/after set explicitly + enum { __pad = 8, __magic = 0xdeba, __deleted_magic = 0xdebd, + __shred_byte = _STLP_SHRED_BYTE }; + + enum { __extra_before = 16, __extra_after = 8 }; + // Size of space used to store size. Note + // that this must be large enough to preserve + // alignment. + static size_t _STLP_CALL __extra_before_chunk() { + return (long)__extra_before / sizeof(value_type) + + (size_t)((long)__extra_before % sizeof(value_type) > 0); + } + static size_t _STLP_CALL __extra_after_chunk() { + return (long)__extra_after / sizeof(value_type) + + (size_t)((long)__extra_after % sizeof(value_type) > 0); + } +public: + __debug_alloc() {} + ~__debug_alloc() {} + static void* _STLP_CALL allocate(size_t); + static void _STLP_CALL deallocate(void *, size_t); +}; + +# if defined (__OS400__) +// dums 02/05/2007: is it really necessary ? +enum { _MAX_BYTES = 256 }; +# else +enum { _MAX_BYTES = 32 * sizeof(void*) }; +# endif + +#if !defined (_STLP_USE_NO_IOSTREAMS) +// Default node allocator. +// With a reasonable compiler, this should be roughly as fast as the +// original STL class-specific allocators, but with less fragmentation. +class _STLP_CLASS_DECLSPEC __node_alloc { + static void * _STLP_CALL _M_allocate(size_t& __n); + /* __p may not be 0 */ + static void _STLP_CALL _M_deallocate(void *__p, size_t __n); + +public: + // this one is needed for proper simple_alloc wrapping + typedef char value_type; + /* __n must be > 0 */ + static void* _STLP_CALL allocate(size_t& __n) + { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) : _M_allocate(__n); } + /* __p may not be 0 */ + static void _STLP_CALL deallocate(void *__p, size_t __n) + { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else _M_deallocate(__p, __n); } +}; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__node_alloc>; +# endif + +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>; +_STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc>; +#endif + +/* macro to convert the allocator for initialization + * not using MEMBER_TEMPLATE_CLASSES as it should work given template constructor */ +#if defined (_STLP_MEMBER_TEMPLATES) || ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* if _STLP_NO_TEMPLATE_CONVERSIONS is set, the member template constructor is + * not used implicitly to convert allocator parameter, so let us do it explicitly */ +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) && defined (_STLP_NO_TEMPLATE_CONVERSIONS) +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0) +# else +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __a +# endif +/* else convert, but only if partial specialization works, since else + * Container::allocator_type won't be different */ +#else +# define _STLP_CONVERT_ALLOCATOR(__a, _Tp) __stl_alloc_create(__a,(_Tp*)0) +#endif + +// Another allocator adaptor: _Alloc_traits. This serves two +// purposes. First, make it possible to write containers that can use +// either SGI-style allocators or standard-conforming allocator. + +// The fully general version. +template <class _Tp, class _Allocator> +struct _Alloc_traits { + typedef _Allocator _Orig; +#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + typedef typename _Allocator::_STLP_TEMPLATE rebind<_Tp> _Rebind_type; + typedef typename _Rebind_type::other allocator_type; + static allocator_type create_allocator(const _Orig& __a) + { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); } +#else + // this is not actually true, used only to pass this type through + // to dynamic overload selection in _STLP_alloc_proxy methods + typedef _Allocator allocator_type; +#endif +}; + +#if defined (_STLP_USE_PERTHREAD_ALLOC) + +_STLP_END_NAMESPACE +// include additional header here +# include <stl/_pthread_alloc.h> +_STLP_BEGIN_NAMESPACE + +typedef __pthread_alloc __alloc_type; +#elif defined (_STLP_USE_NEWALLOC) +typedef __new_alloc __alloc_type; +#elif defined (_STLP_USE_MALLOC) +typedef __malloc_alloc __alloc_type; +#else +typedef __node_alloc __alloc_type; +#endif + +#if defined (_STLP_DEBUG_ALLOC) +typedef __debug_alloc<__alloc_type> __sgi_alloc; +#else +typedef __alloc_type __sgi_alloc; +#endif + +#if !defined (_STLP_NO_ANACHRONISMS) +typedef __sgi_alloc __single_client_alloc; +typedef __sgi_alloc __multithreaded_alloc; +#endif + +// This implements allocators as specified in the C++ standard. +// +// Note that standard-conforming allocators use many language features +// that are not yet widely implemented. In particular, they rely on +// member templates, partial specialization, partial ordering of function +// templates, the typename keyword, and the use of the template keyword +// to refer to a template member of a dependent type. + +/* +template <class _Tp> +struct _AllocatorAux { + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + pointer address(reference __x) const {return &__x;} + const_pointer address(const_reference __x) const { return &__x; } +}; + +template <class _Tp> +struct _AllocatorAux<const _Tp> { + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + const_pointer address(const_reference __x) const { return &__x; } +}; +*/ + +template <class _Tp> +class allocator //: public _AllocatorAux<_Tp> +/* A small helper struct to recognize STLport allocator implementation + * from any user specialization one. + */ + : public __stlport_class<allocator<_Tp> > +{ +public: + typedef _Tp value_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; +#if defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template <class _Tp1> struct rebind { + typedef allocator<_Tp1> other; + }; +#endif + allocator() _STLP_NOTHROW {} +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _Tp1> allocator(const allocator<_Tp1>&) _STLP_NOTHROW {} +#endif + allocator(const allocator<_Tp>&) _STLP_NOTHROW {} +#if !defined (_STLP_NO_MOVE_SEMANTIC) + allocator(__move_source<allocator<_Tp> > src) _STLP_NOTHROW {} +#endif + ~allocator() _STLP_NOTHROW {} + pointer address(reference __x) const {return &__x;} + const_pointer address(const_reference __x) const { return &__x; } + // __n is permitted to be 0. The C++ standard says nothing about what the return value is when __n == 0. + _Tp* allocate(size_type __n, const void* = 0) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + return __ret; + } + + return 0; + } + // __p is permitted to be a null pointer, only if n==0. + void deallocate(pointer __p, size_type __n) { + _STLP_ASSERT( (__p == 0) == (__n == 0) ) + if (__p != 0) { +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__p, _STLP_SHRED_BYTE, __n * sizeof(value_type)); +#endif + __sgi_alloc::deallocate((void*)__p, __n * sizeof(value_type)); + } + } +#if !defined (_STLP_NO_ANACHRONISMS) + // backwards compatibility + void deallocate(pointer __p) const { if (__p != 0) __sgi_alloc::deallocate((void*)__p, sizeof(value_type)); } +#endif + size_type max_size() const _STLP_NOTHROW { return size_t(-1) / sizeof(value_type); } + void construct(pointer __p, const_reference __val) { _STLP_STD::_Copy_Construct(__p, __val); } + void destroy(pointer __p) { _STLP_STD::_Destroy(__p); } + +#if defined (_STLP_NO_EXTENSIONS) + /* STLport extension giving rounded size of an allocated memory buffer + * This method do not have to be part of a user defined allocator implementation + * and won't even be called if such a function was granted. + */ +protected: +#endif + _Tp* _M_allocate(size_type __n, size_type& __allocated_n) { + if (__n > max_size()) { + _STLP_THROW_BAD_ALLOC; + } + + if (__n != 0) { + size_type __buf_size = __n * sizeof(value_type); + _Tp* __ret = __REINTERPRET_CAST(_Tp*, __sgi_alloc::allocate(__buf_size)); +#if defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_ALLOC) + memset((char*)__ret, _STLP_SHRED_BYTE, __buf_size); +#endif + __allocated_n = __buf_size / sizeof(value_type); + return __ret; + } + + return 0; + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(allocator<_Tp>& __other) {} +#endif +}; + +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC allocator<void> { +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef void* pointer; + typedef const void* const_pointer; +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) + typedef void value_type; +#endif +#if defined (_STLP_MEMBER_TEMPLATE_CLASSES) + template <class _Tp1> struct rebind { + typedef allocator<_Tp1> other; + }; +#endif +}; + +template <class _T1, class _T2> +inline bool _STLP_CALL operator==(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW +{ return true; } +template <class _T1, class _T2> +inline bool _STLP_CALL operator!=(const allocator<_T1>&, const allocator<_T2>&) _STLP_NOTHROW +{ return false; } + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS allocator<char>; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS allocator<wchar_t>; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_EXPORT_TEMPLATE_CLASS allocator<void*>; +# endif +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp> +struct __alloc_type_traits { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<allocator<_Tp> >::_Ret _STLportAlloc; +#else + enum { _Is = _IsSTLportClass<allocator<_Tp> >::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportAlloc; +#endif + //The default allocator implementation which is recognize thanks to the + //__stlport_class inheritance is a stateless object so: + typedef _STLportAlloc has_trivial_default_constructor; + typedef _STLportAlloc has_trivial_copy_constructor; + typedef _STLportAlloc has_trivial_assignment_operator; + typedef _STLportAlloc has_trivial_destructor; + typedef _STLportAlloc is_POD_type; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Tp> +struct __type_traits<allocator<_Tp> > : _STLP_PRIV __alloc_type_traits<_Tp> {}; +#else +_STLP_TEMPLATE_NULL +struct __type_traits<allocator<char> > : _STLP_PRIV __alloc_type_traits<char> {}; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_TEMPLATE_NULL +struct __type_traits<allocator<wchar_t> > : _STLP_PRIV __alloc_type_traits<wchar_t> {}; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_TEMPLATE_NULL +struct __type_traits<allocator<void*> > : _STLP_PRIV __alloc_type_traits<void*> {}; +# endif +#endif + + +#if !defined (_STLP_FORCE_ALLOCATORS) +# define _STLP_FORCE_ALLOCATORS(a,y) +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES) +// The version for the default allocator, for rare occasion when we have partial spec w/o member template classes +template <class _Tp, class _Tp1> +struct _Alloc_traits<_Tp, allocator<_Tp1> > { + typedef allocator<_Tp1> _Orig; + typedef allocator<_Tp> allocator_type; + static allocator_type create_allocator(const allocator<_Tp1 >& __a) + { return allocator_type(_STLP_CONVERT_ALLOCATOR(__a, _Tp)); } +}; +#endif + +#if !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) && defined (_STLP_MEMBER_TEMPLATES) +template <class _Tp, class _Alloc> +inline _STLP_TYPENAME_ON_RETURN_TYPE _Alloc_traits<_Tp, _Alloc>::allocator_type _STLP_CALL +__stl_alloc_create(const _Alloc& __a, const _Tp*) { + typedef typename _Alloc::_STLP_TEMPLATE rebind<_Tp>::other _Rebound_type; + return _Rebound_type(__a); +} +#else +// If custom allocators are being used without member template classes support : +// user (on purpose) is forced to define rebind/get operations !!! +template <class _Tp1, class _Tp2> +inline allocator<_Tp2>& _STLP_CALL +__stl_alloc_rebind(allocator<_Tp1>& __a, const _Tp2*) { return (allocator<_Tp2>&)(__a); } +template <class _Tp1, class _Tp2> +inline allocator<_Tp2> _STLP_CALL +__stl_alloc_create(const allocator<_Tp1>&, const _Tp2*) { return allocator<_Tp2>(); } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// inheritance is being used for EBO optimization +template <class _Value, class _Tp, class _MaybeReboundAlloc> +class _STLP_alloc_proxy : public _MaybeReboundAlloc { +private: + typedef _MaybeReboundAlloc _Base; + typedef typename _Base::size_type size_type; + typedef _STLP_alloc_proxy<_Value, _Tp, _MaybeReboundAlloc> _Self; +public: + _Value _M_data; + + _STLP_alloc_proxy (const _MaybeReboundAlloc& __a, _Value __p) : + _MaybeReboundAlloc(__a), _M_data(__p) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _STLP_alloc_proxy (__move_source<_Self> src) : + _Base(_STLP_PRIV _AsMoveSource(src.get()._M_base())), + _M_data(_STLP_PRIV _AsMoveSource(src.get()._M_data)) {} + + _Base& _M_base() + { return *this; } +#endif + +private: + /* Following are helper methods to detect stateless allocators and avoid + * swap in this case. For some compilers (VC6) it is a workaround for a + * compiler bug in the Empty Base class Optimization feature, for others + * it is a small optimization or nothing if no EBO. */ + void _M_swap_alloc(_Self&, const __true_type& /*_IsStateless*/) + {} + + void _M_swap_alloc(_Self& __x, const __false_type& /*_IsStateless*/) { + _MaybeReboundAlloc &__base_this = *this; + _MaybeReboundAlloc &__base_x = __x; + _STLP_STD::swap(__base_this, __base_x); + } + +public: + void _M_swap_alloc(_Self& __x) { +#if !defined (__BORLANDC__) + typedef typename _IsStateless<_MaybeReboundAlloc>::_Ret _StatelessAlloc; +#else + typedef typename __bool2type<_IsStateless<_MaybeReboundAlloc>::_Is>::_Ret _StatelessAlloc; +#endif + _M_swap_alloc(__x, _StatelessAlloc()); + } + + /* We need to define the following swap implementation for allocator with state + * as those allocators might have implement a special swap function to correctly + * move datas from an instance to the oher, _STLP_alloc_proxy should not break + * this mecanism. */ + void swap(_Self& __x) { + _M_swap_alloc(__x); + _STLP_STD::swap(_M_data, __x._M_data); + } + + _Tp* allocate(size_type __n, size_type& __allocated_n) { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<_MaybeReboundAlloc>::_Ret _STLportAlloc; +#else + typedef typename __bool2type<_IsSTLportClass<_MaybeReboundAlloc>::_Is>::_Ret _STLportAlloc; +#endif + return allocate(__n, __allocated_n, _STLportAlloc()); + } + + // Unified interface to perform allocate()/deallocate() with limited + // language support +#if defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) + // else it is rebound already, and allocate() member is accessible + _Tp* allocate(size_type __n) + { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).allocate(__n, 0); } + void deallocate(_Tp* __p, size_type __n) + { __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0)).deallocate(__p, __n); } +private: + _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/) + { return __stl_alloc_rebind(__STATIC_CAST(_Base&, *this), __STATIC_CAST(_Tp*, 0))._M_allocate(__n, __allocated_n); } +#else + //Expose Standard allocate overload (using expression do not work for some compilers (Borland)) + _Tp* allocate(size_type __n) + { return _Base::allocate(__n); } +private: + _Tp* allocate(size_type __n, size_type& __allocated_n, const __true_type& /*STLport allocator*/) + { return _Base::_M_allocate(__n, __allocated_n); } +#endif + + _Tp* allocate(size_type __n, size_type& __allocated_n, const __false_type& /*STLport allocator*/) + { __allocated_n = __n; return allocate(__n); } +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<char*, char, allocator<char> >; +# if defined (_STLP_HAS_WCHAR_T) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<wchar_t*, wchar_t, allocator<wchar_t> >; +# endif +# if defined (_STLP_USE_PTR_SPECIALIZATIONS) +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >; +# endif +#endif + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/_alloc.c> +#endif + +#endif /* _STLP_INTERNAL_ALLOC_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/stlport/stlport/stl/_bvector.h b/stlport/stlport/stl/_bvector.h new file mode 100644 index 0000000..bf417f1 --- /dev/null +++ b/stlport/stlport/stl/_bvector.h @@ -0,0 +1,841 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_BVECTOR_H +#define _STLP_INTERNAL_BVECTOR_H + +#ifndef _STLP_INTERNAL_VECTOR_H +# include <stl/_vector.h> +#endif + +#define _STLP_WORD_BIT (int(CHAR_BIT * sizeof(unsigned int))) + +_STLP_BEGIN_NAMESPACE +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Bit_reference { + unsigned int* _M_p; + unsigned int _M_mask; + _Bit_reference(unsigned int* __x, unsigned int __y) + : _M_p(__x), _M_mask(__y) {} + +public: + _Bit_reference() : _M_p(0), _M_mask(0) {} + + operator bool() const { + return !(!(*_M_p & _M_mask)); + } + _Bit_reference& operator = (bool __x) { + if (__x) *_M_p |= _M_mask; + else *_M_p &= ~_M_mask; + return *this; + } + _Bit_reference& operator = (const _Bit_reference& __x) { + return *this = bool(__x); + } + bool operator == (const _Bit_reference& __x) const { + return bool(*this) == bool(__x); + } + bool operator < (const _Bit_reference& __x) const { + return !bool(*this) && bool(__x); + } + + _Bit_reference& operator |= (bool __x) { + if (__x) + *_M_p |= _M_mask; + return *this; + } + _Bit_reference& operator &= (bool __x) { + if (!__x) + *_M_p &= ~_M_mask; + return *this; + } + void flip() { *_M_p ^= _M_mask; } +}; + + +_STLP_MOVE_TO_STD_NAMESPACE + +inline void swap(_STLP_PRIV _Bit_reference& __x, _STLP_PRIV _Bit_reference& __y) { + bool __tmp = (bool)__x; + __x = __y; + __y = __tmp; +} + +// Might not be very useful but costs nothing! +_STLP_TEMPLATE_NULL +struct __type_traits<_STLP_PRIV _Bit_reference> { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _Bit_iterator_base { + typedef ptrdiff_t difference_type; + + unsigned int* _M_p; + unsigned int _M_offset; + + void _M_bump_up() { + if (_M_offset++ == _STLP_WORD_BIT - 1) { + _M_offset = 0; + ++_M_p; + } + } + + void _M_bump_down() { + if (_M_offset-- == 0) { + _M_offset = _STLP_WORD_BIT - 1; + --_M_p; + } + } + + _Bit_iterator_base() : _M_p(0), _M_offset(0) {} + _Bit_iterator_base(unsigned int* __x, unsigned int __y) : _M_p(__x), _M_offset(__y) {} +// see comment in doc/README.evc4 and doc/README.evc8 +#if defined(_MSC_VER) && _MSC_VER<=1401 && defined(MIPS) && defined(NDEBUG) + _Bit_iterator_base( const _Bit_iterator_base& __x) : _M_p(__x._M_p), _M_offset(__x._M_offset) {} +#endif + // _Bit_iterator_base& operator = ( const _Bit_iterator_base& __x) { _M_p = __x._M_p ; _M_offset = __x._M_offset ; return *this; } + + void _M_advance (difference_type __i) { + difference_type __n = __i + _M_offset; + _M_p += __n / _STLP_WORD_BIT; + __n = __n % _STLP_WORD_BIT; + if (__n < 0) { + _M_offset = (unsigned int) __n + _STLP_WORD_BIT; + --_M_p; + } else + _M_offset = (unsigned int) __n; + } + + difference_type _M_subtract(const _Bit_iterator_base& __x) const { + return _STLP_WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset; + } +}; + +inline bool _STLP_CALL operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __y._M_p == __x._M_p && __y._M_offset == __x._M_offset; +} +inline bool _STLP_CALL operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __y._M_p != __x._M_p || __y._M_offset != __x._M_offset; +} + +inline bool _STLP_CALL operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); +} + +inline bool _STLP_CALL operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return operator <(__y , __x); +} +inline bool _STLP_CALL operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return !(__y < __x); +} +inline bool _STLP_CALL operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) { + return !(__x < __y); +} + +template <class _Ref, class _Ptr> +struct _Bit_iter : public _Bit_iterator_base { + typedef _Ref reference; + typedef _Ptr pointer; + typedef _Bit_iter<_Ref, _Ptr> _Self; + typedef random_access_iterator_tag iterator_category; + typedef bool value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + + _Bit_iter(unsigned int* __x, unsigned int __y) : _Bit_iterator_base(__x, __y) {} + _Bit_iter() {} + + _Bit_iter(const _Bit_iter<_Bit_reference, _Bit_reference*>& __x): + _Bit_iterator_base((const _Bit_iterator_base&)__x) {} + + // _Self& operator = (const _Bit_iter<_Bit_reference, _Bit_reference*>& __x) + // { (_Bit_iterator_base&)*this = (const _Bit_iterator_base&)__x; return *this; } + + reference operator*() const { + return _Bit_reference(_M_p, 1UL << _M_offset); + } + _Self& operator++() { + _M_bump_up(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + _M_bump_up(); + return __tmp; + } + _Self& operator--() { + _M_bump_down(); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + _M_bump_down(); + return __tmp; + } + _Self& operator+=(difference_type __i) { + _M_advance(__i); + return *this; + } + _Self& operator-=(difference_type __i) { + *this += -__i; + return *this; + } + _Self operator+(difference_type __i) const { + _Self __tmp = *this; + return __tmp += __i; + } + _Self operator-(difference_type __i) const { + _Self __tmp = *this; + return __tmp -= __i; + } + difference_type operator-(const _Self& __x) const { + return _M_subtract(__x); + } + reference operator[](difference_type __i) { return *(*this + __i); } +}; + +template <class _Ref, class _Ptr> +inline _Bit_iter<_Ref,_Ptr> _STLP_CALL +operator+(ptrdiff_t __n, const _Bit_iter<_Ref, _Ptr>& __x) { + return __x + __n; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Ref, class _Ptr> +struct __type_traits< _STLP_PRIV _Bit_iter<_Ref, _Ptr> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +inline random_access_iterator_tag iterator_category(const _STLP_PRIV _Bit_iterator_base&) +{ return random_access_iterator_tag(); } +inline ptrdiff_t* distance_type(const _STLP_PRIV _Bit_iterator_base&) +{ return (ptrdiff_t*)0; } +inline bool* value_type(const _STLP_PRIV _Bit_iter<_STLP_PRIV _Bit_reference, _STLP_PRIV _Bit_reference*>&) +{ return (bool*)0; } +inline bool* value_type(const _STLP_PRIV _Bit_iter<bool, const bool*>&) +{ return (bool*)0; } +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +typedef _Bit_iter<bool, const bool*> _Bit_const_iterator; +typedef _Bit_iter<_Bit_reference, _Bit_reference*> _Bit_iterator; + +// Bit-vector base class, which encapsulates the difference between +// old SGI-style allocators and standard-conforming allocators. +template <class _Alloc> +class _Bvector_base { + typedef _Bvector_base<_Alloc> _Self; +public: + _STLP_FORCE_ALLOCATORS(bool, _Alloc) + typedef _Alloc allocator_type; + typedef unsigned int __chunk_type; + typedef typename _Alloc_traits<__chunk_type, _Alloc>::allocator_type __chunk_allocator_type; + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR(__STATIC_CAST(const __chunk_allocator_type&, _M_end_of_storage), bool); } + + _Bvector_base(const allocator_type& __a) + : _M_start(), _M_finish(), _M_end_of_storage(_STLP_CONVERT_ALLOCATOR(__a, __chunk_type), + (__chunk_type*)0) + {} +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Bvector_base(__move_source<_Self> src) + : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish), + _M_end_of_storage(src.get()._M_end_of_storage) { + //Make the source destroyable + src.get()._M_start._M_p = 0; + } +#endif + + ~_Bvector_base() { + _M_deallocate(); + } + +protected: + + static size_t _M_bits_to_chunks(size_t __n_bits) + { return (__n_bits + _STLP_WORD_BIT - 1) / _STLP_WORD_BIT; } + + __chunk_type* _M_bit_alloc(size_t __n) + { return _M_end_of_storage.allocate(_M_bits_to_chunks(__n)); } + + void _M_deallocate() { + if (_M_start._M_p) + _M_end_of_storage.deallocate(_M_start._M_p, + _M_end_of_storage._M_data - _M_start._M_p); + } + + _Bit_iterator _M_start; + _Bit_iterator _M_finish; + _STLP_alloc_proxy<__chunk_type*, __chunk_type, __chunk_allocator_type> _M_end_of_storage; +}; + + +// The next few lines are confusing. What we're doing is declaring a +// partial specialization of vector<T, Alloc> if we have the necessary +// compiler support. Otherwise, we define a class bit_vector which uses +// the default allocator. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_BOOL) && !defined (__SUNPRO_CC) +# define _STLP_VECBOOL_TEMPLATE +# define __BVEC_TMPL_HEADER template <class _Alloc> +#else +# undef _STLP_VECBOOL_TEMPLATE +# ifdef _STLP_NO_BOOL +# define __BVEC_TMPL_HEADER +# else +# define __BVEC_TMPL_HEADER _STLP_TEMPLATE_NULL +# endif +# define _Alloc allocator<bool> +#endif + +#if defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#endif + +#ifdef _STLP_NO_BOOL +# define __BVECTOR_QUALIFIED bit_vector +# define __BVECTOR bit_vector +#else +# ifdef _STLP_VECBOOL_TEMPLATE +# define __BVECTOR_QUALIFIED vector<bool, _Alloc> +# else +# define __BVECTOR_QUALIFIED vector<bool, allocator<bool> > +# endif +# if defined (_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS) +# define __BVECTOR __BVECTOR_QUALIFIED +# else +# define __BVECTOR vector +# endif +#endif + +#if !defined (_STLP_DEBUG) || defined (_STLP_NO_BOOL) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +__BVEC_TMPL_HEADER +class __BVECTOR_QUALIFIED : public _STLP_PRIV _Bvector_base<_Alloc > +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_DEBUG) + , public __stlport_class< __BVECTOR_QUALIFIED > +#endif +{ + typedef _STLP_PRIV _Bvector_base<_Alloc > _Base; + typedef __BVECTOR_QUALIFIED _Self; +public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _STLP_PRIV _Bit_reference reference; + typedef bool const_reference; + typedef _STLP_PRIV _Bit_reference* pointer; + typedef const bool* const_pointer; + typedef random_access_iterator_tag _Iterator_category; + + typedef _STLP_PRIV _Bit_iterator iterator; + typedef _STLP_PRIV _Bit_const_iterator const_iterator; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + +#ifdef _STLP_VECBOOL_TEMPLATE + typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type; + typedef _STLP_TYPENAME _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type; +#else + typedef _STLP_PRIV _Bvector_base<_Alloc >::allocator_type allocator_type; + typedef _STLP_PRIV _Bvector_base<_Alloc >::__chunk_type __chunk_type; +#endif + +protected: + + void _M_initialize(size_type __n) { + __chunk_type* __q = this->_M_bit_alloc(__n); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n); + this->_M_start = iterator(__q, 0); + this->_M_finish = this->_M_start + difference_type(__n); + } + void _M_insert_aux(iterator __position, bool __x) { + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) { + _STLP_PRIV __copy_backward(__position, this->_M_finish, this->_M_finish + 1, + random_access_iterator_tag(), (difference_type*)0 ); + *__position = __x; + ++this->_M_finish; + } + else { + size_type __len = size() ? 2 * size() : _STLP_WORD_BIT; + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + *__i++ = __x; + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void _M_initialize_range(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + this->_M_start = iterator(); + this->_M_finish = iterator(); + this->_M_end_of_storage._M_data = 0; + for ( ; __first != __last; ++__first) + push_back(*__first); + } + + template <class _ForwardIterator> + void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } + + template <class _InputIterator> + void _M_insert_range(iterator __pos, + _InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template <class _ForwardIterator> + void _M_insert_range(iterator __position, + _ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + if (__first != __last) { + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n), + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += difference_type(__n); + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + } + +#endif /* _STLP_MEMBER_TEMPLATES */ + +public: + iterator begin() { return this->_M_start; } + const_iterator begin() const { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator end() const { return this->_M_finish; } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + size_type size() const { return size_type(end() - begin()); } + size_type max_size() const { return size_type(-1); } + size_type capacity() const { + return size_type(const_iterator(this->_M_end_of_storage._M_data, 0) - begin()); + } + bool empty() const { return begin() == end(); } + reference operator[](size_type __n) + { return *(begin() + difference_type(__n)); } + const_reference operator[](size_type __n) const + { return *(begin() + difference_type(__n)); } + + void _M_range_check(size_type __n) const { + if (__n >= this->size()) + __stl_throw_range_error("vector<bool>"); + } + + reference at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } + const_reference at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } + + explicit __BVECTOR(const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) {} + + __BVECTOR(size_type __n, bool __val, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + _M_initialize(__n); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __val ? ~0 : 0); + } + + explicit __BVECTOR(size_type __n) + : _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) { + _M_initialize(__n); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), 0); + } + + __BVECTOR(const _Self& __x) + : _STLP_PRIV _Bvector_base<_Alloc >(__x.get_allocator()) { + _M_initialize(__x.size()); + _STLP_STD::copy(__x.begin(), __x.end(), this->_M_start); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _Integer> + void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) { + _M_initialize(__n); + fill(this->_M_start._M_p, this->_M_end_of_storage._M_data, __x ? ~0 : 0); + } + + template <class _InputIterator> + void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_initialize_range(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + // Check whether it's an integral type. If so, it's not an iterator. + template <class _InputIterator> + __BVECTOR(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Bvector_base<_Alloc >(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +# endif + template <class _InputIterator> + __BVECTOR(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#else /* _STLP_MEMBER_TEMPLATES */ + __BVECTOR(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } + __BVECTOR(const bool* __first, const bool* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Bvector_base<_Alloc >(__a) { + size_type __n = _STLP_STD::distance(__first, __last); + _M_initialize(__n); + _STLP_STD::copy(__first, __last, this->_M_start); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + __BVECTOR(__move_source<_Self> src) + : _STLP_PRIV _Bvector_base<_Alloc >(__move_source<_Base>(src.get())) {} +#endif + + ~__BVECTOR() {} + + __BVECTOR_QUALIFIED& operator=(const __BVECTOR_QUALIFIED& __x) { + if (&__x == this) return *this; + if (__x.size() > capacity()) { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + _STLP_STD::copy(__x.begin(), __x.end(), begin()); + this->_M_finish = begin() + difference_type(__x.size()); + return *this; + } + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void _M_fill_assign(size_t __n, bool __x) { + if (__n > size()) { + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0); + insert(end(), __n - size(), __x); + } + else { + erase(begin() + __n, end()); + fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0); + } + } + void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + + template <class _Integer> + void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&) + { _M_fill_assign((size_t) __n, (bool) __val); } + + template <class _InputIter> + void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&) + { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + + template <class _InputIterator> + void _M_assign_aux(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + iterator __cur = begin(); + for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + erase(__cur, end()); + else + insert(end(), __first, __last); + } + + template <class _ForwardIterator> + void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __len = _STLP_STD::distance(__first, __last); + if (__len < size()) + erase(_STLP_STD::copy(__first, __last, begin()), end()); + else { + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, size()); + _STLP_STD::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void reserve(size_type __n) { + if (capacity() < __n) { + if (max_size() < __n) + __stl_throw_length_error("vector<bool>"); + __chunk_type* __q = this->_M_bit_alloc(__n); + _STLP_PRIV _Bit_iterator __z(__q, 0); + this->_M_finish = _STLP_STD::copy(begin(), end(), __z); + this->_M_deallocate(); + this->_M_start = iterator(__q, 0); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__n); + } + } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + void push_back(bool __x) { + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) { + *(this->_M_finish) = __x; + ++this->_M_finish; + } + else + _M_insert_aux(end(), __x); + } + void swap(__BVECTOR_QUALIFIED& __x) { + _STLP_STD::swap(this->_M_start, __x._M_start); + _STLP_STD::swap(this->_M_finish, __x._M_finish); + this->_M_end_of_storage.swap(__x._M_end_of_storage); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(__BVECTOR_QUALIFIED& __x) { swap(__x); } +#endif + + iterator insert(iterator __position, bool __x = bool()) { + difference_type __n = __position - begin(); + if (this->_M_finish._M_p != this->_M_end_of_storage._M_data && __position == end()) { + *(this->_M_finish) = __x; + ++this->_M_finish; + } + else + _M_insert_aux(__position, __x); + return begin() + __n; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + + template <class _Integer> + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type&) { + _M_fill_insert(__pos, (size_type) __n, (bool) __x); + } + + template <class _InputIterator> + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) { + _M_insert_range(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); + } + + // Check whether it's an integral type. If so, it's not an iterator. + template <class _InputIterator> + void insert(iterator __position, + _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __position, + const_iterator __first, const_iterator __last) { + if (__first == __last) return; + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n, + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += __n; + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + + void insert(iterator __position, const bool* __first, const bool* __last) { + if (__first == __last) return; + size_type __n = _STLP_STD::distance(__first, __last); + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + __n, + random_access_iterator_tag(), (difference_type*)0 ); + _STLP_STD::copy(__first, __last, __position); + this->_M_finish += __n; + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + __i = _STLP_STD::copy(__first, __last, __i); + this->_M_finish = _STLP_STD::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void _M_fill_insert(iterator __position, size_type __n, bool __x) { + if (__n == 0) return; + if (capacity() - size() >= __n) { + _STLP_PRIV __copy_backward(__position, end(), this->_M_finish + difference_type(__n), + random_access_iterator_tag(), (difference_type*)0 ); + fill(__position, __position + difference_type(__n), __x); + this->_M_finish += difference_type(__n); + } + else { + size_type __len = size() + (max)(size(), __n); + __chunk_type* __q = this->_M_bit_alloc(__len); + iterator __i = _STLP_STD::copy(begin(), __position, iterator(__q, 0)); + fill_n(__i, __n, __x); + this->_M_finish = _STLP_STD::copy(__position, end(), __i + difference_type(__n)); + this->_M_deallocate(); + this->_M_end_of_storage._M_data = __q + _Base::_M_bits_to_chunks(__len); + this->_M_start = iterator(__q, 0); + } + } + + void insert(iterator __position, size_type __n, bool __x) { + _M_fill_insert(__position, __n, __x); + } + + void pop_back() { + --this->_M_finish; + } + iterator erase(iterator __position) { + if (__position + 1 != end()) + _STLP_STD::copy(__position + 1, end(), __position); + --this->_M_finish; + return __position; + } + iterator erase(iterator __first, iterator __last) { + this->_M_finish = _STLP_STD::copy(__last, end(), __first); + return __first; + } + void resize(size_type __new_size, bool __x = bool()) { + if (__new_size < size()) + erase(begin() + difference_type(__new_size), end()); + else + insert(end(), __new_size - size(), __x); + } + void flip() { + for (__chunk_type* __p = this->_M_start._M_p; __p != this->_M_end_of_storage._M_data; ++__p) + *__p = ~*__p; + } + + void clear() { erase(begin(), end()); } +}; + +#if defined (_STLP_NO_BOOL) || defined (__HP_aCC) // fixed soon (03/17/2000) +# define _STLP_TEMPLATE_HEADER __BVEC_TMPL_HEADER +# define _STLP_TEMPLATE_CONTAINER __BVECTOR_QUALIFIED +# include <stl/_relops_cont.h> +# undef _STLP_TEMPLATE_CONTAINER +# undef _STLP_TEMPLATE_HEADER +#endif /* NO_BOOL */ + +#if defined (_STLP_DEBUG) && !defined (_STLP_NO_BOOL) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#undef vector +#undef _Alloc +#undef _STLP_VECBOOL_TEMPLATE +#undef __BVECTOR +#undef __BVECTOR_QUALIFIED +#undef __BVEC_TMPL_HEADER + +#undef _STLP_WORD_BIT + +#endif /* _STLP_INTERNAL_BVECTOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_carray.h b/stlport/stlport/stl/_carray.h new file mode 100644 index 0000000..560bab2 --- /dev/null +++ b/stlport/stlport/stl/_carray.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_CARRAY_H +#define _STLP_CARRAY_H + +/* Purpose: Mimic a pur C array with the additionnal feature of + * being able to be used with type not default constructible. + */ + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include <stl/_construct.h> +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp, size_t _Nb> +struct _CArray { + _CArray (const _Tp& __val) { + for (size_t __i = 0; __i < _Nb; ++__i) { + _Copy_Construct(__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)), __val); + } + } + + ~_CArray() { + _Destroy_Range(__REINTERPRET_CAST(_Tp*, _M_data + 0), + __REINTERPRET_CAST(_Tp*, _M_data + _Nb * sizeof(_Tp))); + } + + _Tp& operator [] (size_t __i) { + _STLP_ASSERT(__i < _Nb) + return *__REINTERPRET_CAST(_Tp*, _M_data + __i * sizeof(_Tp)); + } + +private: + char _M_data[sizeof(_Tp) * _Nb]; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif //_STLP_CARRAY_H diff --git a/stlport/stlport/stl/_cmath.h b/stlport/stlport/stl/_cmath.h new file mode 100755 index 0000000..7e3bad5 --- /dev/null +++ b/stlport/stlport/stl/_cmath.h @@ -0,0 +1,581 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + */ + +#ifndef _STLP_INTERNAL_CMATH +#define _STLP_INTERNAL_CMATH + +/* gcc do not like when a using directive appear after a function + * declaration. cmath have abs overloads and cstdlib a using directive + * so cstdlib has to be included first. + */ +#if defined (__GNUC__) && defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstdlib> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +# endif +#endif + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_NO_NAMESPACES) && !defined (exception) +# define exception __math_exception +# endif +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cmath> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cmath) +# endif +# if defined (_STLP_HAS_NO_NAMESPACES) +# undef exception +# endif +#else +# include <math.h> +#endif + +#if (defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) || \ + !(defined (__IBMCPP__) && (__IBMCPP__ >= 500) || !(defined(__HP_aCC) && (__HP_aCC >= 30000) )) +# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC) +// All the other hypot stuff is going to be at file scope, so follow along here. +namespace std { +# endif +extern "C" double hypot(double x, double y); +# if !defined(_STLP_HAS_NO_NAMESPACES) && !defined(__SUNPRO_CC) +} +# endif + +#endif + +#if defined (__sun) && defined (__GNUC__) +extern "C" { + float __cosf(float v); + float __sinf(float v); + float __atan2f(float, float); + float __coshf(float v); + float __sinhf(float v); + float __sqrtf(float v); + float __expf(float v); + float __logf(float v); + float __log10f(float v); + + long double __cosl(long double v); + long double __sinl(long double v); + long double __atan2l(long double, long double); + long double __coshl(long double v); + long double __sinhl(long double v); + long double __sqrtl(long double v); + long double __expl(long double v); + long double __logl(long double v); + long double __log10l(long double v); +} + +extern "C" { + inline float cosf(float v) { return __cosf(v); } + inline float sinf(float v) { return __sinf(v); } + inline float atan2f(float v1, float v2) { return __atan2f(v1,v2); } + inline float coshf(float v) { return __coshf(v); } + inline float sinhf(float v) { return __sinhf(v); } + inline float sqrtf(float v) { return __sqrtf(v); } + inline float expf(float v) { return __expf(v); } + inline float logf(float v) { return __logf(v); } + inline float log10f(float v) { return __log10f(v); } + + inline long double cosl(long double v) { return __cosl(v); } + inline long double sinl(long double v) { return __sinl(v); } + inline long double atan2l(long double v1, long double v2) { return __atan2l(v1,v2); } + inline long double coshl(long double v) { return __coshl(v); } + inline long double sinhl(long double v) { return __sinhl(v); } + inline long double sqrtl(long double v) { return __sqrtl(v); } + inline long double expl(long double v) { return __expl(v); } + inline long double logl(long double v) { return __logl(v); } + inline long double log10l(long double v) { return __log10l(v); } +} +#endif // __sun && __GNUC__ + +#if defined (__sun) +extern "C" { +extern float __acosf(float); +extern float __asinf(float); +extern float __atanf(float); +extern float __atan2f(float, float); +extern float __ceilf(float); +extern float __cosf(float); +extern float __coshf(float); +extern float __expf(float); +extern float __fabsf(float); +extern float __floorf(float); +extern float __fmodf(float, float); +extern float __frexpf(float, int *); +extern float __ldexpf(float, int); +extern float __logf(float); +extern float __log10f(float); +extern float __modff(float, float *); +extern float __powf(float, float); +extern float __sinf(float); +extern float __sinhf(float); +extern float __sqrtf(float); +extern float __tanf(float); +extern float __tanhf(float); + +extern long double __acosl(long double); +extern long double __asinl(long double); +extern long double __atanl(long double); +extern long double __atan2l(long double, long double); +extern long double __ceill(long double); +extern long double __cosl(long double); +extern long double __coshl(long double); +extern long double __expl(long double); +extern long double __fabsl(long double); +extern long double __floorl(long double); +extern long double __fmodl(long double, long double); +extern long double __frexpl(long double, int *); +extern long double __ldexpl(long double, int); +extern long double __logl(long double); +extern long double __log10l(long double); +extern long double __modfl(long double, long double *); +extern long double __powl(long double, long double); +extern long double __sinl(long double); +extern long double __sinhl(long double); +extern long double __sqrtl(long double); +extern long double __tanl(long double); +extern long double __tanhl(long double); +} +#endif + +#if defined (__BORLANDC__) +# define _STLP_CMATH_FUNC_NAMESPACE _STLP_VENDOR_CSTD +#else +# define _STLP_CMATH_FUNC_NAMESPACE +#endif + +#if !defined (__sun) || defined (__GNUC__) +# define _STLP_MATH_INLINE(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x); } +# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_CMATH_FUNC_NAMESPACE::cfunc(x, y); } +# define _STLP_MATH_INLINE_D(float_type, func, cfunc) +# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) +#else +# ifdef __SUNPRO_CC +# define _STLP_MATH_INLINE(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::__##cfunc(x); } +# define _STLP_MATH_INLINE_D(float_type, func, cfunc) \ + inline float_type func (float_type x) { return _STLP_VENDOR_CSTD::cfunc(x); } +# define _STLP_MATH_INLINE2(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::__##cfunc(x,y); } +# define _STLP_MATH_INLINE2_D(float_type, type, func, cfunc) \ + inline float_type func (float_type x, type y) { return _STLP_VENDOR_CSTD::cfunc(x,y); } +# else +# error Unknown compiler for the Sun platform +# endif +#endif + +/** macros to define math functions +These macros (having an X somewhere in the name) forward to the C library's +double functions but cast the arguments and return values to the given type. */ + +#define _STLP_MATH_INLINEX(__type,func,cfunc) \ + inline __type func (__type x) \ + { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x)); } +#define _STLP_MATH_INLINE2X(__type1,__type2,func,cfunc) \ + inline __type1 func (__type1 x, __type2 y) \ + { return __STATIC_CAST(__type1, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, y)); } +#define _STLP_MATH_INLINE2PX(__type,func,cfunc) \ + inline __type func (__type x, __type *y) { \ + double tmp1, tmp2; \ + tmp1 = _STLP_CMATH_FUNC_NAMESPACE::cfunc(__STATIC_CAST(double, x), &tmp2); \ + *y = __STATIC_CAST(__type, tmp2); \ + return __STATIC_CAST(__type, tmp1); \ + } +#define _STLP_MATH_INLINE2XX(__type,func,cfunc) \ + inline __type func (__type x, __type y) \ + { return __STATIC_CAST(__type, _STLP_CMATH_FUNC_NAMESPACE::cfunc((double)x, (double)y)); } + + +/** rough characterization of compiler and native C library +For the compiler, it can either support long double or not. If it doesn't, the +macro _STLP_NO_LONG_DOUBLE is not defined and we don't define any long double +overloads. +For the native C library the question is whether it has variants with an 'f' +suffix (for float as opposed to double) or an 'l' suffix (for long double). If +the float variants are missing, _STLP_NO_VENDOR_MATH_F is defined, when the +long double variants are missing, _STLP_NO_VENDOR_MATH_L is defined. Of course +the latter doesn't make sense anyway when the compiler already has no long +double support. + +Those two traits determine a) which overloads get defined and b) how they are +defined. + +Meaning of suffixes: +"" : function returning and taking a float_type +"2" : function returning a float_type and taking to float_types +"2P" : function returning a float_type and taking a float_type and a float_type* +"2PI": function returning a float_type and taking a float_type and an int* +"2I" : function returning a float_type and taking a float_Type and an int +*/ + +#if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_NO_VENDOR_MATH_L) && !defined (_STLP_NO_VENDOR_MATH_F) + // long double support and both e.g. sinl(long double) and sinf(float) + // This is the default for a correct and complete native library. +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) \ + _STLP_MATH_INLINE_D(double,func,cf) \ + _STLP_MATH_INLINE(long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,double,func,cf) \ + _STLP_MATH_INLINE2(long double,long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,double *,func,cf) \ + _STLP_MATH_INLINE2(long double,long double *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,int *,func,cf) \ + _STLP_MATH_INLINE2(long double,int *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) \ + _STLP_MATH_INLINE2_D(double,int,func,cf) \ + _STLP_MATH_INLINE2(long double,int,func,cf##l) +#else +# if !defined (_STLP_NO_LONG_DOUBLE) +# if !defined (_STLP_NO_VENDOR_MATH_F) + // long double support and e.g. sinf(float) but not e.g. sinl(long double) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) \ + _STLP_MATH_INLINEX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) \ + _STLP_MATH_INLINE2XX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) \ + _STLP_MATH_INLINE2PX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) \ + _STLP_MATH_INLINE2X(long double,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) \ + _STLP_MATH_INLINE2X(long double,int,func,cf) +# elif !defined (_STLP_NO_VENDOR_MATH_L) + // long double support and e.g. sinl(long double) but not e.g. sinf(float) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) \ + _STLP_MATH_INLINE(long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) \ + _STLP_MATH_INLINE2(long double,long double,func,cf##l) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) \ + _STLP_MATH_INLINE2(long double,long double *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) \ + _STLP_MATH_INLINE2(long double,int *,func,cf##l) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) \ + _STLP_MATH_INLINE2(long double,int,func,cf##l) +# else +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) \ + _STLP_MATH_INLINEX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) \ + _STLP_MATH_INLINE2XX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) \ + _STLP_MATH_INLINE2PX(long double,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) \ + _STLP_MATH_INLINE2X(long double,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) \ + _STLP_MATH_INLINE2X(long double,int,func,cf) +# endif +# else +# if !defined (_STLP_NO_VENDOR_MATH_F) +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINE(float,func,cf##f) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2(float,float,func,cf##f) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2(float,float *,func,cf##f) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2(float,int *,func,cf##f) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2(float,int,func,cf##f) +# else // _STLP_NO_VENDOR_MATH_F + // neither long double support nor e.g. sinf(float) functions +# define _STLP_DEF_MATH_INLINE(func,cf) \ + _STLP_MATH_INLINEX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2(func,cf) \ + _STLP_MATH_INLINE2XX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2P(func,cf) \ + _STLP_MATH_INLINE2PX(float,func,cf) +# define _STLP_DEF_MATH_INLINE2PI(func,cf) \ + _STLP_MATH_INLINE2X(float,int *,func,cf) +# define _STLP_DEF_MATH_INLINE2I(func,cf) \ + _STLP_MATH_INLINE2X(float,int,func,cf) +# endif // _STLP_NO_VENDOR_MATH_F +# endif +#endif + +#if defined (_STLP_WCE) || \ + (defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) && defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */) +/* + * dums: VC6 has all the required C++ functions but only define them if + * _MSC_EXTENSIONS is not defined (a bug?). STLport just do the same + * thing also when _MSC_EXTENSIONS is defined. + * TODO: above check (_STLP_MSVC <= 1300) also catches VC7.0, is that intended? + */ +//We have to tell the compilers that abs, acos ... math functions are not intrinsic +//otherwise we have Internal Compiler Error in release mode... +# pragma warning(push) +# pragma warning(disable: 4162) // no function with C linkage found +# pragma warning(disable: 4163) // not available as an intrinsic function +# pragma function (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh) +# if defined (_STLP_WCE) +# pragma function (ceil, floor) +# endif +# define _STLP_RESTORE_FUNCTION_INTRINSIC +#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS + +#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS) +/* In this config Borland native lib only define functions in std namespace. + * In order to have all overloads in STLport namespace we need to add the + * double overload in global namespace. We do not use a using statement to avoid + * import of invalid overload. + */ +# define _STLP_DMATH_INLINE(func) _STLP_MATH_INLINE(double, func, func) +# define _STLP_DMATH_INLINE2(func) _STLP_MATH_INLINE2(double, double, func, func) + +_STLP_DMATH_INLINE(acos) +_STLP_DMATH_INLINE(asin) +_STLP_DMATH_INLINE(atan) +_STLP_DMATH_INLINE2(atan2) +_STLP_DMATH_INLINE(ceil) +_STLP_DMATH_INLINE(cos) +_STLP_DMATH_INLINE(cosh) +_STLP_DMATH_INLINE(exp) +_STLP_DMATH_INLINE(fabs) +_STLP_DMATH_INLINE(floor) +_STLP_DMATH_INLINE2(fmod) +_STLP_MATH_INLINE2X(double, int*, frexp, frexp) +_STLP_MATH_INLINE2X(double, int, ldexp, ldexp) +_STLP_DMATH_INLINE(log) +_STLP_DMATH_INLINE(log10) +_STLP_MATH_INLINE2PX(double, modf, modf) +_STLP_DMATH_INLINE(sin) +_STLP_DMATH_INLINE(sinh) +_STLP_DMATH_INLINE(sqrt) +_STLP_DMATH_INLINE(tan) +_STLP_DMATH_INLINE(tanh) +_STLP_DMATH_INLINE2(pow) +_STLP_DMATH_INLINE2(hypot) + +# undef _STLP_DMATH_INLINE +# undef _STLP_DMATH_INLINE2 +#endif + +#if defined (__DMC__) +# if defined (fabs) +inline double __stlp_fabs(double __x) { return fabs(__x); } +# undef fabs +inline double fabs(double __x) { return __stlp_fabs(__x); } +# endif +# if defined (cos) +inline double __stlp_cos(double __x) { return cos(__x); } +# undef cos +inline double cos(double __x) { return __stlp_cos(__x); } +# endif +# if defined (sin) +inline double __stlp_sin(double __x) { return sin(__x); } +# undef sin +inline double sin(double __x) { return __stlp_sin(__x); } +# endif +# if defined (sqrt) +inline double __stlp_sqrt(double __x) { return sqrt(__x); } +# undef sqrt +inline double sqrt(double __x) { return __stlp_sqrt(__x); } +# endif +# if defined (ldexp) +inline double __stlp_ldexp(double __x, int __y) { return ldexp(__x, __y); } +# undef ldexp +inline double ldexp(double __x, int __y) { return __stlp_ldexp(__x, __y); } +# endif +#endif + +/* MSVC native lib starting with .Net 2003 has already all math functions + * in global namespace. + * HP-UX native lib has math functions in the global namespace. + */ +#if (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)) && \ + (!defined (__HP_aCC) || (__HP_aCC < 30000)) && \ + !defined (__WATCOMC__) && \ + !defined (ANDROID) +inline double abs(double __x) +{ return ::fabs(__x); } +# if !defined (__MVS__) +_STLP_DEF_MATH_INLINE(abs, fabs) +# else // __MVS__ has native long double abs? +inline float abs(float __x) { return ::fabsf(__x); } +# endif + +_STLP_DEF_MATH_INLINE(acos, acos) +_STLP_DEF_MATH_INLINE(asin, asin) +_STLP_DEF_MATH_INLINE(atan, atan) +_STLP_DEF_MATH_INLINE2(atan2, atan2) +_STLP_DEF_MATH_INLINE(ceil, ceil) +_STLP_DEF_MATH_INLINE(cos, cos) +_STLP_DEF_MATH_INLINE(cosh, cosh) +_STLP_DEF_MATH_INLINE(exp, exp) +_STLP_DEF_MATH_INLINE(fabs, fabs) +_STLP_DEF_MATH_INLINE(floor, floor) +_STLP_DEF_MATH_INLINE2(fmod, fmod) +_STLP_DEF_MATH_INLINE2PI(frexp, frexp) +_STLP_DEF_MATH_INLINE2I(ldexp, ldexp) +_STLP_DEF_MATH_INLINE(log, log) +_STLP_DEF_MATH_INLINE(log10, log10) +_STLP_DEF_MATH_INLINE2P(modf, modf) +_STLP_DEF_MATH_INLINE(sin, sin) +_STLP_DEF_MATH_INLINE(sinh, sinh) +_STLP_DEF_MATH_INLINE(sqrt, sqrt) +_STLP_DEF_MATH_INLINE(tan, tan) +_STLP_DEF_MATH_INLINE(tanh, tanh) +_STLP_DEF_MATH_INLINE2(pow, pow) + +# if !defined(_STLP_MSVC) /* || (_STLP_MSVC > 1300) */ || defined(_STLP_WCE) || !defined (_MSC_EXTENSIONS) /* && !defined(_STLP_WCE_NET) */ +# ifndef _STLP_NO_VENDOR_MATH_F +# ifndef __sun +inline float pow(float __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powf(__x, __STATIC_CAST(float,__y)); } +# else +inline float pow(float __x, int __y) { return ::__powf(__x, __STATIC_CAST(float,__y)); } +# endif +# else +inline float pow(float __x, int __y) { return __STATIC_CAST(float, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(float,__y))); } +# endif +inline double pow(double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(double,__y)); } +# if !defined (_STLP_NO_LONG_DOUBLE) +# if !defined(_STLP_NO_VENDOR_MATH_L) +# ifndef __sun +inline long double pow(long double __x, int __y) { return _STLP_CMATH_FUNC_NAMESPACE::powl(__x, __STATIC_CAST(long double,__y)); } +# else +# ifndef __SUNPRO_CC +inline long double pow(long double __x, int __y) { return ::__powl(__x, __STATIC_CAST(long double,__y)); } +# else +inline long double pow(long double __x, int __y) { return _STLP_VENDOR_CSTD::__powl(__x, __STATIC_CAST(long double,__y)); } +# endif +# endif +# else +inline long double pow(long double __x, int __y) { return __STATIC_CAST(long double, _STLP_CMATH_FUNC_NAMESPACE::pow(__x, __STATIC_CAST(long double,__y))); } +# endif +# endif +# else +//The MS native pow version has a bugged overload so it is not imported +//in the STLport namespace. +//Here is the bugged version: +//inline double pow(int __x, int __y) { return (_Pow_int(__x, __y)); } +inline double pow(double __x, int __y) { return (_Pow_int(__x, __y)); } +inline float pow(float __x, int __y) { return (_Pow_int(__x, __y)); } +inline long double pow(long double __x, int __y) { return (_Pow_int(__x, __y)); } +# endif +#endif + +#if (defined (_STLP_MSVC) && !defined (_STLP_WCE)) || defined (__ICL) || defined (__sun) +# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400) +# pragma warning (push) +# pragma warning (disable : 4996) // hypot is deprecated. +# endif +_STLP_MATH_INLINE2XX(float, hypot, hypot) +inline long double hypot(long double x, long double y) { return sqrt(x * x + y * y); } +# if defined (_STLP_MSVC) && (_STLP_MSVC >= 1400) +# pragma warning (pop) +# endif +#else +# if defined (_STLP_USE_UCLIBC) +inline double hypot(double x, double y) { return sqrt(x * x + y * y); } +_STLP_DEF_MATH_INLINE2(hypot, hypot) +# elif defined (_STLP_WCE) + /* CE has a double _hypot(double,double) which we use */ +inline double hypot(double __x, double __y) { return _hypot(__x,__y); } +_STLP_DEF_MATH_INLINE2(hypot, _hypot) +# endif +#endif + +#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC) +//restoration of the default intrinsic status of those functions: +# pragma intrinsic (abs, acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, sqrt, tan, tanh) +# if defined (_STLP_WCE) +# pragma intrinsic (ceil, floor) +# endif +# pragma warning(pop) +# undef _STLP_RESTORE_FUNCTION_INTRINSIC +#endif // _STLP_MSVC && _STLP_MSVC <= 1300 && !_STLP_WCE && _MSC_EXTENSIONS + +/* C++ Standard is unclear about several call to 'using ::func' if new overloads + * of ::func appears between 2 successive 'using' calls. To avoid this potential + * problem we provide all abs overload before the 'using' call. + * Beware: This header inclusion has to be after all abs overload of this file. + * The first 'using ::abs' call is going to be in the other header. + */ +#ifndef _STLP_INTERNAL_CSTDLIB +# include <stl/_cstdlib.h> +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +_STLP_BEGIN_NAMESPACE +using ::abs; +using ::acos; +using ::asin; +using ::atan; +using ::atan2; +using ::ceil; +using ::cos; +using ::cosh; +using ::exp; +using ::fabs; +using ::floor; +using ::fmod; +using ::frexp; +/* + Because of some weird interaction between STLport headers + and native HP-UX headers, when compiled with _STLP_DEBUG + macro defined with aC++, hypot() is not declared. + At some point we'll need to get to the bottom line of + this problem. +*/ +#if !(defined(__HP_aCC) && defined(_STLP_DEBUG)) +using ::hypot; +#endif +using ::ldexp; +using ::log; +using ::log10; +using ::modf; +using ::pow; +using ::sin; +using ::sinh; +using ::sqrt; +using ::tan; +using ::tanh; +_STLP_END_NAMESPACE +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x560) && !defined (__linux__) +using _STLP_VENDOR_CSTD::_ecvt; +using _STLP_VENDOR_CSTD::_fcvt; +# endif +#endif + +#endif /* _STLP_INTERNAL_CMATH */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_config_compat_post.h b/stlport/stlport/stl/_config_compat_post.h new file mode 100644 index 0000000..e3b4111 --- /dev/null +++ b/stlport/stlport/stl/_config_compat_post.h @@ -0,0 +1,51 @@ +/*========================================== */ +#if 1 /* def _STLP_3_COMPATIBILITY */ + +# define __SGI_STL_PORT _STLPORT_VERSION + +# if defined (_STLP_DEBUG) && ! defined ( __STL_DEBUG ) +# define __STL_DEBUG _STLP_DEBUG +# endif + +# if defined (_STLP_USE_NAMESPACES) +# undef __STL_USE_NAMESPACES +# define __STL_USE_NAMESPACES _STLP_USE_NAMESPACES +# endif + +# if defined (_STLP_USE_EXCEPTIONS) +# undef __STL_USE_EXCEPTIONS +# define __STL_USE_EXCEPTIONS _STLP_USE_EXCEPTIONS +# endif + +# if defined (_STLP_BEGIN_NAMESPACE) && ! defined ( __STL_BEGIN_NAMESPACE ) +# define __STL_BEGIN_NAMESPACE _STLP_BEGIN_NAMESPACE +# define __STL_END_NAMESPACE _STLP_END_NAMESPACE +# define __STL_VENDOR_STD _STLP_VENDOR_STD +# define __STL_VENDOR_CSTD _STLP_VENDOR_CSTD +# endif +# endif + +/* +# if defined (_STLP_XXX) && ! defined ( __STL_XXX ) +# define __STL_XXX _STLP_XXX +# endif +*/ + +/* 5.0 -> 4.6 compatibility section */ +#if 1 /* def _STLP_46_COMPATIBILITY */ + +/* provide a uniform way to access full functionality */ +# define __slist__ slist +# define __map__ map +# define __multimap__ multimap +# define __set__ set +# define __multiset__ multiset +# define __list__ list +# define __hash_map__ hash_map +# define __hash_multimap__ hash_multimap +# define __hash_set__ hash_set +# define __hash_multiset__ hash_multiset +# define __vector__ vector + +#endif + diff --git a/stlport/stlport/stl/_construct.h b/stlport/stlport/stl/_construct.h new file mode 100644 index 0000000..9361878 --- /dev/null +++ b/stlport/stlport/stl/_construct.h @@ -0,0 +1,289 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +#define _STLP_INTERNAL_CONSTRUCT_H + +#if !defined (_STLP_DEBUG_UNINITIALIZED) && !defined (_STLP_INTERNAL_CSTRING) +# include <stl/_cstring.h> +#endif + +#ifndef _STLP_INTERNAL_NEW +# include <stl/_new.h> +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include <stl/_iterator_base.h> +#endif + +#ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +#endif + +#if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC) +# include <stl/_move_construct_fwk.h> +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _Tp> +inline void __destroy_aux(_Tp* __pointer, const __false_type& /*_Trivial_destructor*/) +{ __pointer->~_Tp(); } + +template <class _Tp> +inline void __destroy_aux(_Tp*, const __true_type& /*_Trivial_destructor*/) {} + +template <class _Tp> +inline void _Destroy(_Tp* __pointer) { + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; + __destroy_aux(__pointer, _Trivial_destructor()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset(__REINTERPRET_CAST(char*, __pointer), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif +} + +template <class _Tp> +inline void _Destroy_Moved(_Tp* __pointer) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::complete _Trivial_destructor; + __destroy_aux(__pointer, _Trivial_destructor()); +# if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__pointer, _STLP_SHRED_BYTE, sizeof(_Tp)); +# endif +#else + _Destroy(__pointer); +#endif +} + +#if defined (new) +# define _STLP_NEW_REDEFINE new +# undef new +#endif + +template <class _T1> +inline void _Construct_aux (_T1* __p, const __false_type&) { + new(__p) _T1(); +} + +template <class _T1> +inline void _Construct_aux (_T1* __p, const __true_type&) { +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) + *__p = _T1(0); +#else + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(); +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ +} + +template <class _T1> +inline void _Construct(_T1* __p) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif +#if defined (_STLP_DEF_CONST_PLCT_NEW_BUG) + _Construct_aux (__p, _HasDefaultZeroValue(__p)._Answer()); +#else + _Construct_aux (__p, _Is_POD(__p)._Answer()); +#endif /* _STLP_DEF_CONST_PLCT_NEW_BUG */ +} + +template <class _Tp> +inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __false_type&) { + new(__p) _Tp(__val); +} + +template <class _Tp> +inline void _Copy_Construct_aux(_Tp* __p, const _Tp& __val, const __true_type&) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = __val; +} + +template <class _Tp> +inline void _Copy_Construct(_Tp* __p, const _Tp& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + _Copy_Construct_aux(__p, __val, _Is_POD(__p)._Answer()); +} + +template <class _T1, class _T2> +inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __false_type&) { + new(__p) _T1(__val); +} + +template <class _T1, class _T2> +inline void _Param_Construct_aux(_T1* __p, const _T2& __val, const __true_type&) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(__val); +} + +template <class _T1, class _T2> +inline void _Param_Construct(_T1* __p, const _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _Param_Construct_aux(__p, __val, _Is_POD(__p)._Answer()); +} + +template <class _T1, class _T2> +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __false_type& /*_IsPOD*/) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + new(__p) _T1(_STLP_PRIV _AsMoveSource(__val)); +#else + _Param_Construct(__p, __val); +#endif +} + +template <class _T1, class _T2> +inline void _Move_Construct_Aux(_T1* __p, _T2& __val, const __true_type& /*_IsPOD*/) { + // We use binary copying for POD types since it results + // in a considerably better code at least on MSVC. + *__p = _T1(__val); +} + +template <class _T1, class _T2> +inline void _Move_Construct(_T1* __p, _T2& __val) { +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)__p, _STLP_SHRED_BYTE, sizeof(_T1)); +#endif + _Move_Construct_Aux(__p, __val, _Is_POD(__p)._Answer()); +} + +#if defined(_STLP_NEW_REDEFINE) +# if defined (DEBUG_NEW) +# define new DEBUG_NEW +# endif +# undef _STLP_NEW_REDEFINE +#endif + +template <class _ForwardIterator, class _Tp> +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __false_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) { + __destroy_aux(&(*__first), __false_type()); +#if defined (_STLP_DEBUG_UNINITIALIZED) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +#endif + } +} + +template <class _ForwardIterator, class _Tp> +#if defined (_STLP_DEBUG_UNINITIALIZED) +_STLP_INLINE_LOOP void +__destroy_range_aux(_ForwardIterator __first, _ForwardIterator __last, _Tp*, const __true_type& /*_Trivial_destructor*/) { + for ( ; __first != __last; ++__first) + memset((char*)&(*__first), _STLP_SHRED_BYTE, sizeof(_Tp)); +} +#else +inline void +__destroy_range_aux(_ForwardIterator, _ForwardIterator, _Tp*, const __true_type& /*_Trivial_destructor*/) {} +#endif + +template <class _ForwardIterator, class _Tp> +inline void +__destroy_range(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { + typedef typename __type_traits<_Tp>::has_trivial_destructor _Trivial_destructor; + __destroy_range_aux(__first, __last, __ptr, _Trivial_destructor()); +} + +template <class _ForwardIterator> +inline void _Destroy_Range(_ForwardIterator __first, _ForwardIterator __last) { + __destroy_range(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); +} + +inline void _Destroy_Range(char*, char*) {} +#if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97 +inline void _Destroy_Range(wchar_t*, wchar_t*) {} +inline void _Destroy_Range(const wchar_t*, const wchar_t*) {} +#endif + +#if !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _ForwardIterator, class _Tp> +inline void +__destroy_mv_srcs(_ForwardIterator __first, _ForwardIterator __last, _Tp *__ptr) { + typedef typename __move_traits<_Tp>::complete _CompleteMove; + __destroy_range_aux(__first, __last, __ptr, _CompleteMove()); +} +#endif + +template <class _ForwardIterator> +inline void _Destroy_Moved_Range(_ForwardIterator __first, _ForwardIterator __last) +#if !defined (_STLP_NO_MOVE_SEMANTIC) +{ __destroy_mv_srcs(__first, __last, _STLP_VALUE_TYPE(__first, _ForwardIterator)); } +#else +{ _Destroy_Range(__first, __last); } +#endif + +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG) +// Those adaptors are here to fix common compiler bug regarding builtins: +// expressions like int k = int() should initialize k to 0 +template <class _Tp> +inline _Tp __default_constructed_aux(_Tp*, const __false_type&) { + return _Tp(); +} +template <class _Tp> +inline _Tp __default_constructed_aux(_Tp*, const __true_type&) { + return _Tp(0); +} + +template <class _Tp> +inline _Tp __default_constructed(_Tp* __p) { + return __default_constructed_aux(__p, _HasDefaultZeroValue(__p)._Answer()); +} + +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) __default_constructed((_TTp*)0) +#else +# define _STLP_DEFAULT_CONSTRUCTED(_TTp) _TTp() +#endif /* _STLP_DEF_CONST_DEF_PARAM_BUG */ + + +#if !defined (_STLP_NO_ANACHRONISMS) +// -------------------------------------------------- +// Old names from the HP STL. + +template <class _T1, class _T2> +inline void construct(_T1* __p, const _T2& __val) {_Param_Construct(__p, __val); } +template <class _T1> +inline void construct(_T1* __p) { _STLP_STD::_Construct(__p); } +template <class _Tp> +inline void destroy(_Tp* __pointer) { _STLP_STD::_Destroy(__pointer); } +template <class _ForwardIterator> +inline void destroy(_ForwardIterator __first, _ForwardIterator __last) { _STLP_STD::_Destroy_Range(__first, __last); } +#endif /* _STLP_NO_ANACHRONISMS */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_CONSTRUCT_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_cprolog.h b/stlport/stlport/stl/_cprolog.h new file mode 100644 index 0000000..1d27656 --- /dev/null +++ b/stlport/stlport/stl/_cprolog.h @@ -0,0 +1,25 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#ifdef std +# undef std /* We undef "std" on entry , as STLport headers may include native ones. */ +#endif + +#ifdef _STLP_PROLOG_HEADER_INCLUDED +# error STlport prolog header can not be reincluded as long as epilog has not be included. +#endif + +#define _STLP_PROLOG_HEADER_INCLUDED + +#ifndef _STLP_FEATURES_H +# include <stl/config/features.h> +#endif + +/* If the platform provides any specific prolog actions, + * like #pragmas, do include platform-specific prolog file */ +#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) +# include <stl/config/_prolog.h> +#endif diff --git a/stlport/stlport/stl/_cstdarg.h b/stlport/stlport/stl/_cstdarg.h new file mode 100644 index 0000000..e98f31c --- /dev/null +++ b/stlport/stlport/stl/_cstdarg.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#ifndef _STLP_INTERNAL_CSTDARG +#define _STLP_INTERNAL_CSTDARG + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstdarg> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdarg) +# endif +#else +# include <stdarg.h> +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::va_list; +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif diff --git a/stlport/stlport/stl/_cstddef.h b/stlport/stlport/stl/_cstddef.h new file mode 100644 index 0000000..35a585c --- /dev/null +++ b/stlport/stlport/stl/_cstddef.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTDDEF +#define _STLP_INTERNAL_CSTDDEF + +# if (__GNUC__ >= 3) && defined (__CYGWIN__) // this total HACK is the only expedient way I could cygwin to work with GCC 3.0 +# define __need_wint_t // mostly because wint_t didn't seem to get defined otherwise :( +# define __need_wchar_t +# define __need_size_t +# define __need_ptrdiff_t +# define __need_NULL +# endif + +# if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstddef> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstddef) +# endif +# else +# include <stddef.h> +# endif + +# ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::ptrdiff_t; +using _STLP_VENDOR_CSTD::size_t; +_STLP_END_NAMESPACE +# endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif /* _STLP_INTERNAL_CSTDDEF */ diff --git a/stlport/stlport/stl/_cstdio.h b/stlport/stlport/stl/_cstdio.h new file mode 100644 index 0000000..67236f2 --- /dev/null +++ b/stlport/stlport/stl/_cstdio.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTDIO +#define _STLP_INTERNAL_CSTDIO + +#if defined (__Lynx__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <stdarg.h> +# else +# include _STLP_NATIVE_C_HEADER(stdarg.h) +# endif +#endif + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstdio> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdio) +# endif +#else +# include <stdio.h> +#endif + +#if defined (__MWERKS__) +# undef stdin +# undef stdout +# undef stderr +# define stdin (&_STLP_VENDOR_CSTD::__files[0]) +# define stdout (&_STLP_VENDOR_CSTD::__files[1]) +# define stderr (&_STLP_VENDOR_CSTD::__files[2]) +#endif + +#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) +inline int vsnprintf(char *s1, size_t n, const char *s2, va_list v) +{ return _STLP_VENDOR_CSTD::_vsnprintf(s1, n, s2, v); } +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD ) +_STLP_BEGIN_NAMESPACE +using _STLP_VENDOR_CSTD::FILE; +using _STLP_VENDOR_CSTD::fpos_t; +using _STLP_VENDOR_CSTD::size_t; + +// undef obsolete macros +# undef putc +# undef getc +# undef getchar +# undef putchar +# undef feof +# undef ferror + +# if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +using _STLP_VENDOR_CSTD::clearerr; +using _STLP_VENDOR_CSTD::fclose; +using _STLP_VENDOR_CSTD::feof; +using _STLP_VENDOR_CSTD::ferror; +using _STLP_VENDOR_CSTD::fflush; +using _STLP_VENDOR_CSTD::fgetc; +using _STLP_VENDOR_CSTD::fgetpos; +using _STLP_VENDOR_CSTD::fgets; +using _STLP_VENDOR_CSTD::fopen; +using _STLP_VENDOR_CSTD::fprintf; +using _STLP_VENDOR_CSTD::fputc; +using _STLP_VENDOR_CSTD::fputs; +using _STLP_VENDOR_CSTD::fread; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::freopen; +# endif +using _STLP_VENDOR_CSTD::fscanf; +using _STLP_VENDOR_CSTD::fseek; +using _STLP_VENDOR_CSTD::fsetpos; +using _STLP_VENDOR_CSTD::ftell; +using _STLP_VENDOR_CSTD::fwrite; + +# if !(defined (__IBMCPP__) && (__IBMCPP__ >= 500)) +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) // Supplied as macros, TODO: use inline function to redirect to the macros? + using _STLP_VENDOR_CSTD::getc; + using _STLP_VENDOR_CSTD::putc; +# endif + using _STLP_VENDOR_CSTD::getchar; + using _STLP_VENDOR_CSTD::putchar; +# endif + +using _STLP_VENDOR_CSTD::gets; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::perror; +# endif +using _STLP_VENDOR_CSTD::printf; +using _STLP_VENDOR_CSTD::puts; +# if !defined (_WIN32_WCE) || (_WIN32_WCE < 400) +using _STLP_VENDOR_CSTD::remove; +using _STLP_VENDOR_CSTD::rename; +using _STLP_VENDOR_CSTD::rewind; +using _STLP_VENDOR_CSTD::setbuf; +using _STLP_VENDOR_CSTD::tmpfile; +using _STLP_VENDOR_CSTD::tmpnam; +# endif +using _STLP_VENDOR_CSTD::scanf; +using _STLP_VENDOR_CSTD::setvbuf; +using _STLP_VENDOR_CSTD::sprintf; +using _STLP_VENDOR_CSTD::sscanf; +using _STLP_VENDOR_CSTD::ungetc; +using _STLP_VENDOR_CSTD::vfprintf; +using _STLP_VENDOR_CSTD::vprintf; +using _STLP_VENDOR_CSTD::vsprintf; +# if (defined (__MWERKS__) || (defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB < 1400)) || \ + (defined (__BORLANDC__))) +using _STLP_VENDOR_CSTD::vsnprintf; +# endif +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif /* _STLP_INTERNAL_CSTDIO */ diff --git a/stlport/stlport/stl/_cstdlib.h b/stlport/stlport/stl/_cstdlib.h new file mode 100755 index 0000000..a6bb6be --- /dev/null +++ b/stlport/stlport/stl/_cstdlib.h @@ -0,0 +1,195 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + */ + +#ifndef _STLP_INTERNAL_CSTDLIB +#define _STLP_INTERNAL_CSTDLIB + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstdlib> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +# endif +#else +# include <stdlib.h> +#endif + +#if defined (__BORLANDC__) && !defined (__linux__) +/* Borland process.h header do not bring anything here and is just included + * in order to avoid inclusion later. This header cannot be included later + * because Borland compiler consider that for instance the abort function + * defined as extern "C" cannot be overloaded and it finds 2 "overloads", + * once in native std namespace and the other in STLport namespace... + */ +# include <process.h> +#endif + +/* on evc3/evc4 including stdlib.h also defines setjmp macro */ +#if defined (_STLP_WCE) +# define _STLP_NATIVE_SETJMP_H_INCLUDED +#endif + +#if defined (__MSL__) && (__MSL__ <= 0x5003) +namespace std { + typedef ::div_t div_t; + typedef ::ldiv_t ldiv_t; +# ifdef __MSL_LONGLONG_SUPPORT__ + typedef ::lldiv_t lldiv_t; +# endif +} +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +# if !defined (ANDROID) +using _STLP_VENDOR_CSTD::div_t; +using _STLP_VENDOR_CSTD::ldiv_t; +# endif +using _STLP_VENDOR_CSTD::size_t; + +# ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS +# ifndef _STLP_WCE +// these functions just don't exist on Windows CE +using _STLP_VENDOR_CSTD::abort; +using _STLP_VENDOR_CSTD::getenv; +# if !defined (ANDROID) +using _STLP_VENDOR_CSTD::mblen; +using _STLP_VENDOR_CSTD::mbtowc; +using _STLP_VENDOR_CSTD::system; +using _STLP_VENDOR_CSTD::bsearch; +# endif +# endif +using _STLP_VENDOR_CSTD::atexit; +using _STLP_VENDOR_CSTD::exit; +using _STLP_VENDOR_CSTD::calloc; +using _STLP_VENDOR_CSTD::free; +using _STLP_VENDOR_CSTD::malloc; +using _STLP_VENDOR_CSTD::realloc; +using _STLP_VENDOR_CSTD::atof; +using _STLP_VENDOR_CSTD::atoi; +using _STLP_VENDOR_CSTD::atol; +using _STLP_VENDOR_CSTD::mbstowcs; +using _STLP_VENDOR_CSTD::strtod; +using _STLP_VENDOR_CSTD::strtol; +using _STLP_VENDOR_CSTD::strtoul; + +# if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_NATIVE_MBSTATE_T)) +using _STLP_VENDOR_CSTD::wcstombs; +# ifndef _STLP_WCE +using _STLP_VENDOR_CSTD::wctomb; +# endif +# endif +using _STLP_VENDOR_CSTD::qsort; +using _STLP_VENDOR_CSTD::labs; +# if !defined (ANDROID) +using _STLP_VENDOR_CSTD::ldiv; +# endif +# if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L) +# if !defined(__sun) +using _STLP_VENDOR_CSTD::llabs; +# if !defined (ANDROID) +using _STLP_VENDOR_CSTD::lldiv_t; +using _STLP_VENDOR_CSTD::lldiv; +# endif +# else +using ::llabs; +using ::lldiv_t; +using ::lldiv; +# endif +# endif +using _STLP_VENDOR_CSTD::rand; +using _STLP_VENDOR_CSTD::srand; +# endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS) +//In this config bcc define everything in std namespace and not in +//the global one. +inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); } +inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); } +#endif + +#if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300) +# define _STLP_RESTORE_FUNCTION_INTRINSIC +# pragma warning (push) +# pragma warning (disable: 4162) +# pragma function (abs) +#endif + +//HP-UX native lib has abs() and div() functions in global namespace +#if !defined (__SUNPRO_CC) && \ + (!defined (__HP_aCC) || (__HP_aCC < 30000)) + +//MSVC starting with .Net 2003 already define all math functions in global namespace: +# if !defined (__WATCOMC__) && \ + !defined (ANDROID) && \ + (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined (UNDER_CE)) +inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); } +# endif + +/** VC since version 8 has this, the platform SDK and CE SDKs hanging behind. */ +# if !defined (__WATCOMC__) && \ + !defined (ANDROID) && \ + (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined (UNDER_CE)) +inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); } +# endif + +#endif + +#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC) +# pragma intrinsic (abs) +# pragma warning (pop) +# undef _STLP_RESTORE_FUNCTION_INTRINSIC +#endif + +#if defined (_STLP_LONG_LONG) +# if !defined (_STLP_NO_VENDOR_STDLIB_L) +# if !defined (__sun) +# if !defined (ANDROID) +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); } +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); } +# endif +# else +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return ::llabs(__x); } +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); } +# endif +# else +inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; } +# endif +#endif + +/* C++ Standard is unclear about several call to 'using ::func' if new overloads + * of ::func appears between 2 successive 'using' calls. To avoid this potential + * problem we provide all abs overload before the 'using' call. + * Beware: This header inclusion has to be after all abs overload of this file. + * The first 'using ::abs' call is going to be in the other header. + */ +#ifndef _STLP_INTERNAL_CMATH +# include <stl/_cmath.h> +#endif + +#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +// ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05 +_STLP_BEGIN_NAMESPACE +# if !defined (ANDROID) +using ::abs; +using ::div; +# endif +_STLP_END_NAMESPACE +#endif + +#endif /* _STLP_INTERNAL_CSTDLIB */ diff --git a/stlport/stlport/stl/_cstring.h b/stlport/stlport/stl/_cstring.h new file mode 100644 index 0000000..fe0fd5f --- /dev/null +++ b/stlport/stlport/stl/_cstring.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_CSTRING +#define _STLP_INTERNAL_CSTRING + +#if defined (_STLP_USE_NEW_C_HEADERS) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <cstring> +# else +# include _STLP_NATIVE_CPP_C_HEADER(cstring) +# endif +#else +# include <string.h> +#endif + +#ifdef _STLP_IMPORT_VENDOR_CSTD +_STLP_BEGIN_NAMESPACE +# include <using/cstring> +_STLP_END_NAMESPACE +#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#endif /* _STLP_INTERNAL_CSTRING */ diff --git a/stlport/stlport/stl/_epilog.h b/stlport/stlport/stl/_epilog.h new file mode 100644 index 0000000..0747ae3 --- /dev/null +++ b/stlport/stlport/stl/_epilog.h @@ -0,0 +1,42 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#ifndef _STLP_PROLOG_HEADER_INCLUDED +# error STLport epilog header can not be included as long as prolog has not be included. +#endif + +/* If the platform provides any specific epilog actions, + * like #pragmas, do include platform-specific prolog file + */ +#if defined (_STLP_HAS_SPECIFIC_PROLOG_EPILOG) +# include <stl/config/_epilog.h> +#endif + +#if !defined (_STLP_NO_POST_COMPATIBLE_SECTION) +# include <stl/_config_compat_post.h> +#endif + +#if defined (_STLP_USE_OWN_NAMESPACE) + +# if !defined (_STLP_DONT_REDEFINE_STD) +/* We redefine "std" to STLPORT, so that user code may use std:: transparently + * The STLPORT macro contains the STLport namespace name containing all the std + * stuff. + */ +# if defined (std) +/* + * Looks like the compiler native library on which STLport rely defined the std macro. + * This might introduce major incompatibility so report the problem to the STLport + * forum or comment the following #error at your own risk. + */ +# error Incompatible native Std library. +# endif /* std */ +# define std STLPORT +# endif /* _STLP_DONT_REDEFINE_STD */ + +#endif + +#undef _STLP_PROLOG_HEADER_INCLUDED /* defined in _prolog.h */ diff --git a/stlport/stlport/stl/_function_base.h b/stlport/stlport/stl/_function_base.h new file mode 100644 index 0000000..1e7f4f5 --- /dev/null +++ b/stlport/stlport/stl/_function_base.h @@ -0,0 +1,217 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +#define _STLP_INTERNAL_FUNCTION_BASE_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_TYPE_TRAITS_H) +# include <stl/type_traits.h> +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _Arg, class _Result> +struct unary_function { + typedef _Arg argument_type; + typedef _Result result_type; +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580) +protected: + /* This class purpose is to be derived but it is not polymorphic so users should never try + * to destroy an instance of it directly. The protected non-virtual destructor make this + * fact obvious at compilation time. */ + ~unary_function() {} +#endif +}; + +template <class _Arg1, class _Arg2, class _Result> +struct binary_function { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x580) +protected: + /* See unary_function comment. */ + ~binary_function() {} +#endif +}; + +template <class _Tp> +struct equal_to : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; } +}; + +template <class _Tp> +struct less : public binary_function<_Tp,_Tp,bool> +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +/* less is the default template parameter for many STL containers, to fully use + * the move constructor feature we need to know that the default less is just a + * functor. + */ + , public __stlport_class<less<_Tp> > +#endif +{ + bool operator()(const _Tp& __x, const _Tp& __y) const { return __x < __y; } + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(less<_Tp>& __x) {} +#endif +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Tp> +struct __type_traits<less<_Tp> > { +#if !defined (__BORLANDC__) + typedef typename _IsSTLportClass<less<_Tp> >::_Ret _STLportLess; +#else + enum { _Is = _IsSTLportClass<less<_Tp> >::_Is }; + typedef typename __bool2type<_Is>::_Ret _STLportLess; +#endif + typedef _STLportLess has_trivial_default_constructor; + typedef _STLportLess has_trivial_copy_constructor; + typedef _STLportLess has_trivial_assignment_operator; + typedef _STLportLess has_trivial_destructor; + typedef _STLportLess is_POD_type; +}; +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp> +less<_Tp> __less(_Tp* ) { return less<_Tp>(); } + +template <class _Tp> +equal_to<_Tp> __equal_to(_Tp* ) { return equal_to<_Tp>(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _Tp> +struct plus : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } +}; + +template <class _Tp> +struct minus : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x - __y; } +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp> +plus<_Tp> __plus(_Tp* ) { return plus<_Tp>(); } + +template <class _Tp> +minus<_Tp> __minus(_Tp* ) { return minus<_Tp>(); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _Tp> +struct multiplies : public binary_function<_Tp, _Tp, _Tp> { + _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x * __y; } +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Pair> +struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { + const typename _Pair::first_type& operator()(const _Pair& __x) const { + return __x.first; + } +}; + +template <class _Pair> +struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> { + const typename _Pair::second_type& operator()(const _Pair& __x) const { + return __x.second; + } +}; + +// project1st and project2nd are extensions: they are not part of the standard +template <class _Arg1, class _Arg2> +struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1> { + _Arg1 operator()(const _Arg1& __x, const _Arg2&) const { return __x; } +}; + +template <class _Arg1, class _Arg2> +struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2> { + _Arg2 operator()(const _Arg1&, const _Arg2& __y) const { return __y; } +}; + +#if defined (_STLP_MULTI_CONST_TEMPLATE_ARG_BUG) +// fbp : sort of select1st just for maps +template <class _Pair, class _Whatever> +// JDJ (CW Pro1 doesn't like const when first_type is also const) +struct __Select1st_hint : public unary_function<_Pair, _Whatever> { + const _Whatever& operator () (const _Pair& __x) const { return __x.first; } +}; +# define _STLP_SELECT1ST(__x,__y) _STLP_PRIV __Select1st_hint< __x, __y > +#else +# define _STLP_SELECT1ST(__x, __y) _STLP_PRIV _Select1st< __x > +#endif + +template <class _Tp> +struct _Identity : public unary_function<_Tp,_Tp> { + const _Tp& operator()(const _Tp& __x) const { return __x; } +}; + +template <class _Result, class _Argument> +struct _Constant_unary_fun { + typedef _Argument argument_type; + typedef _Result result_type; + result_type _M_val; + + _Constant_unary_fun(const result_type& __v) : _M_val(__v) {} + const result_type& operator()(const _Argument&) const { return _M_val; } +}; + +template <class _Result, class _Arg1, class _Arg2> +struct _Constant_binary_fun { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; + _Result _M_val; + + _Constant_binary_fun(const _Result& __v) : _M_val(__v) {} + const result_type& operator()(const _Arg1&, const _Arg2&) const { + return _M_val; + } +}; + +// identity_element (not part of the C++ standard). +template <class _Tp> inline _Tp __identity_element(plus<_Tp>) { return _Tp(0); } +template <class _Tp> inline _Tp __identity_element(multiplies<_Tp>) { return _Tp(1); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_FUNCTION_BASE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_iterator.h b/stlport/stlport/stl/_iterator.h new file mode 100644 index 0000000..8e3b7b0 --- /dev/null +++ b/stlport/stlport/stl/_iterator.h @@ -0,0 +1,265 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ITERATOR_H +#define _STLP_INTERNAL_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include <stl/_iterator_base.h> +#endif + +_STLP_BEGIN_NAMESPACE + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +// This is the new version of reverse_iterator, as defined in the +// draft C++ standard. It relies on the iterator_traits template, +// which in turn relies on partial specialization. The class +// reverse_bidirectional_iterator is no longer part of the draft +// standard, but it is retained for backward compatibility. + +template <class _Iterator> +class reverse_iterator : + public iterator<typename iterator_traits<_Iterator>::iterator_category, + typename iterator_traits<_Iterator>::value_type, + typename iterator_traits<_Iterator>::difference_type, + typename iterator_traits<_Iterator>::pointer, + typename iterator_traits<_Iterator>::reference> { +protected: + _Iterator current; + typedef reverse_iterator<_Iterator> _Self; +public: + typedef typename iterator_traits<_Iterator>::difference_type difference_type; + // pointer type required for arrow operator hidden behind _STLP_DEFINE_ARROW_OPERATOR: + typedef typename iterator_traits<_Iterator>::pointer pointer; + typedef typename iterator_traits<_Iterator>::reference reference; + typedef _Iterator iterator_type; +public: + reverse_iterator() {} + explicit reverse_iterator(iterator_type __x) : current(__x) {} + reverse_iterator(const _Self& __x) : current(__x.current) {} + _Self& operator = (const _Self& __x) { current = __x.base(); return *this; } +# if defined (_STLP_MEMBER_TEMPLATES) + template <class _Iter> + reverse_iterator(const reverse_iterator<_Iter>& __x) : current(__x.base()) {} + template <class _Iter> + _Self& operator = (const reverse_iterator<_Iter>& __x) { current = __x.base(); return *this; } +# endif /* _STLP_MEMBER_TEMPLATES */ + + iterator_type base() const { return current; } + reference operator*() const { + _Iterator __tmp = current; + return *--__tmp; + } + _STLP_DEFINE_ARROW_OPERATOR + _Self& operator++() { + --current; + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + --current; + return __tmp; + } + _Self& operator--() { + ++current; + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + ++current; + return __tmp; + } + + _Self operator+(difference_type __n) const { return _Self(current - __n); } + _Self& operator+=(difference_type __n) { + current -= __n; + return *this; + } + _Self operator-(difference_type __n) const { return _Self(current + __n); } + _Self& operator-=(difference_type __n) { + current += __n; + return *this; + } + reference operator[](difference_type __n) const { return *(*this + __n); } +}; + +template <class _Iterator> +inline bool _STLP_CALL operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __x.base() == __y.base(); } + +template <class _Iterator> +inline bool _STLP_CALL operator<(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y.base() < __x.base(); } + +# if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template <class _Iterator> +inline bool _STLP_CALL operator!=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__x == __y); } + +template <class _Iterator> +inline bool _STLP_CALL operator>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y < __x; } + +template <class _Iterator> +inline bool _STLP_CALL operator<=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__y < __x); } + +template <class _Iterator> +inline bool _STLP_CALL operator>=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return !(__x < __y); } +# endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +template <class _Iterator> +# if defined (__SUNPRO_CC) +inline ptrdiff_t _STLP_CALL +# else +inline typename reverse_iterator<_Iterator>::difference_type _STLP_CALL +# endif +operator-(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) +{ return __y.base() - __x.base(); } + +template <class _Iterator, class _DifferenceType> +inline reverse_iterator<_Iterator> _STLP_CALL +operator+(_DifferenceType n,const reverse_iterator<_Iterator>& x) +{ return x.operator+(n); } +#endif + +template <class _Container> +class back_insert_iterator + : public iterator<output_iterator_tag, void, void, void, void> { + typedef back_insert_iterator<_Container> _Self; +protected: + //c is a Standard name (24.4.2.1), do no make it STLport naming convention compliant. + _Container *container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + + explicit back_insert_iterator(_Container& __x) : container(&__x) {} + + _Self& operator=(const _Self& __other) { + container = __other.container; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + container->push_back(__val); + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self operator++(int) { return *this; } +}; + +template <class _Container> +inline back_insert_iterator<_Container> _STLP_CALL back_inserter(_Container& __x) +{ return back_insert_iterator<_Container>(__x); } + +template <class _Container> +class front_insert_iterator + : public iterator<output_iterator_tag, void, void, void, void> { + typedef front_insert_iterator<_Container> _Self; +protected: + //c is a Standard name (24.4.2.3), do no make it STLport naming convention compliant. + _Container *container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + explicit front_insert_iterator(_Container& __x) : container(&__x) {} + + _Self& operator=(const _Self& __other) { + container = __other.container; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + container->push_front(__val); + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self operator++(int) { return *this; } +}; + +template <class _Container> +inline front_insert_iterator<_Container> _STLP_CALL front_inserter(_Container& __x) +{ return front_insert_iterator<_Container>(__x); } + +template <class _Container> +class insert_iterator + : public iterator<output_iterator_tag, void, void, void, void> { + typedef insert_iterator<_Container> _Self; +protected: + //container is a Standard name (24.4.2.5), do no make it STLport naming convention compliant. + _Container *container; + typename _Container::iterator _M_iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + insert_iterator(_Container& __x, typename _Container::iterator __i) + : container(&__x), _M_iter(__i) {} + + _Self& operator=(_Self const& __other) { + container = __other.container; + _M_iter = __other._M_iter; + return *this; + } + _Self& operator=(const typename _Container::value_type& __val) { + _M_iter = container->insert(_M_iter, __val); + ++_M_iter; + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self& operator++(int) { return *this; } +}; + +template <class _Container, class _Iterator> +inline insert_iterator<_Container> _STLP_CALL +inserter(_Container& __x, _Iterator __i) { + typedef typename _Container::iterator __iter; + return insert_iterator<_Container>(__x, __iter(__i)); +} + +_STLP_END_NAMESPACE + +#if ! defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# include <stl/_iterator_old.h> +#endif + +#endif /* _STLP_INTERNAL_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_iterator_base.h b/stlport/stlport/stl/_iterator_base.h new file mode 100644 index 0000000..ef59048 --- /dev/null +++ b/stlport/stlport/stl/_iterator_base.h @@ -0,0 +1,525 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +#define _STLP_INTERNAL_ITERATOR_BASE_H + +#ifndef _STLP_INTERNAL_CSTDDEF +# include <stl/_cstddef.h> +#endif + +//# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD) +//_STLP_BEGIN_NAMESPACE +//using namespace _STLP_VENDOR_CSTD; +//_STLP_END_NAMESPACE +//#endif /* _STLP_IMPORT_VENDOR_CSTD */ + +#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) +# ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +struct input_iterator_tag {}; +struct output_iterator_tag {}; +struct forward_iterator_tag : public input_iterator_tag {}; +struct bidirectional_iterator_tag : public forward_iterator_tag {}; +struct random_access_iterator_tag : public bidirectional_iterator_tag {}; + +template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t), + _STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) > +struct iterator { + typedef _Category iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; + typedef _Pointer pointer; + typedef _Reference reference; +}; +_STLP_TEMPLATE_NULL +struct iterator<output_iterator_tag, void, void, void, void> { + typedef output_iterator_tag iterator_category; +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; +#endif +}; + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_category(_It) +# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::distance_type(_It) +# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::value_type(_It) +//Old HP iterator queries do not give information about the iterator +//associated reference type so we consider that it is not a real reference. +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type() +#else +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# define _STLP_VALUE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::value_type*)0 +# define _STLP_DISTANCE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::difference_type*)0 +# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ + (defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__) +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_traits< _Tp >::iterator_category() +# else +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::iterator_category() +# endif +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _STLP_STD::_IsRefType< _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::reference >::_Ret() +# else +# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::__iterator_category(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::__distance_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::__value_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret()) +# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type() +# endif +#endif + +#if defined (_STLP_DONT_REDEFINE_STD) && defined (_STLP_WHOLE_NATIVE_STD) +/* In this mode we will see both STLport implementation and native + * one. To allow some interaction between both implementations through + * iterators we have to map std iterator categories to stlport ones. This + * way we will be able to initialize STLport containers with native + * iterators, the other side won't work except when STLport iterators are + * simple pointers. */ + +_STLP_END_NAMESPACE + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <iterator> +# else +# include _STLP_NATIVE_HEADER(iterator) +# endif + +_STLP_BEGIN_NAMESPACE + +template <class _IteCat> +struct _CategoryMapping +{ typedef _IteCat _Tag; }; + +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::input_iterator_tag> +{ typedef input_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::output_iterator_tag> +{ typedef output_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::forward_iterator_tag> +{ typedef forward_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::bidirectional_iterator_tag> +{ typedef bidirectional_iterator_tag _Tag; }; +_STLP_TEMPLATE_NULL +struct _CategoryMapping<::std::random_access_iterator_tag> +{ typedef random_access_iterator_tag _Tag; }; + +template <class _Iterator> +struct iterator_traits { + typedef typename _Iterator::iterator_category _OriginalTag; + typedef typename _CategoryMapping<_OriginalTag>::_Tag iterator_category; +#else +template <class _Iterator> +struct iterator_traits { + typedef typename _Iterator::iterator_category iterator_category; +#endif + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (__SUNPRO_CC) +# define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type +#else +# define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t +#endif + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION + +// fbp : this order keeps gcc happy +template <class _Tp> +struct iterator_traits<const _Tp*> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; +}; + +template <class _Tp> +struct iterator_traits<_Tp*> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef _Tp& reference; +}; + +# if defined (__BORLANDC__) +template <class _Tp> +struct iterator_traits<_Tp* const> { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; +}; +# endif + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE +#include <stl/_ptrs_specialize.h> +_STLP_BEGIN_NAMESPACE + +#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES +// The overloaded functions iterator_category, distance_type, and +// value_type are not part of the C++ standard. (They have been +// replaced by struct iterator_traits.) They are included for +// backward compatibility with the HP STL. +// We introduce internal names for these functions. + +# ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION + +template <class _Tp> +inline _STLP_STD::random_access_iterator_tag +__iterator_category(const _Tp*, const __true_type&) +{ return _STLP_STD::random_access_iterator_tag(); } + +template <class _Iter> +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::iterator_category +__iterator_category(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::iterator_category _Category; + return _Category(); +} + +template <class _Tp> +inline ptrdiff_t* +__distance_type(const _Tp*, const __true_type&) +{ return __STATIC_CAST(ptrdiff_t*, 0); } + +template <class _Iter> +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::difference_type* +__distance_type(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::difference_type _diff_type; + return __STATIC_CAST(_diff_type*,0); +} + +template <class _Tp> +inline _Tp* +__value_type(const _Tp*, const __true_type&) +{ return __STATIC_CAST(_Tp*, 0); } + +template <class _Iter> +inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::value_type* +__value_type(const _Iter&, const __false_type&) { + typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::value_type _value_type; + return __STATIC_CAST(_value_type*,0); +} + +# endif + +#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ +template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> +inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); } +template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> +inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); } +template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> +inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); } +template <class _Tp> +inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); } +template <class _Tp> +inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); } +template <class _Tp> +inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); } +#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */ + +#if !defined (_STLP_NO_ANACHRONISMS) +// The base classes input_iterator, output_iterator, forward_iterator, +// bidirectional_iterator, and random_access_iterator are not part of +// the C++ standard. (They have been replaced by struct iterator.) +// They are included for backward compatibility with the HP STL. +template <class _Tp, class _Distance> struct input_iterator : + public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {}; +struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {}; +template <class _Tp, class _Distance> struct forward_iterator : + public iterator<forward_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {}; +template <class _Tp, class _Distance> struct bidirectional_iterator : + public iterator<bidirectional_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {}; +template <class _Tp, class _Distance> struct random_access_iterator : + public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {}; + +# if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template <class _Tp, class _Distance> +inline input_iterator_tag _STLP_CALL +iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); } +inline output_iterator_tag _STLP_CALL +iterator_category(const output_iterator&) { return output_iterator_tag(); } +template <class _Tp, class _Distance> +inline forward_iterator_tag _STLP_CALL +iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); } +template <class _Tp, class _Distance> +inline bidirectional_iterator_tag _STLP_CALL +iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); } +template <class _Tp, class _Distance> +inline random_access_iterator_tag _STLP_CALL +iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); } +template <class _Tp, class _Distance> +inline _Tp* _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template <class _Tp, class _Distance> +inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template <class _Tp, class _Distance> +inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template <class _Tp, class _Distance> +inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); } +template <class _Tp, class _Distance> +inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +template <class _Tp, class _Distance> +inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +template <class _Tp, class _Distance> +inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);} +template <class _Tp, class _Distance> +inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); } +# endif +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIterator> +inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL +__distance(const _InputIterator& __first, const _InputIterator& __last, + const input_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0; + _InputIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _ForwardIterator> +inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL +__distance(const _ForwardIterator& __first, const _ForwardIterator& __last, + const forward_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_ForwardIterator) __n = 0; + _ForwardIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} + +template <class _BidirectionalIterator> +_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL +__distance(const _BidirectionalIterator& __first, const _BidirectionalIterator& __last, + const bidirectional_iterator_tag &) { + _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0; + _BidirectionalIterator __it(__first); + while (__it != __last) { + ++__it; ++__n; + } + return __n; +} +#endif + +template <class _RandomAccessIterator> +inline _STLP_DIFFERENCE_TYPE(_RandomAccessIterator) _STLP_CALL +__distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last, + const random_access_iterator_tag &) +{ return __last - __first; } + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIterator> +inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL +distance(_InputIterator __first, _InputIterator __last) +{ return _STLP_PRIV __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +#if !defined (_STLP_NO_ANACHRONISMS) +template <class _InputIterator, class _Distance> +inline void _STLP_CALL distance(const _InputIterator& __first, + const _InputIterator& __last, _Distance& __n) +{ __n += _STLP_STD::distance(__first, __last); } + +# if defined (_STLP_MSVC) +// MSVC specific +template <class _InputIterator, class _Dist> +inline void _STLP_CALL _Distance(_InputIterator __first, + _InputIterator __last, _Dist& __n) +{ __n += _STLP_STD::distance(__first, __last); } +# endif +#endif + +// fbp: those are being used for iterator/const_iterator definitions everywhere +template <class _Tp> +struct _Nonconst_traits; + +template <class _Tp> +struct _Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_traits<_Tp> _NonConstTraits; +}; + +template <class _Tp> +struct _Nonconst_traits { + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + typedef _Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_traits<_Tp> _NonConstTraits; +}; + +/* + * dums: A special iterator/const_iterator traits for set and multiset for which even + * the iterator is not mutable + */ +template <class _Tp> +struct _Nonconst_Const_traits; + +template <class _Tp> +struct _Const_Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits; +}; + +template <class _Tp> +struct _Nonconst_Const_traits { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Const_Const_traits<_Tp> _ConstTraits; + typedef _Nonconst_Const_traits<_Tp> _NonConstTraits; +}; + +/* + * A macro to generate a new iterator traits from one of the + * previous one. Changing the iterator traits type make iterators + * from different containers not comparable. + */ +#define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \ +template <class _Tp> \ +struct _##Motif; \ +template <class _Tp> \ +struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> { \ + typedef _Const##Motif<_Tp> _ConstTraits; \ + typedef _##Motif<_Tp> _NonConstTraits; \ +}; \ +template <class _Tp> \ +struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> { \ + typedef _Const##Motif<_Tp> _ConstTraits; \ + typedef _##Motif<_Tp> _NonConstTraits; \ +}; + +#define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits) \ +_STLP_MOVE_TO_PRIV_NAMESPACE \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits) \ +_STLP_MOVE_TO_STD_NAMESPACE + +#define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits) \ +_STLP_MOVE_TO_PRIV_NAMESPACE \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits) \ +_STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits) \ +template <class _Tp> \ +struct _##Motif { \ + typedef _ConstNonLocal##Motif<_Tp> _ConstTraits; \ + typedef _NonLocal##Motif<_Tp> _NonConstTraits; \ + typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits; \ + typedef _Local##Motif<_Tp> _NonConstLocalTraits; \ +}; \ +_STLP_MOVE_TO_STD_NAMESPACE + +/* +# if defined (_STLP_BASE_TYPEDEF_BUG) +// this workaround is needed for SunPro 4.0.1 +template <class _Traits> +struct __cnst_traits_aux : private _Traits { + typedef typename _Traits::value_type value_type; +}; +# define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type +# else +# define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type +# endif +*/ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter, class _Distance> +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) +{ while (__n--) ++__i; } + +// fbp : added output iterator tag variant +template <class _InputIter, class _Distance> +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) +{ while (__n--) ++__i; } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _ForwardIterator, class _Distance> +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &) +{ while (n--) ++i; } +#endif + +template <class _BidirectionalIterator, class _Distance> +_STLP_INLINE_LOOP void _STLP_CALL +__advance(_BidirectionalIterator& __i, _Distance __n, + const bidirectional_iterator_tag &) { + if (__n > 0) + while (__n--) ++__i; + else + while (__n++) --__i; +} + +template <class _RandomAccessIterator, class _Distance> +inline void _STLP_CALL +__advance(_RandomAccessIterator& __i, _Distance __n, + const random_access_iterator_tag &) +{ __i += __n; } + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIterator, class _Distance> +inline void _STLP_CALL advance(_InputIterator& __i, _Distance __n) +{ _STLP_PRIV __advance(__i, __n, _STLP_ITERATOR_CATEGORY(__i, _InputIterator)); } + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_ITERATOR_BASE_H */ + + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_list.c b/stlport/stlport/stl/_list.c new file mode 100644 index 0000000..86e420b --- /dev/null +++ b/stlport/stlport/stl/_list.c @@ -0,0 +1,250 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_LIST_C +#define _STLP_LIST_C + +#ifndef _STLP_INTERNAL_LIST_H +# include <stl/_list.h> +#endif + +#ifndef _STLP_CARRAY_H +# include <stl/_carray.h> +#endif + +#ifndef _STLP_RANGE_ERRORS_H +# include <stl/_range_errors.h> +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) +template <class _Dummy> +void _STLP_CALL +_List_global<_Dummy>::_Transfer(_List_node_base* __position, + _List_node_base* __first, _List_node_base* __last) { + if (__position != __last) { + // Remove [first, last) from its old position. + __last->_M_prev->_M_next = __position; + __first->_M_prev->_M_next = __last; + __position->_M_prev->_M_next = __first; + + // Splice [first, last) into its new position. + _Node_base* __tmp = __position->_M_prev; + __position->_M_prev = __last->_M_prev; + __last->_M_prev = __first->_M_prev; + __first->_M_prev = __tmp; + } +} +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ + +template <class _Tp, class _Alloc> +void _List_base<_Tp,_Alloc>::clear() { + _Node* __cur = __STATIC_CAST(_Node*, _M_node._M_data._M_next); + while ( +#if defined (__BORLANDC__) // runtime error + __cur && +#endif + __cur != &(_M_node._M_data)) { + _Node* __tmp = __cur; + __cur = __STATIC_CAST(_Node*, __cur->_M_next); + _STLP_STD::_Destroy(&__tmp->_M_data); + this->_M_node.deallocate(__tmp, 1); + } + _M_node._M_data._M_next = &_M_node._M_data; + _M_node._M_data._M_prev = &_M_node._M_data; +} + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define size_type size_t +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define list _STLP_PTR_IMPL_NAME(list) +#elif defined (_STLP_DEBUG) +# define list _STLP_NON_DBG_NAME(list) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template <class _Tp, class _Alloc> +void list<_Tp, _Alloc>::resize(size_type __new_size, const _Tp& __x) { + iterator __i = begin(); + size_type __len = 0; + for ( ; __i != end() && __len < __new_size; ++__i, ++__len); + + if (__len == __new_size) + erase(__i, end()); + else // __i == end() + insert(end(), __new_size - __len, __x); +} + +template <class _Tp, class _Alloc> +list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x) { + if (this != &__x) { + iterator __first1 = begin(); + iterator __last1 = end(); + const_iterator __first2 = __x.begin(); + const_iterator __last2 = __x.end(); + while (__first1 != __last1 && __first2 != __last2) + *__first1++ = *__first2++; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + return *this; +} + +template <class _Tp, class _Alloc> +void list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) { + iterator __i = begin(); + for ( ; __i != end() && __n > 0; ++__i, --__n) + *__i = __val; + if (__n > 0) + insert(end(), __n, __val); + else + erase(__i, end()); +} + +#if !defined (list) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +template <class _Tp, class _Alloc, class _Predicate> +void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first = __that.begin(); + _Literator __last = __that.end(); + while (__first != __last) { + _Literator __next = __first; + ++__next; + if (__pred(*__first)) __that.erase(__first); + __first = __next; + } +} + +template <class _Tp, class _Alloc, class _BinaryPredicate> +void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first = __that.begin(); + _Literator __last = __that.end(); + if (__first == __last) return; + _Literator __next = __first; + while (++__next != __last) { + if (__binary_pred(*__first, *__next)) + __that.erase(__next); + else + __first = __next; + __next = __first; + } +} + +template <class _Tp, class _Alloc, class _StrictWeakOrdering> +void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp) { + typedef typename list<_Tp, _Alloc>::iterator _Literator; + _Literator __first1 = __that.begin(); + _Literator __last1 = __that.end(); + _Literator __first2 = __x.begin(); + _Literator __last2 = __x.end(); + if (__that.get_allocator() == __x.get_allocator()) { + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + _Literator __next = __first2; + _List_global_inst::_Transfer(__first1._M_node, __first2._M_node, (++__next)._M_node); + __first2 = __next; + } + else + ++__first1; + } + if (__first2 != __last2) + _List_global_inst::_Transfer(__last1._M_node, __first2._M_node, __last2._M_node); + } + else { + while (__first1 != __last1 && __first2 != __last2) { + if (__comp(*__first2, *__first1)) { + _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE) + __first1 = __that.insert(__first1, *__first2); + } + else + ++__first1; + } + if (__first2 != __last2) { + __that.insert(__first1, __first2, __last2); + } + __x.clear(); + } +} + +template <class _Tp, class _Alloc, class _StrictWeakOrdering> +void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) { + // Do nothing if the list has length 0 or 1. + if (__that._M_node._M_data._M_next == &__that._M_node._M_data || + __that._M_node._M_data._M_next->_M_next == &__that._M_node._M_data) + return; + + list<_Tp, _Alloc> __carry(__that.get_allocator()); + const int NB = 64; + _STLP_PRIV _CArray<list<_Tp, _Alloc>, NB> __counter(__carry); + int __fill = 0; + while (!__that.empty()) { + __carry.splice(__carry.begin(), __that, __that.begin()); + int __i = 0; + while (__i < __fill && !__counter[__i].empty()) { + _S_merge(__counter[__i], __carry, __comp); + __carry.swap(__counter[__i++]); + } + __carry.swap(__counter[__i]); + if (__i == __fill) { + ++__fill; + if (__fill >= NB) { + //Looks like the list has too many elements to be sorted with this algorithm: + __stl_throw_overflow_error("list::sort"); + } + } + } + + for (int __i = 1; __i < __fill; ++__i) + _S_merge(__counter[__i], __counter[__i - 1], __comp); + __that.swap(__counter[__fill - 1]); +} + +#if defined (list) +# undef list +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_LIST_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_list.h b/stlport/stlport/stl/_list.h new file mode 100644 index 0000000..6cd3f2b --- /dev/null +++ b/stlport/stlport/stl/_list.h @@ -0,0 +1,742 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_LIST_IMPL_H +#define _STLP_INTERNAL_LIST_IMPL_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include <stl/_alloc.h> +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include <stl/_iterator.h> +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include <stl/_construct.h> +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include <stl/_function_base.h> +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +struct _List_node_base { + _List_node_base* _M_next; + _List_node_base* _M_prev; +}; + +template <class _Dummy> +class _List_global { +public: + typedef _List_node_base _Node_base; + static void _STLP_CALL _Transfer(_Node_base* __pos, + _Node_base* __first, _Node_base* __last); +}; + +#if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _List_global<bool>; +#endif +typedef _List_global<bool> _List_global_inst; + +template <class _Tp> +class _List_node : public _List_node_base { +public: + _Tp _M_data; + __TRIVIAL_STUFF(_List_node) +}; + +struct _List_iterator_base { + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bidirectional_iterator_tag iterator_category; + + _List_node_base* _M_node; + + _List_iterator_base(_List_node_base* __x) : _M_node(__x) {} + + void _M_incr() { _M_node = _M_node->_M_next; } + void _M_decr() { _M_node = _M_node->_M_prev; } +}; + + +template<class _Tp, class _Traits> +struct _List_iterator : public _List_iterator_base { + typedef _Tp value_type; + typedef typename _Traits::pointer pointer; + typedef typename _Traits::reference reference; + + typedef _List_iterator<_Tp, _Traits> _Self; + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _List_iterator<_Tp, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _List_iterator<_Tp, _ConstTraits> const_iterator; + + typedef bidirectional_iterator_tag iterator_category; + typedef _List_node<_Tp> _Node; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + explicit _List_iterator(_List_node_base* __x) : _List_iterator_base(__x) {} + _List_iterator() : _List_iterator_base(0) {} + //copy constructor for iterator and constructor from iterator for const_iterator + _List_iterator(const iterator& __x) : _List_iterator_base(__x._M_node) {} + + reference operator*() const { return __STATIC_CAST(_Node*, this->_M_node)->_M_data; } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + this->_M_incr(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + this->_M_incr(); + return __tmp; + } + _Self& operator--() { + this->_M_decr(); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + this->_M_decr(); + return __tmp; + } + bool operator==(const_iterator __y ) const { + return this->_M_node == __y._M_node; + } + bool operator!=(const_iterator __y ) const { + return this->_M_node != __y._M_node; + } +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template <class _Tp, class _Traits> +struct __type_traits<_STLP_PRIV _List_iterator<_Tp, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template <class _Tp, class _Traits> +inline _Tp* value_type(const _STLP_PRIV _List_iterator<_Tp, _Traits>&) { return 0; } +inline bidirectional_iterator_tag iterator_category(const _STLP_PRIV _List_iterator_base&) { return bidirectional_iterator_tag();} +inline ptrdiff_t* distance_type(const _STLP_PRIV _List_iterator_base&) { return 0; } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// Base class that encapsulates details of allocators and helps +// to simplify EH + +template <class _Tp, class _Alloc> +class _List_base { +protected: + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _List_node_base _Node_base; + typedef _List_node<_Tp> _Node; + typedef _List_base<_Tp, _Alloc> _Self; + typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _Node_allocator_type; +public: + typedef _STLP_alloc_proxy<_Node_base, _Node, _Node_allocator_type> _AllocProxy; + typedef _Alloc allocator_type; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const _Node_allocator_type&)_M_node, _Tp); } + + _List_base(const allocator_type& __a) : _M_node(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Node_base()) + { _M_empty_initialize(); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _List_base(__move_source<_Self> src) : + _M_node(__move_source<_AllocProxy>(src.get()._M_node)) { + if (src.get().empty()) + //We force this to empty. + _M_empty_initialize(); + else { + src.get()._M_empty_initialize(); + _M_node._M_data._M_prev->_M_next = _M_node._M_data._M_next->_M_prev = &_M_node._M_data; + } + } +#endif + + ~_List_base() + { clear(); } + + void clear(); + bool empty() const { return _M_node._M_data._M_next == &_M_node._M_data; } + + void _M_empty_initialize() { + _M_node._M_data._M_next = &_M_node._M_data; + _M_node._M_data._M_prev = _M_node._M_data._M_next; + } + +public: + _AllocProxy _M_node; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define list _STLP_PTR_IMPL_NAME(list) +#elif defined (_STLP_DEBUG) +# define list _STLP_NON_DBG_NAME(list) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) > +class list; + +#if !defined (list) +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif + +// helper functions to reduce code duplication +template <class _Tp, class _Alloc, class _Predicate> +void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred); + +template <class _Tp, class _Alloc, class _BinaryPredicate> +void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred); + +template <class _Tp, class _Alloc, class _StrictWeakOrdering> +void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x, + _StrictWeakOrdering __comp); + +template <class _Tp, class _Alloc, class _StrictWeakOrdering> +void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp); + +#if !defined (list) +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template <class _Tp, class _Alloc> +class list : public _STLP_PRIV _List_base<_Tp, _Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list) + , public __stlport_class<list<_Tp, _Alloc> > +#endif +{ + typedef _STLP_PRIV _List_base<_Tp, _Alloc> _Base; + typedef list<_Tp, _Alloc> _Self; + typedef _STLP_PRIV _List_node<_Tp> _Node; + typedef _STLP_PRIV _List_node_base _Node_base; +public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + typedef bidirectional_iterator_tag _Iterator_category; + +public: + typedef _STLP_PRIV _List_iterator<_Tp, _Nonconst_traits<_Tp> > iterator; + typedef _STLP_PRIV _List_iterator<_Tp, _Const_traits<_Tp> > const_iterator; + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +protected: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node_base* _M_create_node(const_reference __x = value_type()) { +#else + _Node_base* _M_create_node(const_reference __x) { +#endif + _Node* __p = this->_M_node.allocate(1); + _STLP_TRY { + _Copy_Construct(&__p->_M_data, __x); + } + _STLP_UNWIND(this->_M_node.deallocate(__p, 1)) + return __p; + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + _Node_base* _M_create_node() { + _Node* __p = this->_M_node.allocate(1); + _STLP_TRY { + _STLP_STD::_Construct(&__p->_M_data); + } + _STLP_UNWIND(this->_M_node.deallocate(__p, 1)) + return __p; + } +#endif + +public: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit list(size_type __n, const_reference __val = _STLP_DEFAULT_CONSTRUCTED(value_type), + const allocator_type& __a = allocator_type()) +#else + explicit list(size_type __n) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { this->insert(begin(), __n, _STLP_DEFAULT_CONSTRUCTED(value_type)); } + list(size_type __n, const_reference __val) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { this->insert(begin(), __n, __val); } + list(size_type __n, const_reference __val, const allocator_type& __a) +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { this->insert(begin(), __n, __val); } + +#if defined (_STLP_MEMBER_TEMPLATES) + // We don't need any dispatching tricks here, because insert does all of + // that anyway. + template <class _InputIterator> + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template <class _InputIterator> + list(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) + { _M_insert(begin(), __first, __last); } +# endif +#else /* _STLP_MEMBER_TEMPLATES */ + list(const value_type* __first, const value_type* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } + list(const_iterator __first, const_iterator __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) + { _M_insert(begin(), __first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit list(const allocator_type& __a = allocator_type()) +#else + list() + : _STLP_PRIV _List_base<_Tp, _Alloc>(allocator_type()) {} + list(const allocator_type& __a) +#endif + : _STLP_PRIV _List_base<_Tp, _Alloc>(__a) {} + + list(const _Self& __x) : _STLP_PRIV _List_base<_Tp, _Alloc>(__x.get_allocator()) + { _M_insert(begin(), __x.begin(), __x.end()); } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + list(__move_source<_Self> src) + : _STLP_PRIV _List_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) {} +#endif + + ~list() {} + + _Self& operator = (const _Self& __x); + + iterator begin() { return iterator(this->_M_node._M_data._M_next); } + const_iterator begin() const { return const_iterator(this->_M_node._M_data._M_next); } + + iterator end() { return iterator(&this->_M_node._M_data); } + const_iterator end() const { return const_iterator(__CONST_CAST(_Node_base*, &this->_M_node._M_data)); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { + size_type __result = _STLP_STD::distance(begin(), end()); + return __result; + } + size_type max_size() const { return size_type(-1); } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(--end()); } + const_reference back() const { return *(--end()); } + +private: + void _M_swap_aux(_Self& __x) { + __x._M_node._M_swap_alloc(this->_M_node); + __x._M_node._M_data._M_next = this->_M_node._M_data._M_next; + __x._M_node._M_data._M_next->_M_prev = &__x._M_node._M_data; + __x._M_node._M_data._M_prev = this->_M_node._M_data._M_prev; + __x._M_node._M_data._M_prev->_M_next = &__x._M_node._M_data; + this->_M_empty_initialize(); + } + +public: + void swap(_Self& __x) { + if (__x.empty()) { + if (this->empty()) { + return; + } + this->_M_swap_aux(__x); + } else if (this->empty()) { + __x._M_swap_aux(*this); + } else { + this->_M_node.swap(__x._M_node); + _STLP_STD::swap(this->_M_node._M_data._M_prev->_M_next, __x._M_node._M_data._M_prev->_M_next); + _STLP_STD::swap(this->_M_node._M_data._M_next->_M_prev, __x._M_node._M_data._M_next->_M_prev); + } + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const_reference __x = value_type()) +#else + iterator insert(iterator __pos, const_reference __x) +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + { + _Node_base* __tmp = _M_create_node(__x); + _Node_base* __n = __pos._M_node; + _Node_base* __p = __n->_M_prev; + __tmp->_M_next = __n; + __tmp->_M_prev = __p; + __p->_M_next = __tmp; + __n->_M_prev = __tmp; + return iterator(__tmp); + } + +private: +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void _M_insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); + } + + // Check whether it's an integral type. If so, it's not an iterator. + template<class _Integer> + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type& /*_IsIntegral*/) { + _M_fill_insert(__pos, __n, __x); + } + template <class _InputIter> + void _M_insert_dispatch(iterator __pos, + _InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) { +#else /* _STLP_MEMBER_TEMPLATES */ + void _M_insert(iterator __pos, const value_type* __first, const value_type* __last) { + for (; __first != __last; ++__first) + insert(__pos, *__first); + } + void _M_insert(iterator __pos, const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary list to avoid the auto reference troubles (infinite loop) + for (; __first != __last; ++__first) + insert(__pos, *__first); + } + +public: +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_splice_insert_dispatch(__pos, __first, __last, _Integral()); + } + +private: + // Check whether it's an integral type. If so, it's not an iterator. + template<class _Integer> + void _M_splice_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + const __true_type& /*_IsIntegral*/) { + _M_fill_insert(__pos, __n, __x); + } + template <class _InputIter> + void _M_splice_insert_dispatch(iterator __pos, + _InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) { +#else /* _STLP_MEMBER_TEMPLATES */ + void insert(iterator __pos, const value_type* __first, const value_type* __last) { + _Self __tmp(__first, __last, this->get_allocator()); + _STLP_ASSERT(__tmp.get_allocator() == this->get_allocator()) + splice(__pos, __tmp); + } + void insert(iterator __pos, const_iterator __first, const_iterator __last) { +#endif /* _STLP_MEMBER_TEMPLATES */ + //We use a temporary list to avoid the auto reference troubles (infinite loop) + _Self __tmp(__first, __last, this->get_allocator()); + splice(__pos, __tmp); + } + +public: + void insert(iterator __pos, size_type __n, const_reference __x) + { _M_fill_insert(__pos, __n, __x); } + +private: + void _M_fill_insert(iterator __pos, size_type __n, const_reference __x) { + for ( ; __n > 0; --__n) + insert(__pos, __x); + } + +public: + void push_front(const_reference __x) { insert(begin(), __x); } + void push_back (const_reference __x) { insert(end(), __x); } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos) + { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); } + void push_front() {insert(begin());} + void push_back() {insert(end());} +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ + + iterator erase(iterator __pos) { + _Node_base* __next_node = __pos._M_node->_M_next; + _Node_base* __prev_node = __pos._M_node->_M_prev; + _Node* __n = __STATIC_CAST(_Node*, __pos._M_node); + __prev_node->_M_next = __next_node; + __next_node->_M_prev = __prev_node; + _STLP_STD::_Destroy(&__n->_M_data); + this->_M_node.deallocate(__n, 1); + return iterator(__next_node); + } + + iterator erase(iterator __first, iterator __last) { + while (__first != __last) + erase(__first++); + return __last; + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const_reference __x = value_type()); +#else + void resize(size_type __new_size, const_reference __x); + void resize(size_type __new_size) + { this->resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); } +#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/ + + void pop_front() { erase(begin()); } + void pop_back() { + iterator __tmp = end(); + erase(--__tmp); + } + +public: + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void assign(size_type __n, const_reference __val) { _M_fill_assign(__n, __val); } + + void _M_fill_assign(size_type __n, const_reference __val); + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } + + template <class _Integer> + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) { + _M_fill_assign(__n, __val); + } + + template <class _InputIterator> + void _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, + const __false_type& /*_IsIntegral*/) { +#else + void assign(const value_type *__first2, const value_type *__last2) { + iterator __first1 = begin(); + iterator __last1 = end(); + for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + void assign(const_iterator __first2, const_iterator __last2) { +#endif /* _STLP_MEMBER_TEMPLATES */ + iterator __first1 = begin(); + iterator __last1 = end(); + for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + +public: + void splice(iterator __pos, _Self& __x) { + if (!__x.empty()) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __x.begin()._M_node, __x.end()._M_node); + } + else { + insert(__pos, __x.begin(), __x.end()); + __x.clear(); + } + } + } + void splice(iterator __pos, _Self& __x, iterator __i) { + iterator __j = __i; + ++__j; + if (__pos == __i || __pos == __j) return; + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __i._M_node, __j._M_node); + } + else { + insert(__pos, *__i); + __x.erase(__i); + } + } + void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) { + if (__first != __last) { + if (this->get_allocator() == __x.get_allocator()) { + _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __first._M_node, __last._M_node); + } + else { + insert(__pos, __first, __last); + __x.erase(__first, __last); + } + } + } + + void remove(const_reference __val) { + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) { + iterator __next = __first; + ++__next; + if (__val == *__first) erase(__first); + __first = __next; + } + } + + void unique() + { _STLP_PRIV _S_unique(*this, equal_to<value_type>()); } + + void merge(_Self& __x) + { _STLP_PRIV _S_merge(*this, __x, less<value_type>()); } + + void reverse() { + _Node_base* __p = &this->_M_node._M_data; + _Node_base* __tmp = __p; + do { + _STLP_STD::swap(__tmp->_M_next, __tmp->_M_prev); + __tmp = __tmp->_M_prev; // Old next node is now prev. + } while (__tmp != __p); + } + + void sort() + { _STLP_PRIV _S_sort(*this, less<value_type>()); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _Predicate> + void remove_if(_Predicate __pred) + { _STLP_PRIV _S_remove_if(*this, __pred); } + template <class _BinaryPredicate> + void unique(_BinaryPredicate __binary_pred) + { _STLP_PRIV _S_unique(*this, __binary_pred); } + + template <class _StrictWeakOrdering> + void merge(_Self& __x, + _StrictWeakOrdering __comp) { + _STLP_PRIV _S_merge(*this, __x, __comp); + } + + template <class _StrictWeakOrdering> + void sort(_StrictWeakOrdering __comp) + { _STLP_PRIV _S_sort(*this, __comp); } +#endif /* _STLP_MEMBER_TEMPLATES */ +}; + +#if defined (list) +# undef list +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/_list.c> +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include <stl/pointers/_list.h> +#endif + +#if defined (_STLP_DEBUG) +# include <stl/debug/_list.h> +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _Tp, class _Alloc> +_STLP_INLINE_LOOP bool _STLP_CALL +operator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) { + typedef typename list<_Tp,_Alloc>::const_iterator const_iterator; + const_iterator __end1 = __x.end(); + const_iterator __end2 = __y.end(); + + const_iterator __i1 = __x.begin(); + const_iterator __i2 = __y.begin(); + while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) { + ++__i1; + ++__i2; + } + return __i1 == __end1 && __i2 == __end2; +} + +#define _STLP_EQUAL_OPERATOR_SPECIALIZED +#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER list<_Tp, _Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER +#undef _STLP_EQUAL_OPERATOR_SPECIALIZED + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Tp, class _Alloc> +struct __move_traits<list<_Tp, _Alloc> > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_LIST_IMPL_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_map.h b/stlport/stlport/stl/_map.h new file mode 100644 index 0000000..bf46a5d --- /dev/null +++ b/stlport/stlport/stl/_map.h @@ -0,0 +1,435 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_MAP_H +#define _STLP_INTERNAL_MAP_H + +#ifndef _STLP_INTERNAL_TREE_H +# include <stl/_tree.h> +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MapTraitsT, traits) + +template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class map +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<map<_Key, _Tp, _Compare, _Alloc> > +#endif +{ + typedef map<_Key, _Tp, _Compare, _Alloc> _Self; +public: + +// typedefs: + + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST _Key, _Tp> value_type; + typedef _Compare key_compare; + + class value_compare + : public binary_function<value_type, value_type, bool> { + friend class map<_Key,_Tp,_Compare,_Alloc>; + protected : + //c is a Standard name (23.3.1), do no make it STLport naming convention compliant. + _Compare comp; + value_compare(_Compare __c) : comp(__c) {} + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + +protected: + typedef _STLP_PRIV _MapTraitsT<value_type> _MapTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree<key_type, key_compare, + value_type, _STLP_SELECT1ST(value_type, _Key), + _MapTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing map + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + // allocation/deallocation + map() : _M_t(_Compare(), allocator_type()) {} +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit map(const _Compare& __comp, + const allocator_type& __a = allocator_type()) +#else + explicit map(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + explicit map(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + map(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + template <class _InputIterator> + map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template <class _InputIterator> + map(_InputIterator __first, _InputIterator __last, const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } +# endif + +#else + map(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + map(const value_type* __first, + const value_type* __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + + map(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + map(const_iterator __first, const_iterator __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + map(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + map(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return value_compare(_M_t.key_comp()); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + const_iterator begin() const { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + _STLP_TEMPLATE_FOR_CONT_EXT + _Tp& operator[](const _KT& __k) { + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) + __i = insert(__i, value_type(__k, _STLP_DEFAULT_CONSTRUCTED(_Tp))); + return (*__i).second; + } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + pair<iterator,bool> insert(const value_type& __x) + { return _M_t.insert_unique(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_unique(__pos, __x); } +#ifdef _STLP_MEMBER_TEMPLATES + template <class _InputIterator> + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_unique(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_unique(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + void erase(iterator __pos) { _M_t.erase(__pos); } + size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } + void clear() { _M_t.clear(); } + + // map operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator,iterator> equal_range(const _KT& __x) + { return _M_t.equal_range_unique(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator,const_iterator> equal_range(const _KT& __x) const + { return _M_t.equal_range_unique(__x); } +}; + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MultimapTraitsT, traits) + +template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key> ), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class multimap +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<multimap<_Key, _Tp, _Compare, _Alloc> > +#endif +{ + typedef multimap<_Key, _Tp, _Compare, _Alloc> _Self; +public: + +// typedefs: + + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST _Key, _Tp> value_type; + typedef _Compare key_compare; + + class value_compare : public binary_function<value_type, value_type, bool> { + friend class multimap<_Key,_Tp,_Compare,_Alloc>; + protected: + //comp is a Standard name (23.3.2), do no make it STLport naming convention compliant. + _Compare comp; + value_compare(_Compare __c) : comp(__c) {} + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + +protected: + //Specific iterator traits creation + typedef _STLP_PRIV _MultimapTraitsT<value_type> _MultimapTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree<key_type, key_compare, + value_type, _STLP_SELECT1ST(value_type, _Key), + _MultimapTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing multimap + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + // allocation/deallocation + multimap() : _M_t(_Compare(), allocator_type()) { } + explicit multimap(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { } + +#ifdef _STLP_MEMBER_TEMPLATES + template <class _InputIterator> + multimap(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } +# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS + template <class _InputIterator> + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } +# endif + template <class _InputIterator> + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#else + multimap(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + multimap(const value_type* __first, const value_type* __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } + + multimap(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + multimap(const_iterator __first, const_iterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + multimap(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + multimap(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return value_compare(_M_t.key_comp()); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + const_iterator begin() const { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); } + iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_equal(__pos, __x); } +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_equal(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_equal(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase(__pos); } + size_type erase(const key_type& __x) { return _M_t.erase(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } + void clear() { _M_t.clear(); } + + // multimap operations: + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.count(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator,iterator> equal_range(const _KT& __x) + { return _M_t.equal_range(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator,const_iterator> equal_range(const _KT& __x) const + { return _M_t.equal_range(__x); } +}; + +#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _Compare, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER map<_Key,_Tp,_Compare,_Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER multimap<_Key,_Tp,_Compare,_Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Key, class _Tp, class _Compare, class _Alloc> +struct __move_traits<map<_Key,_Tp,_Compare,_Alloc> > : + _STLP_PRIV __move_traits_aux<typename map<_Key,_Tp,_Compare,_Alloc>::_Rep_type> +{}; + +template <class _Key, class _Tp, class _Compare, class _Alloc> +struct __move_traits<multimap<_Key,_Tp,_Compare,_Alloc> > : + _STLP_PRIV __move_traits_aux<typename multimap<_Key,_Tp,_Compare,_Alloc>::_Rep_type> +{}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_MAP_H */ + +// Local Variables: +// mode:C++ +// End: + diff --git a/stlport/stlport/stl/_move_construct_fwk.h b/stlport/stlport/stl/_move_construct_fwk.h new file mode 100644 index 0000000..4a85fe3 --- /dev/null +++ b/stlport/stlport/stl/_move_construct_fwk.h @@ -0,0 +1,159 @@ +/* + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H +#define _STLP_MOVE_CONSTRUCT_FWK_H + +#ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +#endif + +_STLP_BEGIN_NAMESPACE + +/************************************************************* + * Move constructor framework + *************************************************************/ + +/************************************************************* + *Partial move: + *The source HAS to be a valid instance after the move! + *************************************************************/ +template <class _Tp> +class __move_source { +public: + explicit __move_source (_Tp &_src) : _M_data(_src) + {} + + _Tp& get() const + { return _M_data; } +private: + _Tp &_M_data; + + //We explicitely forbid assignment to avoid warning: + typedef __move_source<_Tp> _Self; + _Self& operator = (_Self const&); +}; + +//Class used to signal move constructor support, implementation and type. +template <class _Tp> +struct __move_traits { + /* + * implemented tells if a the special move constructor has to be called or the classic + * copy constructor is just fine. Most of the time the copy constructor is fine only + * if the following info is true. + */ +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && \ + !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && \ + !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename _IsSTLportClass<_Tp>::_Ret implemented; +#else + typedef __false_type implemented; +#endif + /* + * complete tells if the move is complete or partial, that is to say, does the source + * needs to be destroyed once it has been moved. + */ +# if defined (__BORLANDC__) && (__BORLANDC__ >= 0x564) + typedef __type_traits<_Tp>::has_trivial_destructor _TpMoveComplete; + typedef typename __bool2type<__type2bool<_TpMoveComplete>::_Ret>::_Ret complete; +# else + typedef typename __type_traits<_Tp>::has_trivial_destructor complete; +# endif +}; + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * This struct should never be used if the user has not explicitely stipulated + * that its class support the full move concept. To check that the return type + * in such a case will be __invalid_source<_Tp> to generate a compile error + * revealing the configuration problem. + */ +template <class _Tp> +struct _MoveSourceTraits { + typedef typename __move_traits<_Tp>::implemented _MvImpRet; +#if defined (__BORLANDC__) + typedef typename __selectT<_MvImpRet, +#else + enum {_MvImp = __type2bool<_MvImpRet>::_Ret}; + typedef typename __select<_MvImp, +#endif + __move_source<_Tp>, + _Tp const&>::_Ret _Type; +}; + +//The helper function +template <class _Tp> +inline _STLP_TYPENAME_ON_RETURN_TYPE _MoveSourceTraits<_Tp>::_Type +_AsMoveSource (_Tp &src) { + typedef typename _MoveSourceTraits<_Tp>::_Type _SrcType; + return _SrcType(src); +} + +//Helper structs used for many class. +template <class _Tp> +struct __move_traits_aux { + typedef typename __move_traits<_Tp>::implemented implemented; + typedef typename __move_traits<_Tp>::complete complete; +}; + +template <class _Tp1, class _Tp2> +struct __move_traits_aux2 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef typename _Lor2<typename _MoveTraits1::implemented, + typename _MoveTraits2::implemented>::_Ret implemented; + typedef typename _Land2<typename _MoveTraits1::complete, + typename _MoveTraits2::complete>::_Ret complete; +}; + +/* + * Most of the time a class implement a move constructor but its use depends + * on a third party, this is what the following struct are for. + */ +template <class _Tp> +struct __move_traits_help { + typedef __true_type implemented; + typedef typename __move_traits<_Tp>::complete complete; +}; + +template <class _Tp1, class _Tp2> +struct __move_traits_help1 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef typename _Lor2<typename _MoveTraits1::implemented, + typename _MoveTraits2::implemented>::_Ret implemented; + typedef typename _Land2<typename _MoveTraits1::complete, + typename _MoveTraits2::complete>::_Ret complete; +}; + +template <class _Tp1, class _Tp2> +struct __move_traits_help2 { + typedef __move_traits<_Tp1> _MoveTraits1; + typedef __move_traits<_Tp2> _MoveTraits2; + + typedef __true_type implemented; + typedef typename _Land2<typename _MoveTraits1::complete, + typename _MoveTraits2::complete>::_Ret complete; +}; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_MOVE_CONSTRUCT_FWK_H */ diff --git a/stlport/stlport/stl/_new.h b/stlport/stlport/stl/_new.h new file mode 100644 index 0000000..94094cf --- /dev/null +++ b/stlport/stlport/stl/_new.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_INTERNAL_NEW +#define _STLP_INTERNAL_NEW + +#ifndef _STLP_INTERNAL_CSTDDEF +// size_t +# include <stl/_cstddef.h> +#endif + +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x570) +// new.h uses ::malloc ;( +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib) +using _STLP_VENDOR_CSTD::malloc; +#endif + +#if !defined (_STLP_NO_NEW_NEW_HEADER) +// eMbedded Visual C++ .NET unfortunately uses _INC_NEW for both <new.h> and <new> +// we undefine the symbol to get the stuff in the SDK's <new> +# if defined (_STLP_WCE_NET) && defined (_INC_NEW) +# undef _INC_NEW +# endif + +# if defined (new) +/* STLport cannot replace native Std library new header if new is a macro, + * please define new macro after <new> header inclusion. + */ +# error Cannot include native new header as new is a macro. +# endif + +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <new> +# else +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new) +# endif +#else +# include <new.h> +#endif + +#if defined (_STLP_NO_BAD_ALLOC) && !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +#endif + +#if defined (_STLP_USE_EXCEPTIONS) && defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) + +# ifndef _STLP_INTERNAL_EXCEPTION +# include <stl/_exception.h> +# endif + +_STLP_BEGIN_NAMESPACE + +# if defined (_STLP_NO_BAD_ALLOC) +struct nothrow_t {}; +# define nothrow nothrow_t() +# endif + +/* + * STLport own bad_alloc exception to be used if the native C++ library + * do not define it or when the new operator do not throw it to avoid + * a useless library dependency. + */ +class bad_alloc : public exception { +public: + bad_alloc () _STLP_NOTHROW_INHERENTLY { } + bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { } + bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;} + ~bad_alloc () _STLP_NOTHROW_INHERENTLY { } + const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; } +}; + +_STLP_END_NAMESPACE + +#endif /* _STLP_USE_EXCEPTIONS && (_STLP_NO_BAD_ALLOC || _STLP_NEW_DONT_THROW_BAD_ALLOC) */ + +#if defined (_STLP_USE_OWN_NAMESPACE) + +_STLP_BEGIN_NAMESPACE + +# if !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +using _STLP_VENDOR_EXCEPT_STD::bad_alloc; +# endif + +# if !defined (_STLP_NO_BAD_ALLOC) +using _STLP_VENDOR_EXCEPT_STD::nothrow_t; +using _STLP_VENDOR_EXCEPT_STD::nothrow; +# if defined (_STLP_GLOBAL_NEW_HANDLER) +using ::new_handler; +using ::set_new_handler; +# else +using _STLP_VENDOR_EXCEPT_STD::new_handler; +using _STLP_VENDOR_EXCEPT_STD::set_new_handler; +# endif +# endif /* !_STLP_NO_BAD_ALLOC */ + +_STLP_END_NAMESPACE +#endif /* _STLP_USE_OWN_NAMESPACE */ + +#ifndef _STLP_THROW_BAD_ALLOC +# if !defined (_STLP_USE_EXCEPTIONS) +# ifndef _STLP_INTERNAL_CSTDIO +# include <stl/_cstdio.h> +# endif +# define _STLP_THROW_BAD_ALLOC puts("out of memory\n"); exit(1) +# else +# define _STLP_THROW_BAD_ALLOC _STLP_THROW(_STLP_STD::bad_alloc()) +# endif +#endif + +#if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW_BAD_ALLOC) +# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x; if (__y == 0) { _STLP_THROW_BAD_ALLOC; } return __y +#else +# define _STLP_CHECK_NULL_ALLOC(__x) return __x +#endif + +_STLP_BEGIN_NAMESPACE + +#if ((defined (__IBMCPP__) || defined (__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined (_STLP_DEBUG_ALLOC)) +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n, __FILE__, __LINE__)); } +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); } +#else +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator new(__n)); } +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); } +#endif +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_NEW */ + +/* + * Local Variables: + * mode:C++ + * End: + */ diff --git a/stlport/stlport/stl/_pair.h b/stlport/stlport/stl/_pair.h new file mode 100644 index 0000000..7038bb1 --- /dev/null +++ b/stlport/stlport/stl/_pair.h @@ -0,0 +1,182 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_PAIR_H +#define _STLP_INTERNAL_PAIR_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +# endif + +# if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC) +# include <stl/_move_construct_fwk.h> +# endif +#endif + +_STLP_BEGIN_NAMESPACE + +template <class _T1, class _T2> +struct pair { + typedef _T1 first_type; + typedef _T2 second_type; + + _T1 first; + _T2 second; +#if defined (_STLP_CONST_CONSTRUCTOR_BUG) + pair() {} +#else + pair() : first(_T1()), second(_T2()) {} +#endif + pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _U1, class _U2> + pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} + + pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {} +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) + pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)), + second(_STLP_PRIV _AsMoveSource(src.get().second)) + {} +#endif + + __TRIVIAL_DESTRUCTOR(pair) +}; + +template <class _T1, class _T2> +inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return __x.first == __y.first && __x.second == __y.second; } + +template <class _T1, class _T2> +inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { + return __x.first < __y.first || + (!(__y.first < __x.first) && __x.second < __y.second); +} + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template <class _T1, class _T2> +inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__x == __y); } + +template <class _T1, class _T2> +inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return __y < __x; } + +template <class _T1, class _T2> +inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__y < __x); } + +template <class _T1, class _T2> +inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) +{ return !(__x < __y); } +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS) +template <class _T1, class _T2, int _Sz> +inline pair<_T1, _T2 const*> make_pair(_T1 const& __x, + _T2 const (&__y)[_Sz]) +{ return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); } + +template <class _T1, class _T2, int _Sz> +inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz], + _T2 const& __y) +{ return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); } + +template <class _T1, class _T2, int _Sz1, int _Sz2> +inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1], + _T2 const (&__y)[_Sz2]) { + return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x), + static_cast<_T2 const*>(__y)); +} +#endif + +template <class _T1, class _T2> +inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y) +{ return pair<_T1, _T2>(__x, __y); } + +_STLP_END_NAMESPACE + +#if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +_STLP_BEGIN_RELOPS_NAMESPACE + +template <class _Tp> +inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) +{ return !(__x == __y); } + +template <class _Tp> +inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) +{ return __y < __x; } + +template <class _Tp> +inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) +{ return !(__y < __x); } + +template <class _Tp> +inline bool _STLP_CALL operator>=(const _Tp& __x, const _Tp& __y) +{ return !(__x < __y); } + +_STLP_END_RELOPS_NAMESPACE +#endif + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_BEGIN_NAMESPACE + +template <class _T1, class _T2> +struct __type_traits<pair<_T1, _T2> > { + typedef __type_traits<_T1> _T1Traits; + typedef __type_traits<_T2> _T2Traits; + typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor, + typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor; + typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor, + typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor; + typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator, + typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator; + typedef typename _Land2<typename _T1Traits::has_trivial_destructor, + typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _T1, class _T2> +struct __move_traits<pair<_T1, _T2> > + : _STLP_PRIV __move_traits_help1<_T1, _T2> {}; +# endif + +_STLP_END_NAMESPACE +#endif + +#endif /* _STLP_INTERNAL_PAIR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_prolog.h b/stlport/stlport/stl/_prolog.h new file mode 100644 index 0000000..9705c2c --- /dev/null +++ b/stlport/stlport/stl/_prolog.h @@ -0,0 +1,18 @@ +/* NOTE : this header has no guards and is MEANT for multiple inclusion! + * If you are using "header protection" option with your compiler, + * please also find #pragma which disables it and put it here, to + * allow reentrancy of this header. + */ + +#include <stl/_cprolog.h> + +/* Get all debug things, potentially only empty macros if none of + * the debug features available in user config file is activated. */ + /* Thanks to _STLP_OUTERMOST_HEADER_ID we hide _debug.h when C standard + * headers are included as some platforms (Win32) include C standard headers + * in an 'extern "C"' scope which do not accept the templates exposed + * in _debug.h. */ +#if defined (__cplusplus) && !defined (_STLP_DEBUG_H) && \ + !((_STLP_OUTERMOST_HEADER_ID >= 0x200) && (_STLP_OUTERMOST_HEADER_ID <= 0x300)) +# include <stl/debug/_debug.h> +#endif diff --git a/stlport/stlport/stl/_ptrs_specialize.h b/stlport/stlport/stl/_ptrs_specialize.h new file mode 100644 index 0000000..b9cb5d8 --- /dev/null +++ b/stlport/stlport/stl/_ptrs_specialize.h @@ -0,0 +1,83 @@ +#ifndef _STLP_PTRS_SPECIALIZE_H +#define _STLP_PTRS_SPECIALIZE_H + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || \ + (defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && !defined (_STLP_NO_ARROW_OPERATOR)) +# define _STLP_POINTERS_SPECIALIZE( _TpP ) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); } +#else +# ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +# endif + +// the following is a workaround for arrow operator problems +# if defined ( _STLP_NO_ARROW_OPERATOR ) +// User wants to disable proxy -> operators +# define _STLP_DEFINE_ARROW_OPERATOR +# else +// Compiler can handle generic -> operator. +# if defined (__BORLANDC__) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(*(*this)); } +# elif defined(__WATCOMC__) +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { reference x = operator*(); return &x; } +# else +# define _STLP_DEFINE_ARROW_OPERATOR pointer operator->() const { return &(operator*()); } +# endif +# endif /* _STLP_NO_ARROW_OPERATOR */ + +// Important pointers specializations + +# ifdef _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type) +# else +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type) _STLP_TEMPLATE_NULL struct __type_traits<_Type> : __type_traits_aux<__true_type> {}; +# define _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type*) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type*) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type**) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type* const *) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type**) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(_Type***) \ +_STLP_TYPE_TRAITS_POD_SPECIALIZE(const _Type***) +# endif + +# define _STLP_POINTERS_SPECIALIZE(_Type) _STLP_TYPE_TRAITS_POD_SPECIALIZE_V(_Type) + +_STLP_BEGIN_NAMESPACE + +# if !defined ( _STLP_NO_BOOL ) +_STLP_POINTERS_SPECIALIZE( bool ) +# endif +_STLP_TYPE_TRAITS_POD_SPECIALIZE_V(void) +# ifndef _STLP_NO_SIGNED_BUILTINS + _STLP_POINTERS_SPECIALIZE( signed char ) +# endif + _STLP_POINTERS_SPECIALIZE( char ) + _STLP_POINTERS_SPECIALIZE( unsigned char ) + _STLP_POINTERS_SPECIALIZE( short ) + _STLP_POINTERS_SPECIALIZE( unsigned short ) + _STLP_POINTERS_SPECIALIZE( int ) + _STLP_POINTERS_SPECIALIZE( unsigned int ) + _STLP_POINTERS_SPECIALIZE( long ) + _STLP_POINTERS_SPECIALIZE( unsigned long ) + _STLP_POINTERS_SPECIALIZE( float ) + _STLP_POINTERS_SPECIALIZE( double ) +# if !defined ( _STLP_NO_LONG_DOUBLE ) + _STLP_POINTERS_SPECIALIZE( long double ) +# endif +# if defined ( _STLP_LONG_LONG) + _STLP_POINTERS_SPECIALIZE( _STLP_LONG_LONG ) + _STLP_POINTERS_SPECIALIZE( unsigned _STLP_LONG_LONG ) +# endif +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) + _STLP_POINTERS_SPECIALIZE( wchar_t ) +# endif + +_STLP_END_NAMESPACE + +# undef _STLP_ARROW_SPECIALIZE +# undef _STLP_TYPE_TRAITS_POD_SPECIALIZE_V + +#endif +#endif diff --git a/stlport/stlport/stl/_range_errors.c b/stlport/stlport/stl/_range_errors.c new file mode 100644 index 0000000..87293be --- /dev/null +++ b/stlport/stlport/stl/_range_errors.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#if defined(_STLP_THROW_RANGE_ERRORS) +# if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_DONT_REDEFINE_STD) +// In this mode we are going to throw native exception so that catch of +// exception like std::runtime_error for instance will also catch exception +// thrown by STLport containers like stlport::vector or stlport::string. +# include <stdexcept> +# include <string> +# define _STLP_THROW_MSG(ex,msg) throw std::ex(msg) +# else +# if defined (__BUILDING_STLPORT) +# include <stdexcept> +# include <string> +# else +# ifndef _STLP_INTERNAL_STDEXCEPT +# include <stl/_stdexcept.h> +# endif +# ifndef _STLP_INTERNAL_STRING_H +# include <stl/_string.h> +# endif +# endif +# define _STLP_THROW_MSG(ex,msg) throw ex(msg) +# endif +#else +# if defined (__BUILDING_STLPORT) +# include <cstdlib> +# include <cstdio> +# else +# ifndef _STLP_INTERNAL_CSTDLIB +# include <stl/_cstdlib.h> +# endif +# ifndef _STLP_INTERNAL_CSTDIO +# include <stl/_cstdio.h> +# endif +# endif +# define _STLP_THROW_MSG(ex,msg) puts(msg),_STLP_ABORT() +#endif + +// For mode without library and throwing range errors, include the +// stdexcept header and throw the appropriate exceptions directly. + +#if defined (_STLP_EXTERN_RANGE_ERRORS) +# define _STLP_THROW_FUNCT_SPEC void _STLP_DECLSPEC +#else +# define _STLP_THROW_FUNCT_SPEC inline void +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg) +{ _STLP_THROW_MSG(runtime_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_range_error(const char* __msg) +{ _STLP_THROW_MSG(range_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg) +{ _STLP_THROW_MSG(out_of_range, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_length_error(const char* __msg) +{ _STLP_THROW_MSG(length_error, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg) +{ _STLP_THROW_MSG(invalid_argument, __msg); } + +_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg) +{ _STLP_THROW_MSG(overflow_error, __msg); } + +_STLP_END_NAMESPACE + +#undef _STLP_THROW_FUNCT_SPEC +#undef _STLP_THROW_MSG diff --git a/stlport/stlport/stl/_range_errors.h b/stlport/stlport/stl/_range_errors.h new file mode 100644 index 0000000..80df26a --- /dev/null +++ b/stlport/stlport/stl/_range_errors.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1999 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +#ifndef _STLP_RANGE_ERRORS_H +#define _STLP_RANGE_ERRORS_H + +// A few places in the STL throw range errors, using standard exception +// classes defined in <stdexcept>. This header file provides functions +// to throw those exception objects. + +// _STLP_DONT_THROW_RANGE_ERRORS is a hook so that users can disable +// this exception throwing. +#if defined (_STLP_CAN_THROW_RANGE_ERRORS) && defined (_STLP_USE_EXCEPTIONS) && \ + !defined (_STLP_DONT_THROW_RANGE_ERRORS) +# define _STLP_THROW_RANGE_ERRORS +#endif + +// For the STLport iostreams, only declaration here, definition is in the lib +#if !defined (_STLP_USE_NO_IOSTREAMS) && !defined (_STLP_EXTERN_RANGE_ERRORS) +# define _STLP_EXTERN_RANGE_ERRORS +#endif + +_STLP_BEGIN_NAMESPACE +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_runtime_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_range_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_out_of_range(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_length_error(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_invalid_argument(const char* __msg); +void _STLP_FUNCTION_THROWS _STLP_DECLSPEC _STLP_CALL __stl_throw_overflow_error(const char* __msg); + +#if defined (__DMC__) && !defined (_STLP_NO_EXCEPTIONS) +# pragma noreturn(__stl_throw_runtime_error) +# pragma noreturn(__stl_throw_range_error) +# pragma noreturn(__stl_throw_out_of_range) +# pragma noreturn(__stl_throw_length_error) +# pragma noreturn(__stl_throw_invalid_argument) +# pragma noreturn(__stl_throw_overflow_error) +#endif +_STLP_END_NAMESPACE + +#if !defined (_STLP_EXTERN_RANGE_ERRORS) +# include <stl/_range_errors.c> +#endif + +#endif /* _STLP_RANGE_ERRORS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_relops_cont.h b/stlport/stlport/stl/_relops_cont.h new file mode 100644 index 0000000..cd8ec05 --- /dev/null +++ b/stlport/stlport/stl/_relops_cont.h @@ -0,0 +1,29 @@ +// This is an implementation file which +// is intended to be included multiple times with different _STLP_ASSOCIATIVE_CONTAINER +// setting + +#if !defined (_STLP_EQUAL_OPERATOR_SPECIALIZED) +_STLP_TEMPLATE_HEADER +inline bool _STLP_CALL operator==(const _STLP_TEMPLATE_CONTAINER& __x, + const _STLP_TEMPLATE_CONTAINER& __y) { + return __x.size() == __y.size() && + equal(__x.begin(), __x.end(), __y.begin()); +} +#endif /* _STLP_EQUAL_OPERATOR_SPECIALIZED */ + +_STLP_TEMPLATE_HEADER +inline bool _STLP_CALL operator<(const _STLP_TEMPLATE_CONTAINER& __x, + const _STLP_TEMPLATE_CONTAINER& __y) { + return lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); +} + +_STLP_RELOPS_OPERATORS( _STLP_TEMPLATE_HEADER , _STLP_TEMPLATE_CONTAINER ) + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +_STLP_TEMPLATE_HEADER +inline void _STLP_CALL swap(_STLP_TEMPLATE_CONTAINER& __x, + _STLP_TEMPLATE_CONTAINER& __y) { + __x.swap(__y); +} +#endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */ diff --git a/stlport/stlport/stl/_set.h b/stlport/stlport/stl/_set.h new file mode 100644 index 0000000..a8f6862 --- /dev/null +++ b/stlport/stlport/stl/_set.h @@ -0,0 +1,412 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_SET_H +#define _STLP_INTERNAL_SET_H + +#ifndef _STLP_INTERNAL_TREE_H +# include <stl/_tree.h> +#endif + +#if !defined (_STLP_USE_PTR_SPECIALIZATIONS) + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits) + +template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class set +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<set<_Key, _Compare, _Alloc> > +#endif +{ + typedef set<_Key, _Compare, _Alloc> _Self; +public: +// typedefs: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +private: + //Specific iterator traits creation + typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree<key_type, key_compare, + value_type, _STLP_PRIV _Identity<value_type>, + _SetTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing set + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + + // allocation/deallocation +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit set(const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) +#else + set() + : _M_t(_Compare(), allocator_type()) {} + explicit set(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + set(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + set(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template <class _InputIterator> + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } +# endif + template <class _InputIterator> + set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#else + set(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + set(const value_type* __first, + const value_type* __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } + + set(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_unique(__first, __last); } + + set(const_iterator __first, const_iterator __last, const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + set(const _Self& __x) : _M_t(__x._M_t) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + set(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator begin() const { return _M_t.begin(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + pair<iterator,bool> insert(const value_type& __x) + { return _M_t.insert_unique(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_unique( __pos , __x); } +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_unique(__first, __last); } +#else + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_unique(__first, __last); } + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_unique(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase( __pos ); } + size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last ); } + void clear() { _M_t.clear(); } + + // set operations: + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1 ; } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator, iterator> equal_range(const _KT& __x) + { return _M_t.equal_range_unique(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range(const _KT& __x) const + { return _M_t.equal_range_unique(__x); } +}; + +//Specific iterator traits creation +_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits) + +template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > +class multiset +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<multiset<_Key, _Compare, _Alloc> > +#endif +{ + typedef multiset<_Key, _Compare, _Alloc> _Self; +public: + // typedefs: + + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + +private: + //Specific iterator traits creation + typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits; + +public: + //Following typedef have to be public for __move_traits specialization. + typedef _STLP_PRIV _Rb_tree<key_type, key_compare, + value_type, _STLP_PRIV _Identity<value_type>, + _MultisetTraits, _Alloc> _Rep_type; + + typedef typename _Rep_type::pointer pointer; + typedef typename _Rep_type::const_pointer const_pointer; + typedef typename _Rep_type::reference reference; + typedef typename _Rep_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::allocator_type allocator_type; + +private: + _Rep_type _M_t; // red-black tree representing multiset + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit multiset(const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) +#else + multiset() + : _M_t(_Compare(), allocator_type()) {} + explicit multiset(const _Compare& __comp) + : _M_t(__comp, allocator_type()) {} + multiset(const _Compare& __comp, const allocator_type& __a) +#endif + : _M_t(__comp, __a) {} + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + multiset(_InputIterator __first, _InputIterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + template <class _InputIterator> + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template <class _InputIterator> + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp) + : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } +# endif +#else + multiset(const value_type* __first, const value_type* __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + multiset(const value_type* __first, const value_type* __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } + + multiset(const_iterator __first, const_iterator __last) + : _M_t(_Compare(), allocator_type()) + { _M_t.insert_equal(__first, __last); } + + multiset(const_iterator __first, const_iterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + + multiset(const _Self& __x) : _M_t(__x._M_t) {} + _Self& operator=(const _Self& __x) { + _M_t = __x._M_t; + return *this; + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + multiset(__move_source<_Self> src) + : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} +#endif + + // accessors: + key_compare key_comp() const { return _M_t.key_comp(); } + value_compare value_comp() const { return _M_t.key_comp(); } + allocator_type get_allocator() const { return _M_t.get_allocator(); } + + iterator begin() { return _M_t.begin(); } + iterator end() { return _M_t.end(); } + const_iterator begin() const { return _M_t.begin(); } + const_iterator end() const { return _M_t.end(); } + reverse_iterator rbegin() { return _M_t.rbegin(); } + reverse_iterator rend() { return _M_t.rend(); } + const_reverse_iterator rbegin() const { return _M_t.rbegin(); } + const_reverse_iterator rend() const { return _M_t.rend(); } + bool empty() const { return _M_t.empty(); } + size_type size() const { return _M_t.size(); } + size_type max_size() const { return _M_t.max_size(); } + void swap(_Self& __x) { _M_t.swap(__x._M_t); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + // insert/erase + iterator insert(const value_type& __x) + { return _M_t.insert_equal(__x); } + iterator insert(iterator __pos, const value_type& __x) + { return _M_t.insert_equal(__pos, __x); } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(_InputIterator __first, _InputIterator __last) + { _M_t.insert_equal(__first, __last); } +#else + void insert(const value_type* __first, const value_type* __last) + { _M_t.insert_equal(__first, __last); } + void insert(const_iterator __first, const_iterator __last) + { _M_t.insert_equal(__first, __last); } +#endif /* _STLP_MEMBER_TEMPLATES */ + void erase(iterator __pos) { _M_t.erase( __pos ); } + size_type erase(const key_type& __x) { return _M_t.erase(__x); } + void erase(iterator __first, iterator __last) { _M_t.erase( __first, __last ); } + void clear() { _M_t.clear(); } + + // multiset operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __x) { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __x) const { return _M_t.find(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { return _M_t.count(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator, iterator> equal_range(const _KT& __x) { return _M_t.equal_range(__x); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { return _M_t.equal_range(__x); } +}; + +#else +# include <stl/pointers/_set.h> +_STLP_BEGIN_NAMESPACE +#endif /* _STLP_USE_PTR_SPECIALIZATIONS */ + +#define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Key, class _Compare, class _Alloc> +struct __move_traits<set<_Key,_Compare,_Alloc> > : + _STLP_PRIV __move_traits_aux<typename set<_Key,_Compare,_Alloc>::_Rep_type> +{}; + +template <class _Key, class _Compare, class _Alloc> +struct __move_traits<multiset<_Key,_Compare,_Alloc> > : + _STLP_PRIV __move_traits_aux<typename multiset<_Key,_Compare,_Alloc>::_Rep_type> +{}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_SET_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_stlport_version.h b/stlport/stlport/stl/_stlport_version.h new file mode 100644 index 0000000..587651d --- /dev/null +++ b/stlport/stlport/stl/_stlport_version.h @@ -0,0 +1,30 @@ + /* + * + * Copyright (c) 2005 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_STLPORT_VERSION_H +#define _STLP_STLPORT_VERSION_H + +/* The last SGI STL release we merged with */ +#define __SGI_STL 0x330 + +/* STLport version */ +#define _STLPORT_MAJOR 5 +#define _STLPORT_MINOR 2 +#define _STLPORT_PATCHLEVEL 1 + +#define _STLPORT_VERSION 0x521 + +#endif /* _STLP_STLPORT_VERSION_H */ diff --git a/stlport/stlport/stl/_stream_iterator.h b/stlport/stlport/stl/_stream_iterator.h new file mode 100644 index 0000000..aa26ae3 --- /dev/null +++ b/stlport/stlport/stl/_stream_iterator.h @@ -0,0 +1,253 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#if !defined (_STLP_INTERNAL_STREAM_ITERATOR_H) && !defined (_STLP_USE_NO_IOSTREAMS) +#define _STLP_INTERNAL_STREAM_ITERATOR_H + +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include <stl/_iterator_base.h> +#endif + +// streambuf_iterators predeclarations must appear first +#ifndef _STLP_INTERNAL_IOSFWD +# include <stl/_iosfwd.h> +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H +# include <stl/_ostreambuf_iterator.h> +#endif + +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H +# include <stl/_istreambuf_iterator.h> +#endif + +#ifndef _STLP_INTERNAL_ISTREAM +# include <stl/_istream.h> +#endif + +// istream_iterator and ostream_iterator look very different if we're +// using new, templatized iostreams than if we're using the old cfront +// version. + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp, class _CharT, class _Traits, class _Dist +# define __ISI_TMPL_ARGUMENTS _Tp, _CharT, _Traits, _Dist +template <class _Tp, + class _CharT = char, class _Traits = char_traits<_CharT>, + class _Dist = ptrdiff_t> +class istream_iterator : public iterator<input_iterator_tag, _Tp , _Dist, + const _Tp*, const _Tp& > { +#else +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp +# define __ISI_TMPL_ARGUMENTS _Tp +template <class _Tp> +class istream_iterator : public iterator<input_iterator_tag, _Tp , ptrdiff_t, + const _Tp*, const _Tp& > { +# else +# define __ISI_TMPL_HEADER_ARGUMENTS class _Tp, class _Dist +# define __ISI_TMPL_ARGUMENTS _Tp, _Dist +template <class _Tp, _STLP_DFL_TYPE_PARAM(_Dist, ptrdiff_t)> +class istream_iterator : public iterator<input_iterator_tag, _Tp, _Dist , + const _Tp*, const _Tp& > { +# endif /* _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS */ +#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */ + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) + typedef char _CharT; + typedef char_traits<char> _Traits; +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) + typedef ptrdiff_t _Dist; +# endif +#endif + + typedef istream_iterator< __ISI_TMPL_ARGUMENTS > _Self; +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT, _Traits> istream_type; + + typedef input_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Dist difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + istream_iterator() : _M_stream(0), _M_ok(false), _M_read_done(true) {} + istream_iterator(istream_type& __s) : _M_stream(&__s), _M_ok(false), _M_read_done(false) {} + + reference operator*() const { + if (!_M_read_done) { + _M_read(); + } + return _M_value; + } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + _M_read(); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + _M_read(); + return __tmp; + } + + bool _M_equal(const _Self& __x) const { + if (!_M_read_done) { + _M_read(); + } + if (!__x._M_read_done) { + __x._M_read(); + } + return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); + } + +private: + istream_type* _M_stream; + mutable _Tp _M_value; + mutable bool _M_ok; + mutable bool _M_read_done; + + void _M_read() const { + _STLP_MUTABLE(_Self, _M_ok) = ((_M_stream != 0) && !_M_stream->fail()); + if (_M_ok) { + *_M_stream >> _STLP_MUTABLE(_Self, _M_value); + _STLP_MUTABLE(_Self, _M_ok) = !_M_stream->fail(); + } + _STLP_MUTABLE(_Self, _M_read_done) = true; + } +}; + +#if !defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template <class _TpP, + class _CharT = char, class _Traits = char_traits<_CharT> > +#else +template <class _TpP> +#endif +class ostream_iterator: public iterator<output_iterator_tag, void, void, void, void> { +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) + typedef char _CharT; + typedef char_traits<char> _Traits; + typedef ostream_iterator<_TpP> _Self; +#else + typedef ostream_iterator<_TpP, _CharT, _Traits> _Self; +#endif +public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + + typedef output_iterator_tag iterator_category; + + ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {} + ostream_iterator(ostream_type& __s, const _CharT* __c) + : _M_stream(&__s), _M_string(__c) {} + _Self& operator=(const _TpP& __val) { + *_M_stream << __val; + if (_M_string) *_M_stream << _M_string; + return *this; + } + _Self& operator*() { return *this; } + _Self& operator++() { return *this; } + _Self& operator++(int) { return *this; } +private: + ostream_type* _M_stream; + const _CharT* _M_string; +}; + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +# if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +template <class _TpP> +inline output_iterator_tag _STLP_CALL +iterator_category(const ostream_iterator<_TpP>&) { return output_iterator_tag(); } +# else +template <class _TpP, class _CharT, class _Traits> +inline output_iterator_tag _STLP_CALL +iterator_category(const ostream_iterator<_TpP, _CharT, _Traits>&) { return output_iterator_tag(); } +# endif +#endif + +_STLP_END_NAMESPACE + +// form-independent definiotion of stream iterators +_STLP_BEGIN_NAMESPACE + +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline bool _STLP_CALL +operator==(const istream_iterator< __ISI_TMPL_ARGUMENTS >& __x, + const istream_iterator< __ISI_TMPL_ARGUMENTS >& __y) +{ return __x._M_equal(__y); } + +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline bool _STLP_CALL +operator!=(const istream_iterator< __ISI_TMPL_ARGUMENTS >& __x, + const istream_iterator< __ISI_TMPL_ARGUMENTS >& __y) +{ return !__x._M_equal(__y); } +#endif + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline input_iterator_tag _STLP_CALL +iterator_category(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) +{ return input_iterator_tag(); } +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline _Tp* _STLP_CALL +value_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (_Tp*) 0; } + +# if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_DEFAULT_TYPE_PARAM) +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline ptrdiff_t* _STLP_CALL +distance_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (ptrdiff_t*)0; } +# else +template < __ISI_TMPL_HEADER_ARGUMENTS > +inline _Dist* _STLP_CALL +distance_type(const istream_iterator< __ISI_TMPL_ARGUMENTS >&) { return (_Dist*)0; } +# endif /* _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS */ +#endif + +_STLP_END_NAMESPACE + +#undef __ISI_TMPL_HEADER_ARGUMENTS +#undef __ISI_TMPL_ARGUMENTS + +#endif /* _STLP_INTERNAL_STREAM_ITERATOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_tree.c b/stlport/stlport/stl/_tree.c new file mode 100644 index 0000000..818fcc4 --- /dev/null +++ b/stlport/stlport/stl/_tree.c @@ -0,0 +1,730 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Modified CRP 7/10/00 for improved conformance / efficiency on insert_unique / + * insert_equal with valid hint -- efficiency is improved all around, and it is + * should now be standard conforming for complexity on insert point immediately + * after hint (amortized constant time). + * + */ +#ifndef _STLP_TREE_C +#define _STLP_TREE_C + +#ifndef _STLP_INTERNAL_TREE_H +# include <stl/_tree.h> +#endif + +#if defined (_STLP_DEBUG) +# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) +#endif + +// fbp: these defines are for outline methods definitions. +// needed for definitions to be portable. Should not be used in method bodies. +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define __iterator__ _Rb_tree_iterator<_Value, _STLP_HEADER_TYPENAME _Traits::_NonConstTraits> +# define __size_type__ size_t +# define iterator __iterator__ +#else +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc>::iterator +# define __size_type__ _STLP_TYPENAME_ON_RETURN_TYPE _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc>::size_type +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) + +template <class _Dummy> void _STLP_CALL +_Rb_global<_Dummy>::_Rotate_left(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + _Rb_tree_node_base* __y = __x->_M_right; + __x->_M_right = __y->_M_left; + if (__y->_M_left != 0) + __y->_M_left->_M_parent = __x; + __y->_M_parent = __x->_M_parent; + + if (__x == __root) + __root = __y; + else if (__x == __x->_M_parent->_M_left) + __x->_M_parent->_M_left = __y; + else + __x->_M_parent->_M_right = __y; + __y->_M_left = __x; + __x->_M_parent = __y; +} + +template <class _Dummy> void _STLP_CALL +_Rb_global<_Dummy>::_Rotate_right(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + _Rb_tree_node_base* __y = __x->_M_left; + __x->_M_left = __y->_M_right; + if (__y->_M_right != 0) + __y->_M_right->_M_parent = __x; + __y->_M_parent = __x->_M_parent; + + if (__x == __root) + __root = __y; + else if (__x == __x->_M_parent->_M_right) + __x->_M_parent->_M_right = __y; + else + __x->_M_parent->_M_left = __y; + __y->_M_right = __x; + __x->_M_parent = __y; +} + +template <class _Dummy> void _STLP_CALL +_Rb_global<_Dummy>::_Rebalance(_Rb_tree_node_base* __x, + _Rb_tree_node_base*& __root) { + __x->_M_color = _S_rb_tree_red; + while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) { + if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) { + _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right; + if (__y && __y->_M_color == _S_rb_tree_red) { + __x->_M_parent->_M_color = _S_rb_tree_black; + __y->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + __x = __x->_M_parent->_M_parent; + } + else { + if (__x == __x->_M_parent->_M_right) { + __x = __x->_M_parent; + _Rotate_left(__x, __root); + } + __x->_M_parent->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + _Rotate_right(__x->_M_parent->_M_parent, __root); + } + } + else { + _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left; + if (__y && __y->_M_color == _S_rb_tree_red) { + __x->_M_parent->_M_color = _S_rb_tree_black; + __y->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + __x = __x->_M_parent->_M_parent; + } + else { + if (__x == __x->_M_parent->_M_left) { + __x = __x->_M_parent; + _Rotate_right(__x, __root); + } + __x->_M_parent->_M_color = _S_rb_tree_black; + __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red; + _Rotate_left(__x->_M_parent->_M_parent, __root); + } + } + } + __root->_M_color = _S_rb_tree_black; +} + +template <class _Dummy> _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_Rebalance_for_erase(_Rb_tree_node_base* __z, + _Rb_tree_node_base*& __root, + _Rb_tree_node_base*& __leftmost, + _Rb_tree_node_base*& __rightmost) { + _Rb_tree_node_base* __y = __z; + _Rb_tree_node_base* __x; + _Rb_tree_node_base* __x_parent; + + if (__y->_M_left == 0) // __z has at most one non-null child. y == z. + __x = __y->_M_right; // __x might be null. + else { + if (__y->_M_right == 0) // __z has exactly one non-null child. y == z. + __x = __y->_M_left; // __x is not null. + else { // __z has two non-null children. Set __y to + __y = _Rb_tree_node_base::_S_minimum(__y->_M_right); // __z's successor. __x might be null. + __x = __y->_M_right; + } + } + + if (__y != __z) { // relink y in place of z. y is z's successor + __z->_M_left->_M_parent = __y; + __y->_M_left = __z->_M_left; + if (__y != __z->_M_right) { + __x_parent = __y->_M_parent; + if (__x) __x->_M_parent = __y->_M_parent; + __y->_M_parent->_M_left = __x; // __y must be a child of _M_left + __y->_M_right = __z->_M_right; + __z->_M_right->_M_parent = __y; + } + else + __x_parent = __y; + if (__root == __z) + __root = __y; + else if (__z->_M_parent->_M_left == __z) + __z->_M_parent->_M_left = __y; + else + __z->_M_parent->_M_right = __y; + __y->_M_parent = __z->_M_parent; + _STLP_STD::swap(__y->_M_color, __z->_M_color); + __y = __z; + // __y now points to node to be actually deleted + } + else { // __y == __z + __x_parent = __y->_M_parent; + if (__x) __x->_M_parent = __y->_M_parent; + if (__root == __z) + __root = __x; + else { + if (__z->_M_parent->_M_left == __z) + __z->_M_parent->_M_left = __x; + else + __z->_M_parent->_M_right = __x; + } + + if (__leftmost == __z) { + if (__z->_M_right == 0) // __z->_M_left must be null also + __leftmost = __z->_M_parent; + // makes __leftmost == _M_header if __z == __root + else + __leftmost = _Rb_tree_node_base::_S_minimum(__x); + } + if (__rightmost == __z) { + if (__z->_M_left == 0) // __z->_M_right must be null also + __rightmost = __z->_M_parent; + // makes __rightmost == _M_header if __z == __root + else // __x == __z->_M_left + __rightmost = _Rb_tree_node_base::_S_maximum(__x); + } + } + + if (__y->_M_color != _S_rb_tree_red) { + while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black)) + if (__x == __x_parent->_M_left) { + _Rb_tree_node_base* __w = __x_parent->_M_right; + if (__w->_M_color == _S_rb_tree_red) { + __w->_M_color = _S_rb_tree_black; + __x_parent->_M_color = _S_rb_tree_red; + _Rotate_left(__x_parent, __root); + __w = __x_parent->_M_right; + } + if ((__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black) && (__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black)) { + __w->_M_color = _S_rb_tree_red; + __x = __x_parent; + __x_parent = __x_parent->_M_parent; + } else { + if (__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black) { + if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; + __w->_M_color = _S_rb_tree_red; + _Rotate_right(__w, __root); + __w = __x_parent->_M_right; + } + __w->_M_color = __x_parent->_M_color; + __x_parent->_M_color = _S_rb_tree_black; + if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; + _Rotate_left(__x_parent, __root); + break; + } + } else { // same as above, with _M_right <-> _M_left. + _Rb_tree_node_base* __w = __x_parent->_M_left; + if (__w->_M_color == _S_rb_tree_red) { + __w->_M_color = _S_rb_tree_black; + __x_parent->_M_color = _S_rb_tree_red; + _Rotate_right(__x_parent, __root); + __w = __x_parent->_M_left; + } + if ((__w->_M_right == 0 || + __w->_M_right->_M_color == _S_rb_tree_black) && (__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black)) { + __w->_M_color = _S_rb_tree_red; + __x = __x_parent; + __x_parent = __x_parent->_M_parent; + } else { + if (__w->_M_left == 0 || + __w->_M_left->_M_color == _S_rb_tree_black) { + if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black; + __w->_M_color = _S_rb_tree_red; + _Rotate_left(__w, __root); + __w = __x_parent->_M_left; + } + __w->_M_color = __x_parent->_M_color; + __x_parent->_M_color = _S_rb_tree_black; + if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black; + _Rotate_right(__x_parent, __root); + break; + } + } + if (__x) __x->_M_color = _S_rb_tree_black; + } + return __y; +} + +template <class _Dummy> _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_M_decrement(_Rb_tree_node_base* _M_node) { + if (_M_node->_M_color == _S_rb_tree_red && _M_node->_M_parent->_M_parent == _M_node) + _M_node = _M_node->_M_right; + else if (_M_node->_M_left != 0) { + _M_node = _Rb_tree_node_base::_S_maximum(_M_node->_M_left); + } + else { + _Base_ptr __y = _M_node->_M_parent; + while (_M_node == __y->_M_left) { + _M_node = __y; + __y = __y->_M_parent; + } + _M_node = __y; + } + return _M_node; +} + +template <class _Dummy> _Rb_tree_node_base* _STLP_CALL +_Rb_global<_Dummy>::_M_increment(_Rb_tree_node_base* _M_node) { + if (_M_node->_M_right != 0) { + _M_node = _Rb_tree_node_base::_S_minimum(_M_node->_M_right); + } + else { + _Base_ptr __y = _M_node->_M_parent; + while (_M_node == __y->_M_right) { + _M_node = __y; + __y = __y->_M_parent; + } + // check special case: This is necessary if _M_node is the + // _M_head and the tree contains only a single node __y. In + // that case parent, left and right all point to __y! + if (_M_node->_M_right != __y) + _M_node = __y; + } + return _M_node; +} + +#endif /* _STLP_EXPOSE_GLOBALS_IMPLEMENTATION */ + + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>& +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::operator=( + const _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>& __x) { + if (this != &__x) { + // Note that _Key may be a constant type. + clear(); + _M_node_count = 0; + _M_key_compare = __x._M_key_compare; + if (__x._M_root() == 0) { + _M_root() = 0; + _M_leftmost() = &this->_M_header._M_data; + _M_rightmost() = &this->_M_header._M_data; + } + else { + _M_root() = _M_copy(__x._M_root(), &this->_M_header._M_data); + _M_leftmost() = _S_minimum(_M_root()); + _M_rightmost() = _S_maximum(_M_root()); + _M_node_count = __x._M_node_count; + } + } + return *this; +} + +// CRP 7/10/00 inserted argument __on_right, which is another hint (meant to +// act like __on_left and ignore a portion of the if conditions -- specify +// __on_right != 0 to bypass comparison as false or __on_left != 0 to bypass +// comparison as true) +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::_M_insert(_Rb_tree_node_base * __parent, + const _Value& __val, + _Rb_tree_node_base * __on_left, + _Rb_tree_node_base * __on_right) { + // We do not create the node here as, depending on tests, we might call + // _M_key_compare that can throw an exception. + _Base_ptr __new_node; + + if ( __parent == &this->_M_header._M_data ) { + __new_node = _M_create_node(__val); + _S_left(__parent) = __new_node; // also makes _M_leftmost() = __new_node + _M_root() = __new_node; + _M_rightmost() = __new_node; + } + else if ( __on_right == 0 && // If __on_right != 0, the remainder fails to false + ( __on_left != 0 || // If __on_left != 0, the remainder succeeds to true + _M_key_compare( _KeyOfValue()(__val), _S_key(__parent) ) ) ) { + __new_node = _M_create_node(__val); + _S_left(__parent) = __new_node; + if (__parent == _M_leftmost()) + _M_leftmost() = __new_node; // maintain _M_leftmost() pointing to min node + } + else { + __new_node = _M_create_node(__val); + _S_right(__parent) = __new_node; + if (__parent == _M_rightmost()) + _M_rightmost() = __new_node; // maintain _M_rightmost() pointing to max node + } + _S_parent(__new_node) = __parent; + _Rb_global_inst::_Rebalance(__new_node, this->_M_header._M_data._M_parent); + ++_M_node_count; + return iterator(__new_node); +} + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_equal(const _Value& __val) { + _Base_ptr __y = &this->_M_header._M_data; + _Base_ptr __x = _M_root(); + while (__x != 0) { + __y = __x; + if (_M_key_compare(_KeyOfValue()(__val), _S_key(__x))) { + __x = _S_left(__x); + } + else + __x = _S_right(__x); + } + return _M_insert(__y, __val, __x); +} + + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +pair<__iterator__, bool> +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_unique(const _Value& __val) { + _Base_ptr __y = &this->_M_header._M_data; + _Base_ptr __x = _M_root(); + bool __comp = true; + while (__x != 0) { + __y = __x; + __comp = _M_key_compare(_KeyOfValue()(__val), _S_key(__x)); + __x = __comp ? _S_left(__x) : _S_right(__x); + } + iterator __j = iterator(__y); + if (__comp) { + if (__j == begin()) + return pair<iterator,bool>(_M_insert(__y, __val, /* __x*/ __y), true); + else + --__j; + } + if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__val))) { + return pair<iterator,bool>(_M_insert(__y, __val, __x), true); + } + return pair<iterator,bool>(__j, false); +} + +// Modifications CRP 7/10/00 as noted to improve conformance and +// efficiency. +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_unique(iterator __position, + const _Value& __val) { + if (__position._M_node == this->_M_header._M_data._M_left) { // begin() + + // if the container is empty, fall back on insert_unique. + if (empty()) + return insert_unique(__val).first; + + if (_M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node))) { + return _M_insert(__position._M_node, __val, __position._M_node); + } + // first argument just needs to be non-null + else { + bool __comp_pos_v = _M_key_compare( _S_key(__position._M_node), _KeyOfValue()(__val) ); + + if (__comp_pos_v == false) // compare > and compare < both false so compare equal + return __position; + //Below __comp_pos_v == true + + // Standard-conformance - does the insertion point fall immediately AFTER + // the hint? + iterator __after = __position; + ++__after; + + // Check for only one member -- in that case, __position points to itself, + // and attempting to increment will cause an infinite loop. + if (__after._M_node == &this->_M_header._M_data) + // Check guarantees exactly one member, so comparison was already + // performed and we know the result; skip repeating it in _M_insert + // by specifying a non-zero fourth argument. + return _M_insert(__position._M_node, __val, 0, __position._M_node); + + // All other cases: + + // Optimization to catch insert-equivalent -- save comparison results, + // and we get this for free. + if (_M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) )) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { + return insert_unique(__val).first; + } + } + } + else if (__position._M_node == &this->_M_header._M_data) { // end() + if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__val))) { + // pass along to _M_insert that it can skip comparing + // v, Key ; since compare Key, v was true, compare v, Key must be false. + return _M_insert(_M_rightmost(), __val, 0, __position._M_node); // Last argument only needs to be non-null + } + else + return insert_unique(__val).first; + } + else { + iterator __before = __position; + --__before; + + bool __comp_v_pos = _M_key_compare(_KeyOfValue()(__val), _S_key(__position._M_node)); + + if (__comp_v_pos + && _M_key_compare( _S_key(__before._M_node), _KeyOfValue()(__val) )) { + + if (_S_right(__before._M_node) == 0) + return _M_insert(__before._M_node, __val, 0, __before._M_node); // Last argument only needs to be non-null + else + return _M_insert(__position._M_node, __val, __position._M_node); + // first argument just needs to be non-null + } + else { + // Does the insertion point fall immediately AFTER the hint? + iterator __after = __position; + ++__after; + // Optimization to catch equivalent cases and avoid unnecessary comparisons + bool __comp_pos_v = !__comp_v_pos; // Stored this result earlier + // If the earlier comparison was true, this comparison doesn't need to be + // performed because it must be false. However, if the earlier comparison + // was false, we need to perform this one because in the equal case, both will + // be false. + if (!__comp_v_pos) { + __comp_pos_v = _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val)); + } + + if ( (!__comp_v_pos) // comp_v_pos true implies comp_v_pos false + && __comp_pos_v + && (__after._M_node == &this->_M_header._M_data || + _M_key_compare( _KeyOfValue()(__val), _S_key(__after._M_node) ))) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } else { + // Test for equivalent case + if (__comp_v_pos == __comp_pos_v) + return __position; + else + return insert_unique(__val).first; + } + } + } +} + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +__iterator__ +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::insert_equal(iterator __position, + const _Value& __val) { + if (__position._M_node == this->_M_header._M_data._M_left) { // begin() + + // Check for zero members + if (size() <= 0) + return insert_equal(__val); + + if (!_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val))) + return _M_insert(__position._M_node, __val, __position._M_node); + else { + // Check for only one member + if (__position._M_node->_M_left == __position._M_node) + // Unlike insert_unique, can't avoid doing a comparison here. + return _M_insert(__position._M_node, __val); + + // All other cases: + // Standard-conformance - does the insertion point fall immediately AFTER + // the hint? + iterator __after = __position; + ++__after; + + // Already know that compare(pos, v) must be true! + // Therefore, we want to know if compare(after, v) is false. + // (i.e., we now pos < v, now we want to know if v <= after) + // If not, invalid hint. + if ( __after._M_node == &this->_M_header._M_data || + !_M_key_compare( _S_key(__after._M_node), _KeyOfValue()(__val) ) ) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { // Invalid hint + return insert_equal(__val); + } + } + } + else if (__position._M_node == &this->_M_header._M_data) { // end() + if (!_M_key_compare(_KeyOfValue()(__val), _S_key(_M_rightmost()))) + return _M_insert(_M_rightmost(), __val, 0, __position._M_node); // Last argument only needs to be non-null + else { + return insert_equal(__val); + } + } + else { + iterator __before = __position; + --__before; + // store the result of the comparison between pos and v so + // that we don't have to do it again later. Note that this reverses the shortcut + // on the if, possibly harming efficiency in comparisons; I think the harm will + // be negligible, and to do what I want to do (save the result of a comparison so + // that it can be re-used) there is no alternative. Test here is for before <= v <= pos. + bool __comp_pos_v = _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__val)); + if (!__comp_pos_v && + !_M_key_compare(_KeyOfValue()(__val), _S_key(__before._M_node))) { + if (_S_right(__before._M_node) == 0) + return _M_insert(__before._M_node, __val, 0, __before._M_node); // Last argument only needs to be non-null + else + return _M_insert(__position._M_node, __val, __position._M_node); + } + else { + // Does the insertion point fall immediately AFTER the hint? + // Test for pos < v <= after + iterator __after = __position; + ++__after; + + if (__comp_pos_v && + ( __after._M_node == &this->_M_header._M_data || + !_M_key_compare( _S_key(__after._M_node), _KeyOfValue()(__val) ) ) ) { + if (_S_right(__position._M_node) == 0) + return _M_insert(__position._M_node, __val, 0, __position._M_node); + else + return _M_insert(__after._M_node, __val, __after._M_node); + } + else { // Invalid hint + return insert_equal(__val); + } + } + } +} + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +_Rb_tree_node_base* +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> ::_M_copy(_Rb_tree_node_base* __x, + _Rb_tree_node_base* __p) { + // structural copy. __x and __p must be non-null. + _Base_ptr __top = _M_clone_node(__x); + _S_parent(__top) = __p; + + _STLP_TRY { + if (_S_right(__x)) + _S_right(__top) = _M_copy(_S_right(__x), __top); + __p = __top; + __x = _S_left(__x); + + while (__x != 0) { + _Base_ptr __y = _M_clone_node(__x); + _S_left(__p) = __y; + _S_parent(__y) = __p; + if (_S_right(__x)) + _S_right(__y) = _M_copy(_S_right(__x), __y); + __p = __y; + __x = _S_left(__x); + } + } + _STLP_UNWIND(_M_erase(__top)) + + return __top; +} + +// this has to stay out-of-line : it's recursive +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +void +_Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::_M_erase(_Rb_tree_node_base *__x) { + // erase without rebalancing + while (__x != 0) { + _M_erase(_S_right(__x)); + _Base_ptr __y = _S_left(__x); + _STLP_STD::_Destroy(&_S_value(__x)); + this->_M_header.deallocate(__STATIC_CAST(_Link_type, __x),1); + __x = __y; + } +} + +#if defined (_STLP_DEBUG) +inline int +__black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root) { + if (__node == 0) + return 0; + else { + int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0; + if (__node == __root) + return __bc; + else + return __bc + __black_count(__node->_M_parent, __root); + } +} + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, class _Alloc> +bool _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc>::__rb_verify() const { + if (_M_node_count == 0 || begin() == end()) + return ((_M_node_count == 0) && + (begin() == end()) && + (this->_M_header._M_data._M_left == &this->_M_header._M_data) && + (this->_M_header._M_data._M_right == &this->_M_header._M_data)); + + int __len = __black_count(_M_leftmost(), _M_root()); + for (const_iterator __it = begin(); __it != end(); ++__it) { + _Base_ptr __x = __it._M_node; + _Base_ptr __L = _S_left(__x); + _Base_ptr __R = _S_right(__x); + + if (__x->_M_color == _S_rb_tree_red) + if ((__L && __L->_M_color == _S_rb_tree_red) || + (__R && __R->_M_color == _S_rb_tree_red)) + return false; + + if (__L && _M_key_compare(_S_key(__x), _S_key(__L))) + return false; + if (__R && _M_key_compare(_S_key(__R), _S_key(__x))) + return false; + + if (!__L && !__R && __black_count(__x, _M_root()) != __len) + return false; + } + + if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) + return false; + if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) + return false; + + return true; +} +#endif /* _STLP_DEBUG */ + +_STLP_MOVE_TO_STD_NAMESPACE +_STLP_END_NAMESPACE + +#undef _Rb_tree +#undef __iterator__ +#undef iterator +#undef __size_type__ + +#endif /* _STLP_TREE_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_tree.h b/stlport/stlport/stl/_tree.h new file mode 100644 index 0000000..bf05901 --- /dev/null +++ b/stlport/stlport/stl/_tree.h @@ -0,0 +1,684 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_TREE_H +#define _STLP_INTERNAL_TREE_H + +/* + +Red-black tree class, designed for use in implementing STL +associative containers (set, multiset, map, and multimap). The +insertion and deletion algorithms are based on those in Cormen, +Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990), +except that + +(1) the header cell is maintained with links not only to the root +but also to the leftmost node of the tree, to enable constant time +begin(), and to the rightmost node of the tree, to enable linear time +performance when used with the generic set algorithms (set_union, +etc.); + +(2) when a node being deleted has two children its successor node is +relinked into its place, rather than copied, so that the only +iterators invalidated are those referring to the deleted node. + +*/ + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include <stl/_alloc.h> +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include <stl/_iterator.h> +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include <stl/_construct.h> +#endif + +#ifndef _STLP_INTERNAL_FUNCTION_BASE_H +# include <stl/_function_base.h> +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +typedef bool _Rb_tree_Color_type; +//const _Rb_tree_Color_type _S_rb_tree_red = false; +//const _Rb_tree_Color_type _S_rb_tree_black = true; + +#define _S_rb_tree_red false +#define _S_rb_tree_black true + +struct _Rb_tree_node_base { + typedef _Rb_tree_Color_type _Color_type; + typedef _Rb_tree_node_base* _Base_ptr; + + _Color_type _M_color; + _Base_ptr _M_parent; + _Base_ptr _M_left; + _Base_ptr _M_right; + + static _Base_ptr _STLP_CALL _S_minimum(_Base_ptr __x) { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Base_ptr _STLP_CALL _S_maximum(_Base_ptr __x) { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } +}; + +template <class _Value> +struct _Rb_tree_node : public _Rb_tree_node_base { + _Value _M_value_field; + __TRIVIAL_STUFF(_Rb_tree_node) +}; + +struct _Rb_tree_base_iterator; + +template <class _Dummy> +class _Rb_global { +public: + typedef _Rb_tree_node_base* _Base_ptr; + // those used to be global functions + static void _STLP_CALL _Rebalance(_Base_ptr __x, _Base_ptr& __root); + static _Base_ptr _STLP_CALL _Rebalance_for_erase(_Base_ptr __z, + _Base_ptr& __root, + _Base_ptr& __leftmost, + _Base_ptr& __rightmost); + // those are from _Rb_tree_base_iterator - moved here to reduce code bloat + // moved here to reduce code bloat without templatizing _Rb_tree_base_iterator + static _Base_ptr _STLP_CALL _M_increment (_Base_ptr); + static _Base_ptr _STLP_CALL _M_decrement (_Base_ptr); + static void _STLP_CALL _Rotate_left (_Base_ptr __x, _Base_ptr& __root); + static void _STLP_CALL _Rotate_right(_Base_ptr __x, _Base_ptr& __root); +}; + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS _Rb_global<bool>; +# endif + +typedef _Rb_global<bool> _Rb_global_inst; + +struct _Rb_tree_base_iterator { + typedef _Rb_tree_node_base* _Base_ptr; + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + _Base_ptr _M_node; + _Rb_tree_base_iterator() : _M_node(0) {} + _Rb_tree_base_iterator(_Base_ptr __x) : _M_node(__x) {} +}; + +template <class _Value, class _Traits> +struct _Rb_tree_iterator : public _Rb_tree_base_iterator { + typedef _Value value_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + typedef _Rb_tree_iterator<_Value, _Traits> _Self; + typedef _Rb_tree_node_base* _Base_ptr; + typedef _Rb_tree_node<_Value>* _Link_type; + + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef _Rb_tree_iterator<_Value, _NonConstTraits> iterator; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Rb_tree_iterator<_Value, _ConstTraits> const_iterator; + + _Rb_tree_iterator() {} +#if !defined (_STLP_DEBUG) + /* In STL debug mode we need this constructor implicit for the pointer + * specialization implementation. + */ + explicit +#endif + _Rb_tree_iterator(_Base_ptr __x) : _Rb_tree_base_iterator(__x) {} + //copy constructor for iterator and constructor from iterator for const_iterator + _Rb_tree_iterator(const iterator& __it) : _Rb_tree_base_iterator(__it._M_node) {} + + reference operator*() const { + return __STATIC_CAST(_Link_type, _M_node)->_M_value_field; + } + + _STLP_DEFINE_ARROW_OPERATOR + + _Self& operator++() { + _M_node = _Rb_global_inst::_M_increment(_M_node); + return *this; + } + _Self operator++(int) { + _Self __tmp = *this; + ++(*this); + return __tmp; + } + + _Self& operator--() { + _M_node = _Rb_global_inst::_M_decrement(_M_node); + return *this; + } + _Self operator--(int) { + _Self __tmp = *this; + --(*this); + return __tmp; + } + + bool operator == (const_iterator __rhs) const { + return _M_node == __rhs._M_node; + } + bool operator != (const_iterator __rhs) const { + return _M_node != __rhs._M_node; + } +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +_STLP_MOVE_TO_STD_NAMESPACE +template <class _Value, class _Traits> +struct __type_traits<_STLP_PRIV _Rb_tree_iterator<_Value, _Traits> > { + typedef __false_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES) +_STLP_MOVE_TO_STD_NAMESPACE +template <class _Value, class _Traits> +inline _Value* value_type(const _STLP_PRIV _Rb_tree_iterator<_Value, _Traits>&) +{ return (_Value*)0; } +inline bidirectional_iterator_tag iterator_category(const _STLP_PRIV _Rb_tree_base_iterator&) +{ return bidirectional_iterator_tag(); } +inline ptrdiff_t* distance_type(const _STLP_PRIV _Rb_tree_base_iterator&) +{ return (ptrdiff_t*) 0; } +_STLP_MOVE_TO_PRIV_NAMESPACE +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +// Base class to help EH + +template <class _Tp, class _Alloc> +class _Rb_tree_base { +public: + typedef _Rb_tree_node_base _Node_base; + typedef _Rb_tree_node<_Tp> _Node; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; +private: + typedef _Rb_tree_base<_Tp, _Alloc> _Self; + typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator_type; + typedef _STLP_alloc_proxy<_Node_base, _Node, _M_node_allocator_type> _AllocProxy; + +public: + allocator_type get_allocator() const { + return _STLP_CONVERT_ALLOCATOR(_M_header, _Tp); + } + +protected: + _Rb_tree_base(const allocator_type& __a) : + _M_header(_STLP_CONVERT_ALLOCATOR(__a, _Node), _Node_base() ) { + _M_empty_initialize(); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Rb_tree_base(__move_source<_Self> src) : + _M_header(__move_source<_AllocProxy>(src.get()._M_header)) { + _M_rebind(&src.get()._M_header._M_data); + src.get()._M_empty_initialize(); + } +#endif + + void _M_empty_initialize() { + _M_header._M_data._M_color = _S_rb_tree_red; // used to distinguish header from + // __root, in iterator.operator++ + _M_header._M_data._M_parent = 0; + _M_header._M_data._M_left = &_M_header._M_data; + _M_header._M_data._M_right = &_M_header._M_data; + } + + void _M_rebind(_Node_base *__static_node) { + if (_M_header._M_data._M_parent != 0) { + _M_header._M_data._M_parent->_M_parent = &_M_header._M_data; + } + if (_M_header._M_data._M_right == __static_node) { + _M_header._M_data._M_right = &_M_header._M_data; + } + if (_M_header._M_data._M_left == __static_node) { + _M_header._M_data._M_left = &_M_header._M_data; + } + } + + _AllocProxy _M_header; +}; + +#if defined (_STLP_DEBUG) +# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) +#endif + +template <class _Key, class _Compare, + class _Value, class _KeyOfValue, class _Traits, + _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) > +class _Rb_tree : public _Rb_tree_base<_Value, _Alloc> { + typedef _Rb_tree_base<_Value, _Alloc> _Base; + typedef _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> _Self; +protected: + typedef _Rb_tree_node_base * _Base_ptr; + typedef _Rb_tree_node<_Value> _Node; + typedef _Node* _Link_type; + typedef _Rb_tree_Color_type _Color_type; +public: + typedef _Key key_type; + typedef _Value value_type; + typedef typename _Traits::pointer pointer; + typedef const value_type* const_pointer; + typedef typename _Traits::reference reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef bidirectional_iterator_tag _Iterator_category; + typedef typename _Base::allocator_type allocator_type; + +protected: + + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + _Base_ptr _M_create_node(const value_type& __x) { + _Link_type __tmp = this->_M_header.allocate(1); + _STLP_TRY { + _Copy_Construct(&__tmp->_M_value_field, __x); + } + _STLP_UNWIND(this->_M_header.deallocate(__tmp,1)) + _S_left(__tmp) = 0; + _S_right(__tmp) = 0; + return __tmp; + } + + _Base_ptr _M_clone_node(_Base_ptr __x) { + _Base_ptr __tmp = _M_create_node(_S_value(__x)); + _S_color(__tmp) = _S_color(__x); + return __tmp; + } + + size_type _M_node_count; // keeps track of size of tree + _Compare _M_key_compare; + + _Base_ptr _M_root() const + { return this->_M_header._M_data._M_parent; } + _Base_ptr _M_leftmost() const + { return this->_M_header._M_data._M_left; } + _Base_ptr _M_rightmost() const + { return this->_M_header._M_data._M_right; } + + _Base_ptr& _M_root() + { return this->_M_header._M_data._M_parent; } + _Base_ptr& _M_leftmost() + { return this->_M_header._M_data._M_left; } + _Base_ptr& _M_rightmost() + { return this->_M_header._M_data._M_right; } + + static _Base_ptr& _STLP_CALL _S_left(_Base_ptr __x) + { return __x->_M_left; } + static _Base_ptr& _STLP_CALL _S_right(_Base_ptr __x) + { return __x->_M_right; } + static _Base_ptr& _STLP_CALL _S_parent(_Base_ptr __x) + { return __x->_M_parent; } + static value_type& _STLP_CALL _S_value(_Base_ptr __x) + { return __STATIC_CAST(_Link_type, __x)->_M_value_field; } + static const _Key& _STLP_CALL _S_key(_Base_ptr __x) + { return _KeyOfValue()(_S_value(__x));} + static _Color_type& _STLP_CALL _S_color(_Base_ptr __x) + { return (_Color_type&)(__x->_M_color); } + + static _Base_ptr _STLP_CALL _S_minimum(_Base_ptr __x) + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Base_ptr _STLP_CALL _S_maximum(_Base_ptr __x) + { return _Rb_tree_node_base::_S_maximum(__x); } + +public: + typedef typename _Traits::_NonConstTraits _NonConstTraits; + typedef typename _Traits::_ConstTraits _ConstTraits; + typedef _Rb_tree_iterator<value_type, _NonConstTraits> iterator; + typedef _Rb_tree_iterator<value_type, _ConstTraits> const_iterator; + _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; + +private: + iterator _M_insert(_Base_ptr __parent, const value_type& __val, _Base_ptr __on_left = 0, _Base_ptr __on_right = 0); + _Base_ptr _M_copy(_Base_ptr __x, _Base_ptr __p); + void _M_erase(_Base_ptr __x); + +public: + // allocation/deallocation + _Rb_tree() + : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(_Compare()) + {} + + _Rb_tree(const _Compare& __comp) + : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(__comp) + {} + + _Rb_tree(const _Compare& __comp, const allocator_type& __a) + : _Rb_tree_base<_Value, _Alloc>(__a), _M_node_count(0), _M_key_compare(__comp) + {} + + _Rb_tree(const _Self& __x) + : _Rb_tree_base<_Value, _Alloc>(__x.get_allocator()), + _M_node_count(0), _M_key_compare(__x._M_key_compare) { + if (__x._M_root() != 0) { + _S_color(&this->_M_header._M_data) = _S_rb_tree_red; + _M_root() = _M_copy(__x._M_root(), &this->_M_header._M_data); + _M_leftmost() = _S_minimum(_M_root()); + _M_rightmost() = _S_maximum(_M_root()); + } + _M_node_count = __x._M_node_count; + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Rb_tree(__move_source<_Self> src) + : _Rb_tree_base<_Value, _Alloc>(__move_source<_Base>(src.get())), + _M_node_count(src.get()._M_node_count), + _M_key_compare(_AsMoveSource(src.get()._M_key_compare)) + { src.get()._M_node_count = 0; } +#endif + + ~_Rb_tree() { clear(); } + _Self& operator=(const _Self& __x); + +public: + // accessors: + _Compare key_comp() const { return _M_key_compare; } + + iterator begin() { return iterator(_M_leftmost()); } + const_iterator begin() const { return const_iterator(_M_leftmost()); } + iterator end() { return iterator(&this->_M_header._M_data); } + const_iterator end() const { return const_iterator(__CONST_CAST(_Base_ptr, &this->_M_header._M_data)); } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const + { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const + { return const_reverse_iterator(begin()); } + bool empty() const { return _M_node_count == 0; } + size_type size() const { return _M_node_count; } + size_type max_size() const { return size_type(-1); } + + void swap(_Self& __t) { + if (__t.empty()) { + if (this->empty()) return; + __t._M_header.swap(this->_M_header); + __t._M_rebind(&this->_M_header._M_data); + this->_M_empty_initialize(); + } + else if (this->empty()) { + __t.swap(*this); + return; + } + else { + this->_M_header.swap(__t._M_header); + this->_M_rebind(&__t._M_header._M_data); + __t._M_rebind(&this->_M_header._M_data); + } + _STLP_STD::swap(_M_node_count, __t._M_node_count); + _STLP_STD::swap(_M_key_compare, __t._M_key_compare); + } + +public: + // insert/erase + pair<iterator,bool> insert_unique(const value_type& __x); + iterator insert_equal(const value_type& __x); + + iterator insert_unique(iterator __pos, const value_type& __x); + iterator insert_equal(iterator __pos, const value_type& __x); + +#if defined (_STLP_MEMBER_TEMPLATES) + template<class _II> void insert_equal(_II __first, _II __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } + template<class _II> void insert_unique(_II __first, _II __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } +#else + void insert_unique(const_iterator __first, const_iterator __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } + void insert_unique(const value_type* __first, const value_type* __last) { + for ( ; __first != __last; ++__first) + insert_unique(*__first); + } + void insert_equal(const_iterator __first, const_iterator __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } + void insert_equal(const value_type* __first, const value_type* __last) { + for ( ; __first != __last; ++__first) + insert_equal(*__first); + } +#endif + + void erase(iterator __pos) { + _Base_ptr __x = _Rb_global_inst::_Rebalance_for_erase(__pos._M_node, + this->_M_header._M_data._M_parent, + this->_M_header._M_data._M_left, + this->_M_header._M_data._M_right); + _STLP_STD::_Destroy(&_S_value(__x)); + this->_M_header.deallocate(__STATIC_CAST(_Link_type, __x), 1); + --_M_node_count; + } + + size_type erase(const key_type& __x) { + pair<iterator,iterator> __p = equal_range(__x); + size_type __n = _STLP_STD::distance(__p.first, __p.second); + erase(__p.first, __p.second); + return __n; + } + + size_type erase_unique(const key_type& __x) { + iterator __i = find(__x); + if (__i._M_node != &this->_M_header._M_data) { + erase(__i); + return 1; + } + return 0; + } + + void erase(iterator __first, iterator __last) { + if (__first._M_node == this->_M_header._M_data._M_left && // begin() + __last._M_node == &this->_M_header._M_data) // end() + clear(); + else + while (__first != __last) erase(__first++); + } + + void erase(const key_type* __first, const key_type* __last) { + while (__first != __last) erase(*__first++); + } + + void clear() { + if (_M_node_count != 0) { + _M_erase(_M_root()); + _M_leftmost() = &this->_M_header._M_data; + _M_root() = 0; + _M_rightmost() = &this->_M_header._M_data; + _M_node_count = 0; + } + } + +public: + // set operations: + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __k) { return iterator(_M_find(__k)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __k) const { return const_iterator(_M_find(__k)); } +private: + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_find(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); // Last node which is not less than __k. + _Base_ptr __x = _M_root(); // Current node. + + while (__x != 0) + if (!_M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + if (__y != &this->_M_header._M_data) { + if (_M_key_compare(__k, _S_key(__y))) { + __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); + } + } + return __y; + } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_lower_bound(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); /* Last node which is not less than __k. */ + _Base_ptr __x = _M_root(); /* Current node. */ + + while (__x != 0) + if (!_M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + return __y; + } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Base_ptr _M_upper_bound(const _KT& __k) const { + _Base_ptr __y = __CONST_CAST(_Base_ptr, &this->_M_header._M_data); /* Last node which is greater than __k. */ + _Base_ptr __x = _M_root(); /* Current node. */ + + while (__x != 0) + if (_M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + + return __y; + } + +public: + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __x) const { + pair<const_iterator, const_iterator> __p = equal_range(__x); + return _STLP_STD::distance(__p.first, __p.second); + } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator lower_bound(const _KT& __x) { return iterator(_M_lower_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator lower_bound(const _KT& __x) const { return const_iterator(_M_lower_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + iterator upper_bound(const _KT& __x) { return iterator(_M_upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator upper_bound(const _KT& __x) const { return const_iterator(_M_upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator,iterator> equal_range(const _KT& __x) + { return pair<iterator, iterator>(lower_bound(__x), upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range(const _KT& __x) const + { return pair<const_iterator, const_iterator>(lower_bound(__x), upper_bound(__x)); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator,iterator> equal_range_unique(const _KT& __x) { + pair<iterator, iterator> __p; + __p.second = lower_bound(__x); + if (__p.second._M_node != &this->_M_header._M_data && + !_M_key_compare(__x, _S_key(__p.second._M_node))) { + __p.first = __p.second++; + } + else { + __p.first = __p.second; + } + return __p; + } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range_unique(const _KT& __x) const { + pair<const_iterator, const_iterator> __p; + __p.second = lower_bound(__x); + if (__p.second._M_node != &this->_M_header._M_data && + !_M_key_compare(__x, _S_key(__p.second._M_node))) { + __p.first = __p.second++; + } + else { + __p.first = __p.second; + } + return __p; + } + +#if defined (_STLP_DEBUG) +public: + // Debugging. + bool __rb_verify() const; +#endif //_STLP_DEBUG +}; + +#if defined (_STLP_DEBUG) +# undef _Rb_tree +#endif + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/_tree.c> +#endif + +#if defined (_STLP_DEBUG) +# include <stl/debug/_tree.h> +#endif + +_STLP_BEGIN_NAMESPACE + +#define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Value, class _KeyOfValue, class _Traits, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER _STLP_PRIV _Rb_tree<_Key,_Compare,_Value,_KeyOfValue,_Traits,_Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Key, class _Compare, class _Value, class _KeyOfValue, class _Traits, class _Alloc> +struct __move_traits<_STLP_PRIV _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> > + : _STLP_PRIV __move_traits_help2<_Compare, _Alloc> {}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_TREE_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_uninitialized.h b/stlport/stlport/stl/_uninitialized.h new file mode 100644 index 0000000..5489a94 --- /dev/null +++ b/stlport/stlport/stl/_uninitialized.h @@ -0,0 +1,443 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +#define _STLP_INTERNAL_UNINITIALIZED_H + +#ifndef _STLP_INTERNAL_CSTRING +# include <stl/_cstring.h> +#endif + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include <stl/_construct.h> +#endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// uninitialized_copy + +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, _Distance*) { + _OutputIter __cur = __result; + _STLP_TRY { + for ( ; __first != __last; ++__first, ++__cur) + _Param_Construct(&*__cur, *__first); + return __cur; + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW(__cur) +} + +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const input_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const forward_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } + +template <class _InputIter, class _OutputIter, class _Distance> +inline _OutputIter __ucopy(_InputIter __first, _InputIter __last, + _OutputIter __result, const bidirectional_iterator_tag &, _Distance* __d) +{ return __ucopy(__first, __last, __result, __d); } +#endif + +template <class _RandomAccessIter, class _OutputIter, class _Distance> +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last, + _OutputIter __result, const random_access_iterator_tag &, _Distance*) { + _OutputIter __cur = __result; + _STLP_TRY { + for (_Distance __n = __last - __first; __n > 0; --__n) { + _Param_Construct(&*__cur, *__first); + ++__first; + ++__cur; + } + return __cur; + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW(__cur) +} + +//Used internaly +template <class _RandomAccessIter, class _OutputIter> +inline _OutputIter __ucopy(_RandomAccessIter __first, _RandomAccessIter __last, _OutputIter __result) +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); } + +inline void* +__ucopy_trivial(const void* __first, const void* __last, void* __result) { + //dums: this version can use memcpy (__copy_trivial can't) + return (__last == __first) ? __result : + ((char*)memcpy(__result, __first, ((const char*)__last - (const char*)__first))) + + ((const char*)__last - (const char*)__first); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*TrivialUCopy*/) +{ return __ucopy(__first, __last, __result, random_access_iterator_tag(), (ptrdiff_t*)0); } + +template <class _InputIter, class _OutputIter> +inline _OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*TrivialUCopy*/) { + // we know they all pointers, so this cast is OK + // return (_OutputIter)__copy_trivial(&(*__first), &(*__last), &(*__result)); + return (_OutputIter)__ucopy_trivial(__first, __last, __result); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __true_type& /*BothPtrType*/) { + return __ucopy_ptrs(__first, __last, __result, + _UseTrivialUCopy(_STLP_VALUE_TYPE(__first, _InputIter), + _STLP_VALUE_TYPE(__result, _OutputIter))._Answer()); +} + +template <class _InputIter, class _OutputIter> +inline _OutputIter __ucopy_aux(_InputIter __first, _InputIter __last, _OutputIter __result, + const __false_type& /*BothPtrType*/) { + return __ucopy(__first, __last, __result, + _STLP_ITERATOR_CATEGORY(__first, _InputIter), + _STLP_DISTANCE_TYPE(__first, _InputIter)); +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _ForwardIter> +inline _ForwardIter +uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_aux(__first, __last, __result, _BothPtrType< _InputIter, _ForwardIter>::_Answer()); } + +inline char* +uninitialized_copy(const char* __first, const char* __last, char* __result) +{ return (char*)_STLP_PRIV __ucopy_trivial(__first, __last, __result); } + +# if defined (_STLP_HAS_WCHAR_T) // dwa 8/15/97 +inline wchar_t* +uninitialized_copy(const wchar_t* __first, const wchar_t* __last, wchar_t* __result) +{ return (wchar_t*)_STLP_PRIV __ucopy_trivial (__first, __last, __result); } +# endif + +// uninitialized_copy_n (not part of the C++ standard) +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter, class _Size, class _ForwardIter> +_STLP_INLINE_LOOP +pair<_InputIter, _ForwardIter> +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result, + const input_iterator_tag &) { + _ForwardIter __cur = __result; + _STLP_TRY { + for ( ; __count > 0 ; --__count, ++__first, ++__cur) + _Param_Construct(&*__cur, *__first); + return pair<_InputIter, _ForwardIter>(__first, __cur); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __cur)) + _STLP_RET_AFTER_THROW((pair<_InputIter, _ForwardIter>(__first, __cur))) +} + +# if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _InputIter, class _Size, class _ForwardIterator> +inline pair<_InputIter, _ForwardIterator> +__ucopy_n(_InputIter __first, _Size __count, + _ForwardIterator __result, + const forward_iterator_tag &) +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); } + +template <class _InputIter, class _Size, class _ForwardIterator> +inline pair<_InputIter, _ForwardIterator> +__ucopy_n(_InputIter __first, _Size __count, + _ForwardIterator __result, + const bidirectional_iterator_tag &) +{ return __ucopy_n(__first, __count, __result, input_iterator_tag()); } +# endif + +template <class _RandomAccessIter, class _Size, class _ForwardIter> +inline pair<_RandomAccessIter, _ForwardIter> +__ucopy_n(_RandomAccessIter __first, _Size __count, _ForwardIter __result, + const random_access_iterator_tag &) { + _RandomAccessIter __last = __first + __count; + return pair<_RandomAccessIter, _ForwardIter>(__last, uninitialized_copy(__first, __last, __result)); +} + +// This is used internally in <rope> , which is extension itself. +template <class _InputIter, class _Size, class _ForwardIter> +inline pair<_InputIter, _ForwardIter> +__ucopy_n(_InputIter __first, _Size __count, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_n(__first, __count, __result, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + +#if !defined (_STLP_NO_EXTENSIONS) + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _InputIter, class _Size, class _ForwardIter> +inline pair<_InputIter, _ForwardIter> +uninitialized_copy_n(_InputIter __first, _Size __count, _ForwardIter __result) +{ return _STLP_PRIV __ucopy_n(__first, __count, __result); } + +_STLP_MOVE_TO_PRIV_NAMESPACE + +#endif + +template <class _ForwardIter, class _Tp, class _Distance> +inline void __ufill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x, _Distance*) { + _ForwardIter __cur = __first; + _STLP_TRY { + for ( ; __cur != __last; ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) +} + +template <class _ForwardIter, class _Tp, class _Distance> +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const input_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _ForwardIter, class _Tp, class _Distance> +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const forward_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } + +template <class _ForwardIter, class _Tp, class _Distance> +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const bidirectional_iterator_tag &, _Distance* __d) +{ __ufill(__first, __last, __x, __d); } +#endif + +template <class _ForwardIter, class _Tp, class _Distance> +inline void __ufill(_ForwardIter __first, _ForwardIter __last, + const _Tp& __x, const random_access_iterator_tag &, _Distance*) { + _ForwardIter __cur = __first; + _STLP_TRY { + for (_Distance __n = __last - __first; __n > 0; --__n, ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) +} + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _ForwardIter, class _Tp> +inline void uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp& __x) { + _STLP_PRIV __ufill(__first, __last, __x, + _STLP_ITERATOR_CATEGORY(__first, _ForwardIter), + _STLP_DISTANCE_TYPE(__first, _ForwardIter)); +} + +// Specialization: for one-byte types we can use memset. +inline void uninitialized_fill(unsigned char* __first, unsigned char* __last, + const unsigned char& __val) { + unsigned char __tmp = __val; + memset(__first, __tmp, __last - __first); +} +#if !defined (_STLP_NO_SIGNED_BUILTINS) +inline void uninitialized_fill(signed char* __first, signed char* __last, + const signed char& __val) { + signed char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} +#endif +inline void uninitialized_fill(char* __first, char* __last, const char& __val) { + char __tmp = __val; + memset(__first, __STATIC_CAST(unsigned char,__tmp), __last - __first); +} + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x) { + _ForwardIter __cur = __first; + _STLP_TRY { + for ( ; __n > 0; --__n, ++__cur) + _Param_Construct(&*__cur, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first, __cur)) + return __cur; +} + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const input_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } + +#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG) +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const forward_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const bidirectional_iterator_tag &) +{ return __ufill_n(__first, __n, __x); } +#endif + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) { + _ForwardIter __last = __first + __n; + __ufill(__first, __last, __x, random_access_iterator_tag(), (ptrdiff_t*)0); + return __last; +} + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __ufill_n(_ForwardIter __first, _Size __n, const _Tp& __x, + const random_access_iterator_tag &) +{ return __uninitialized_fill_n(__first, __n, __x); } + +/* __uninitialized_init is an internal algo to init a range with a value + * built using default constructor. It is only called with pointer as + * iterator. + */ +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& __val, + const __false_type& /*_HasDefaultZero*/) +{ return __uninitialized_fill_n(__first, __n, __val); } + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uinit_aux_aux(_ForwardIter __first, _Size __n, const _Tp& /* __val */, + const __true_type& /*_HasDefaultZero*/) { + memset((unsigned char*)__first, 0, __n * sizeof(_Tp)); + return __first + __n; +} + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp&, + const __true_type& /*_TrivialInit*/) +{ return __first + __n; } + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uinit_aux(_ForwardIter __first, _Size __n, const _Tp& __val, + const __false_type& /*_TrivialInit*/) +{ return __uinit_aux_aux(__first, __n, __val, _HasDefaultZeroValue(__first)._Answer()); } + +template <class _ForwardIter, class _Size, class _Tp> +inline _ForwardIter __uninitialized_init(_ForwardIter __first, _Size __n, const _Tp& __val) +{ return __uinit_aux(__first, __n, __val, _UseTrivialInit(__first)._Answer()); } + +_STLP_MOVE_TO_STD_NAMESPACE + +template <class _ForwardIter, class _Size, class _Tp> +inline void +uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp& __x) +{ _STLP_PRIV __ufill_n(__first, __n, __x, _STLP_ITERATOR_CATEGORY(__first, _ForwardIter)); } + +// Extensions: __uninitialized_copy_copy, __uninitialized_copy_fill, +// __uninitialized_fill_copy. + +// __uninitialized_copy_copy +// Copies [first1, last1) into [result, result + (last1 - first1)), and +// copies [first2, last2) into +// [result + (last1 - first1), result + (last1 - first1) + (last2 - first2)). + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _InputIter1, class _InputIter2, class _ForwardIter> +inline _ForwardIter +__uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, + _InputIter2 __first2, _InputIter2 __last2, + _ForwardIter __result) { + _ForwardIter __new_result = uninitialized_copy(__first1, __last1, __result); + _STLP_TRY { + return uninitialized_copy(__first2, __last2, __new_result); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __new_result)) + _STLP_RET_AFTER_THROW(__result) +} + +// __uninitialized_fill_copy +// Fills [result, mid) with x, and copies [first, last) into +// [mid, mid + (last - first)). +template <class _ForwardIter, class _Tp, class _InputIter> +inline _ForwardIter +__uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp& __x, + _InputIter __first, _InputIter __last) { + uninitialized_fill(__result, __mid, __x); + _STLP_TRY { + return uninitialized_copy(__first, __last, __mid); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__result, __mid)) + _STLP_RET_AFTER_THROW(__result) +} + +// __uninitialized_copy_fill +// Copies [first1, last1) into [first2, first2 + (last1 - first1)), and +// fills [first2 + (last1 - first1), last2) with x. +template <class _Iter, class _Tp> +inline void +__uninitialized_copy_fill(_Iter __first1, _Iter __last1, _Iter __first2, _Iter __last2, + const _Tp& __x) { + _Iter __mid2 = uninitialized_copy(__first1, __last1, __first2); + _STLP_TRY { + uninitialized_fill(__mid2, __last2, __x); + } + _STLP_UNWIND(_STLP_STD::_Destroy_Range(__first2, __mid2)) +} + +/* __uninitialized_move: + * This function is used internaly and only with pointers as iterators. + */ +template <class _InputIter, class _ForwardIter, class _TrivialUCpy> +inline _ForwardIter +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result, + _TrivialUCpy __trivial_ucpy, const __false_type& /*_Movable*/) +{ return __ucopy_ptrs(__first, __last, __result, __trivial_ucpy); } + +template <class _InputIter, class _ForwardIter, class _TrivialUCpy> +_STLP_INLINE_LOOP +_ForwardIter +__uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result, + _TrivialUCpy , const __true_type& /*_Movable*/) { + //Move constructor should not throw so we do not need to take care of exceptions here. + for (ptrdiff_t __n = __last - __first ; __n > 0; --__n) { + _Move_Construct(&*__result, *__first); + ++__first; ++__result; + } + return __result; +} + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_UNINITIALIZED_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_unordered_map.h b/stlport/stlport/stl/_unordered_map.h new file mode 100644 index 0000000..f2b017d --- /dev/null +++ b/stlport/stlport/stl/_unordered_map.h @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2004 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_UNORDERED_MAP_H +#define _STLP_INTERNAL_UNORDERED_MAP_H + +#ifndef _STLP_INTERNAL_HASHTABLE_H +# include <stl/_hashtable.h> +#endif + +_STLP_BEGIN_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMapTraitsT, traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class unordered_map +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> > +#endif +{ +private: + typedef unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedMapTraitsT<value_type> _UnorderedMapTraits; + +public: + typedef hashtable<value_type, key_type, _HashFcn, _UnorderedMapTraits, + _STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_map(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_map(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + unordered_map(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#else + unordered_map(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + unordered_map(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + pair<iterator,bool> insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_unique(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_unique(__f,__l); } + void insert(const_iterator __f, const_iterator __l) +#endif /*_STLP_MEMBER_TEMPLATES */ + { _M_ht.insert_unique(__f, __l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + _Tp& operator[](const _KT& __key) { + iterator __it = _M_ht.find(__key); + return (__it == _M_ht.end() ? + _M_ht._M_insert(value_type(__key, _STLP_DEFAULT_CONSTRUCTED(_Tp))).second : + (*__it).second ); + } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator, iterator> equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } + +#if defined (__DMC__) // disable operator==(pair<x,unordered_map>, pair<x,unordered_map>) + bool operator==(const _Self&) const; +#endif +}; + +_STLP_END_NAMESPACE + +//Specific iterator traits creation +_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultimapTraitsT, traits) + +_STLP_BEGIN_TR1_NAMESPACE + +template <class _Key, class _Tp, _STLP_DFL_TMPL_PARAM(_HashFcn,hash<_Key>), + _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>), + _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > +class unordered_multimap +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) + : public __stlport_class<unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> > +#endif +{ +private: + typedef unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; +public: + typedef _Key key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef pair<_STLP_CONST key_type, data_type> value_type; +private: + //Specific iterator traits creation + typedef _STLP_PRIV _UnorderedMultimapTraitsT<value_type> _UnorderedMultimapTraits; + +public: + typedef hashtable<value_type, key_type, _HashFcn, _UnorderedMultimapTraits, + _STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht; + + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + typedef typename _Ht::local_iterator local_iterator; + typedef typename _Ht::const_local_iterator const_local_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher hash_function() const { return _M_ht.hash_funct(); } + key_equal key_eq() const { return _M_ht.key_eq(); } + allocator_type get_allocator() const { return _M_ht.get_allocator(); } + +private: + _Ht _M_ht; + _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) + +public: + explicit unordered_multimap(size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + unordered_multimap(__move_source<_Self> src) + : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + unordered_multimap(_InputIterator __f, _InputIterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#else + unordered_multimap(const value_type* __f, const value_type* __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + unordered_multimap(const_iterator __f, const_iterator __l, + size_type __n = 0, const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } +#endif /*_STLP_MEMBER_TEMPLATES */ + + _Self& operator = (const _Self& __other) + { _M_ht = __other._M_ht; return *this; } + + size_type size() const { return _M_ht.size(); } + size_type max_size() const { return _M_ht.max_size(); } + bool empty() const { return _M_ht.empty(); } + void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + + iterator begin() { return _M_ht.begin(); } + iterator end() { return _M_ht.end(); } + const_iterator begin() const { return _M_ht.begin(); } + const_iterator end() const { return _M_ht.end(); } + + iterator insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + iterator insert(const_iterator /*__hint*/, const value_type& __obj) + { return _M_ht.insert_equal(__obj); } +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void insert(_InputIterator __f, _InputIterator __l) +#else + void insert(const value_type* __f, const value_type* __l) + { _M_ht.insert_equal(__f,__l); } + void insert(const_iterator __f, const_iterator __l) +#endif /*_STLP_MEMBER_TEMPLATES */ + { _M_ht.insert_equal(__f, __l); } + + _STLP_TEMPLATE_FOR_CONT_EXT + iterator find(const _KT& __key) { return _M_ht.find(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + const_iterator find(const _KT& __key) const { return _M_ht.find(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + size_type count(const _KT& __key) const { return _M_ht.count(__key); } + + _STLP_TEMPLATE_FOR_CONT_EXT + pair<iterator, iterator> equal_range(const _KT& __key) + { return _M_ht.equal_range(__key); } + _STLP_TEMPLATE_FOR_CONT_EXT + pair<const_iterator, const_iterator> equal_range(const _KT& __key) const + { return _M_ht.equal_range(__key); } + + size_type erase(const key_type& __key) {return _M_ht.erase(__key); } + void erase(const_iterator __it) { _M_ht.erase(__it); } + void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } + void clear() { _M_ht.clear(); } + + size_type bucket_count() const { return _M_ht.bucket_count(); } + size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } + size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } + _STLP_TEMPLATE_FOR_CONT_EXT + size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } + local_iterator begin(size_type __n) { return _M_ht.begin(__n); } + local_iterator end(size_type __n) { return _M_ht.end(__n); } + const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } + const_local_iterator end(size_type __n) const { return _M_ht.end(__n); } + + float load_factor() const { return _M_ht.load_factor(); } + float max_load_factor() const { return _M_ht.max_load_factor(); } + void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } + void rehash(size_type __hint) { _M_ht.rehash(__hint); } +}; + +#define _STLP_TEMPLATE_HEADER template <class _Key, class _Tp, class _HashFcn, class _EqlKey, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER unordered_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> + +#include <stl/_relops_hash_cont.h> + +#undef _STLP_TEMPLATE_CONTAINER +#define _STLP_TEMPLATE_CONTAINER unordered_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> + +#include <stl/_relops_hash_cont.h> + +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +_STLP_END_NAMESPACE + +// Specialization of insert_iterator so that it will work for unordered_map +// and unordered_multimap. + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> +struct __move_traits<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > : + _STLP_PRIV __move_traits_help<typename _STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht> +{}; + +template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> +struct __move_traits<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > : + _STLP_PRIV __move_traits_help<typename _STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>::_Ht> +{}; +# endif + +template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> +class insert_iterator<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> +class insert_iterator<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { +protected: + typedef _STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; + _Container* container; + typename _Container::iterator iter; +public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) : container(&__x) {} + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __val) { + container->insert(__val); + return *this; + } + insert_iterator<_Container>& operator*() { return *this; } + insert_iterator<_Container>& operator++() { return *this; } + insert_iterator<_Container>& operator++(int) { return *this; } +}; + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_INTERNAL_UNORDERED_MAP_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_vector.c b/stlport/stlport/stl/_vector.c new file mode 100644 index 0000000..705f786 --- /dev/null +++ b/stlport/stlport/stl/_vector.c @@ -0,0 +1,242 @@ +/* + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ +#ifndef _STLP_VECTOR_C +#define _STLP_VECTOR_C + +#if !defined (_STLP_INTERNAL_VECTOR_H) +# include <stl/_vector.h> +#endif + +#include <stl/_range_errors.h> + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp, class _Alloc> +void _Vector_base<_Tp,_Alloc>::_M_throw_length_error() const +{ __stl_throw_length_error("vector"); } + +template <class _Tp, class _Alloc> +void _Vector_base<_Tp, _Alloc>::_M_throw_out_of_range() const +{ __stl_throw_out_of_range("vector"); } + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define vector _STLP_PTR_IMPL_NAME(vector) +#elif defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define __iterator__ _Tp* +#else +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE vector<_Tp, _Alloc>::iterator +#endif + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::reserve(size_type __n) { + if (capacity() < __n) { + if (max_size() < __n) { + this->_M_throw_length_error(); + } + + const size_type __old_size = size(); + pointer __tmp; + if (this->_M_start) { + __tmp = _M_allocate_and_copy(__n, this->_M_start, this->_M_finish); + _M_clear(); + } else { + __tmp = this->_M_end_of_storage.allocate(__n, __n); + } + _M_set(__tmp, __tmp + __old_size, __tmp + __n); + } +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*DO NOT USE!!*/, + size_type __fill_len, bool __atend ) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __len = _M_compute_next_size(__fill_len); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __new_start; + _STLP_TRY { + __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable()); + // handle insertion + if (__fill_len == 1) { + _Copy_Construct(__new_finish, __x); + ++__new_finish; + } else + __new_finish = _STLP_PRIV __uninitialized_fill_n(__new_finish, __fill_len, __x); + if (!__atend) + __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable()); // copy remainder + } + _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish), + this->_M_end_of_storage.deallocate(__new_start,__len))) + _M_clear_after_move(); + _M_set(__new_start, __new_finish, __new_start + __len); +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend ) { + size_type __len = _M_compute_next_size(__fill_len); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(this->_M_start, __pos, __new_start)); + // handle insertion + __new_finish = _STLP_PRIV __fill_n(__new_finish, __fill_len, __x); + if (!__atend) + __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(__pos, this->_M_finish, __new_finish)); // copy remainder + _M_clear(); + _M_set(__new_start, __new_finish, __new_start + __len); +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n, + const _Tp& __x, const __true_type& /*_Movable*/) { + if (_M_is_inside(__x)) { + _Tp __x_copy = __x; + _M_fill_insert_aux(__pos, __n, __x_copy, __true_type()); + return; + } + iterator __src = this->_M_finish - 1; + iterator __dst = __src + __n; + for (; __src >= __pos; --__dst, --__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + _STLP_PRIV __uninitialized_fill_n(__pos, __n, __x); + this->_M_finish += __n; +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_fill_insert_aux (iterator __pos, size_type __n, + const _Tp& __x, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + //Here self referencing needs to be checked even for non movable types. + if (_M_is_inside(__x)) { + _Tp __x_copy = __x; + _M_fill_insert_aux(__pos, __n, __x_copy, __false_type()); + return; + } + const size_type __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after > __n) { + _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __n; + _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy()); + _STLP_STD::fill(__pos, __pos + __n, __x); + } else { + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_finish, __n - __elems_after, __x); + _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __elems_after; + _STLP_STD::fill(__pos, __old_finish, __x); + } +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_fill_insert(iterator __pos, + size_type __n, const _Tp& __x) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__n != 0) { + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { + _M_fill_insert_aux(__pos, __n, __x, _Movable()); + } else { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _M_insert_overflow(__pos, __x, _TrivialCopy(), __n); + } + } +} + +template <class _Tp, class _Alloc> +vector<_Tp, _Alloc>& vector<_Tp, _Alloc>::operator = (const vector<_Tp, _Alloc>& __x) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + if (&__x != this) { + const size_type __xlen = __x.size(); + if (__xlen > capacity()) { + size_type __len = __xlen; + pointer __tmp = _M_allocate_and_copy(__len, __CONST_CAST(const_pointer, __x._M_start) + 0, + __CONST_CAST(const_pointer, __x._M_finish) + 0); + _M_clear(); + this->_M_start = __tmp; + this->_M_end_of_storage._M_data = this->_M_start + __len; + } else if (size() >= __xlen) { + pointer __i = _STLP_PRIV __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start) + 0, + __CONST_CAST(const_pointer, __x._M_finish) + 0, this->_M_start, _TrivialCopy()); + _STLP_STD::_Destroy_Range(__i, this->_M_finish); + } else { + _STLP_PRIV __copy_ptrs(__CONST_CAST(const_pointer, __x._M_start), + __CONST_CAST(const_pointer, __x._M_start) + size(), this->_M_start, _TrivialCopy()); + _STLP_PRIV __ucopy_ptrs(__CONST_CAST(const_pointer, __x._M_start) + size(), + __CONST_CAST(const_pointer, __x._M_finish) + 0, this->_M_finish, _TrivialUCopy()); + } + this->_M_finish = this->_M_start + __xlen; + } + return *this; +} + +template <class _Tp, class _Alloc> +void vector<_Tp, _Alloc>::_M_fill_assign(size_t __n, const _Tp& __val) { + if (__n > capacity()) { + vector<_Tp, _Alloc> __tmp(__n, __val, get_allocator()); + __tmp.swap(*this); + } else if (__n > size()) { + fill(begin(), end(), __val); + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_finish, __n - size(), __val); + } else + erase(_STLP_PRIV __fill_n(begin(), __n, __val), end()); +} + +template <class _Tp, class _Alloc> +__iterator__ +vector<_Tp, _Alloc>::insert(iterator __pos, const _Tp& __x) { + size_type __n = __pos - begin(); + _M_fill_insert(__pos, 1, __x); + return begin() + __n; +} + +#undef __iterator__ + +#if defined (vector) +# undef vector +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_VECTOR_C */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/_vector.h b/stlport/stlport/stl/_vector.h new file mode 100644 index 0000000..ed243ef --- /dev/null +++ b/stlport/stlport/stl/_vector.h @@ -0,0 +1,773 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This is an internal header file, included by other STL headers. + * You should not attempt to use it directly. + */ + +#ifndef _STLP_INTERNAL_VECTOR_H +#define _STLP_INTERNAL_VECTOR_H + +#ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +#endif + +#ifndef _STLP_INTERNAL_ALLOC_H +# include <stl/_alloc.h> +#endif + +#ifndef _STLP_INTERNAL_ITERATOR_H +# include <stl/_iterator.h> +#endif + +#ifndef _STLP_INTERNAL_UNINITIALIZED_H +# include <stl/_uninitialized.h> +#endif + +_STLP_BEGIN_NAMESPACE + +// The vector base class serves one purpose, its constructor and +// destructor allocate (but don't initialize) storage. This makes +// exception safety easier. + +_STLP_MOVE_TO_PRIV_NAMESPACE + +template <class _Tp, class _Alloc> +class _Vector_base { +public: + typedef _Vector_base<_Tp, _Alloc> _Self; + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef _Alloc allocator_type; + typedef _Tp* pointer; + typedef _STLP_alloc_proxy<pointer, _Tp, allocator_type> _AllocProxy; + + _Vector_base(const _Alloc& __a) + : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {} + + _Vector_base(size_t __n, const _Alloc& __a) + : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) { + _M_start = _M_end_of_storage.allocate(__n, __n); + _M_finish = _M_start; + _M_end_of_storage._M_data = _M_start + __n; + _STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + _Vector_base(__move_source<_Self> src) + : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish), + _M_end_of_storage(__move_source<_AllocProxy>(src.get()._M_end_of_storage)) { + //Set the source as empty: + src.get()._M_finish = src.get()._M_end_of_storage._M_data = src.get()._M_start = 0; + } +#endif + + ~_Vector_base() { + if (_M_start != _STLP_DEFAULT_CONSTRUCTED(pointer)) + _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); + } + +protected: + void _STLP_FUNCTION_THROWS _M_throw_length_error() const; + void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const; + + pointer _M_start; + pointer _M_finish; + _AllocProxy _M_end_of_storage; +}; + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define vector _STLP_PTR_IMPL_NAME(vector) +#elif defined (_STLP_DEBUG) +# define vector _STLP_NON_DBG_NAME(vector) +#else +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) > +class vector : protected _STLP_PRIV _Vector_base<_Tp, _Alloc> +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector) + , public __stlport_class<vector<_Tp, _Alloc> > +#endif +{ +private: + typedef _STLP_PRIV _Vector_base<_Tp, _Alloc> _Base; + typedef vector<_Tp, _Alloc> _Self; +public: + _STLP_FORCE_ALLOCATORS(_Tp, _Alloc) + typedef typename _Base::allocator_type allocator_type; + + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type* iterator; + typedef const value_type* const_iterator; + + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef random_access_iterator_tag _Iterator_category; + + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; + + allocator_type get_allocator() const + { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp); } + +private: +#if defined (_STLP_NO_MOVE_SEMANTIC) + typedef __false_type _Movable; +#endif + + // handles insertions on overflow + void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*_Movable*/, + size_type __fill_len, bool __atend); + void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __true_type& /*_Movable*/, + size_type __fill_len, bool __atend) { + //We need to take care of self referencing here: + if (_M_is_inside(__x)) { + value_type __x_copy = __x; + _M_insert_overflow_aux(__pos, __x_copy, __false_type(), __fill_len, __atend); + return; + } + _M_insert_overflow_aux(__pos, __x, __false_type(), __fill_len, __atend); + } + + void _M_insert_overflow(pointer __pos, const _Tp& __x, const __false_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend = false) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + _M_insert_overflow_aux(__pos, __x, _Movable(), __fill_len, __atend); + } + void _M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/, + size_type __fill_len, bool __atend = false); + void _M_range_check(size_type __n) const { + if (__n >= size_type(this->_M_finish - this->_M_start)) + this->_M_throw_out_of_range(); + } + + size_type _M_compute_next_size(size_type __n) { + const size_type __size = size(); + if (__n > max_size() - __size) + this->_M_throw_length_error(); + size_type __len = __size + (max)(__n, __size); + if (__len > max_size() || __len < __size) + __len = max_size(); // overflow + return __len; + } + +public: + iterator begin() { return this->_M_start; } + const_iterator begin() const { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator end() const { return this->_M_finish; } + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + + size_type size() const { return size_type(this->_M_finish - this->_M_start); } + size_type max_size() const { + size_type __vector_max_size = size_type(-1) / sizeof(_Tp); + typename allocator_type::size_type __alloc_max_size = this->_M_end_of_storage.max_size(); + return (__alloc_max_size < __vector_max_size)?__alloc_max_size:__vector_max_size; + } + + size_type capacity() const { return size_type(this->_M_end_of_storage._M_data - this->_M_start); } + bool empty() const { return this->_M_start == this->_M_finish; } + + reference operator[](size_type __n) { return *(begin() + __n); } + const_reference operator[](size_type __n) const { return *(begin() + __n); } + + reference front() { return *begin(); } + const_reference front() const { return *begin(); } + reference back() { return *(end() - 1); } + const_reference back() const { return *(end() - 1); } + + reference at(size_type __n) { _M_range_check(__n); return (*this)[__n]; } + const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + explicit vector(const allocator_type& __a = allocator_type()) +#else + vector() + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) {} + vector(const allocator_type& __a) +#endif + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) {} + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) +private: + //We always call _M_initialize with only 1 parameter. Default parameter + //is used to allow explicit instanciation of vector with types with no + //default constructor. + void _M_initialize(size_type __n, const _Tp& __val = _STLP_DEFAULT_CONSTRUCTED(_Tp)) + { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, __val); } +public: + explicit vector(size_type __n) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { _M_initialize(__n); } + vector(size_type __n, const _Tp& __val, const allocator_type& __a = allocator_type()) +#else + explicit vector(size_type __n) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } + vector(size_type __n, const _Tp& __val) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, allocator_type()) + { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); } + vector(size_type __n, const _Tp& __val, const allocator_type& __a) +#endif + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__n, __a) + { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); } + + vector(const _Self& __x) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + this->_M_finish = _STLP_PRIV __ucopy_ptrs(__x.begin(), __x.end(), this->_M_start, _TrivialUCopy()); + } + +#if !defined (_STLP_NO_MOVE_SEMANTIC) + vector(__move_source<_Self> src) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__move_source<_Base>(src.get())) + {} +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) +private: + template <class _Integer> + void _M_initialize_aux(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) { + size_type __real_n = __n; + this->_M_start = this->_M_end_of_storage.allocate(__n, __real_n); + this->_M_end_of_storage._M_data = this->_M_start + __real_n; + this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); + } + + template <class _InputIterator> + void _M_initialize_aux(_InputIterator __first, _InputIterator __last, + const __false_type& /*_IsIntegral*/) + { _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template <class _InputIterator> + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL ) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_aux(__first, __last, _Integral()); + } + +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) + template <class _InputIterator> + vector(_InputIterator __first, _InputIterator __last) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(allocator_type()) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_initialize_aux(__first, __last, _Integral()); + } +# endif /* _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS */ + +#else /* _STLP_MEMBER_TEMPLATES */ + vector(const _Tp* __first, const _Tp* __last, + const allocator_type& __a = allocator_type()) + : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__last - __first, __a) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + this->_M_finish = _STLP_PRIV __ucopy_ptrs(__first, __last, this->_M_start, _TrivialUCopy()); + } +#endif /* _STLP_MEMBER_TEMPLATES */ + + //As the vector container is a back insert oriented container it + //seems rather logical to destroy elements in reverse order. + ~vector() { _STLP_STD::_Destroy_Range(rbegin(), rend()); } + + _Self& operator=(const _Self& __x); + + void reserve(size_type __n); + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + + void assign(size_type __n, const _Tp& __val) { _M_fill_assign(__n, __val); } + void _M_fill_assign(size_type __n, const _Tp& __val); + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _ForwardIter> + void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &) { +#else + void assign(const_iterator __first, const_iterator __last) { + typedef const_iterator _ForwardIter; +#endif + const size_type __len = _STLP_STD::distance(__first, __last); + if (__len > capacity()) { + size_type __n = __len; + iterator __tmp = _M_allocate_and_copy(__n, __first, __last); + _M_clear(); + _M_set(__tmp, __tmp + __len, __tmp + __n); + } + else if (size() >= __len) { + iterator __new_finish = copy(__first, __last, this->_M_start); + _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish); + this->_M_finish = __new_finish; + } + else { + _ForwardIter __mid = __first; + _STLP_STD::advance(__mid, size()); + _STLP_STD::copy(__first, __mid, this->_M_start); + this->_M_finish = _STLP_STD::uninitialized_copy(__mid, __last, this->_M_finish); + } + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIter> + void _M_assign_aux(_InputIter __first, _InputIter __last, + const input_iterator_tag &) { + iterator __cur = begin(); + for ( ; __first != __last && __cur != end(); ++__cur, ++__first) + *__cur = *__first; + if (__first == __last) + erase(__cur, end()); + else + insert(end(), __first, __last); + } + + template <class _Integer> + void _M_assign_dispatch(_Integer __n, _Integer __val, + const __true_type& /*_IsIntegral*/) + { _M_fill_assign(__n, __val); } + + template <class _InputIter> + void _M_assign_dispatch(_InputIter __first, _InputIter __last, + const __false_type& /*_IsIntegral*/) + { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); } + + template <class _InputIterator> + void assign(_InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) + void push_back(const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void push_back(const _Tp& __x) { +#endif + if (this->_M_finish != this->_M_end_of_storage._M_data) { + _Copy_Construct(this->_M_finish, __x); + ++this->_M_finish; + } + else { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _M_insert_overflow(this->_M_finish, __x, _TrivialCopy(), 1, true); + } + } + +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + iterator insert(iterator __pos, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)); +#else + iterator insert(iterator __pos, const _Tp& __x); +#endif + +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) + void push_back() { push_back(_STLP_DEFAULT_CONSTRUCTED(_Tp)); } + iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif + + void swap(_Self& __x) { + _STLP_STD::swap(this->_M_start, __x._M_start); + _STLP_STD::swap(this->_M_finish, __x._M_finish); + this->_M_end_of_storage.swap(__x._M_end_of_storage); + } +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) + void _M_swap_workaround(_Self& __x) { swap(__x); } +#endif + +private: + void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __true_type& /*_Movable*/); + void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/); + void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x); + + bool _M_is_inside(const value_type& __x) const { + return (&__x >= this->_M_start && &__x < this->_M_finish); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _ForwardIterator> + void _M_range_insert_realloc(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_realloc(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + size_type __len = _M_compute_next_size(__n); + pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); + pointer __new_finish = __new_start; + _STLP_TRY { + __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable()); + __new_finish = uninitialized_copy(__first, __last, __new_finish); + __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable()); + } + _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish), + this->_M_end_of_storage.deallocate(__new_start,__len))) + _M_clear_after_move(); + _M_set(__new_start, __new_finish, __new_start + __len); + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _ForwardIterator> + void _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_aux(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n, const __true_type& /*_Movable*/) { + iterator __src = this->_M_finish - 1; + iterator __dst = __src + __n; + for (; __src >= __pos; --__dst, --__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + uninitialized_copy(__first, __last, __pos); + this->_M_finish += __n; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _ForwardIterator> + void _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, +#else + void _M_range_insert_aux(iterator __pos, + const_iterator __first, const_iterator __last, +#endif + size_type __n, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_copy_constructor _TrivialUCopy; + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + const size_type __elems_after = this->_M_finish - __pos; + pointer __old_finish = this->_M_finish; + if (__elems_after > __n) { + _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __n; + _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy()); + copy(__first, __last, __pos); + } + else { +#if defined ( _STLP_MEMBER_TEMPLATES ) + _ForwardIterator __mid = __first; + _STLP_STD::advance(__mid, __elems_after); +#else + const_pointer __mid = __first + __elems_after; +#endif + uninitialized_copy(__mid, __last, this->_M_finish); + this->_M_finish += __n - __elems_after; + _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy()); + this->_M_finish += __elems_after; + copy(__first, __mid, __pos); + } /* elems_after */ + } + + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _Integer> + void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + const __true_type&) + { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); } + + template <class _InputIterator> + void _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + const __false_type&) + { _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); } + +public: + // Check whether it's an integral type. If so, it's not an iterator. + template <class _InputIterator> + void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { + typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; + _M_insert_dispatch(__pos, __first, __last, _Integral()); + } + +private: + template <class _InputIterator> + void _M_range_insert(iterator __pos, + _InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template <class _ForwardIterator> + void _M_range_insert(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { +#else +public: + void insert(iterator __pos, + const_iterator __first, const_iterator __last) { +#endif +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + /* This method do not check self referencing. + * Standard forbids it, checked by the debug mode. + */ + if (__first != __last) { + size_type __n = _STLP_STD::distance(__first, __last); + + if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) { + _M_range_insert_aux(__pos, __first, __last, __n, _Movable()); + } + else { + _M_range_insert_realloc(__pos, __first, __last, __n); + } + } + } + +public: + void insert (iterator __pos, size_type __n, const _Tp& __x) + { _M_fill_insert(__pos, __n, __x); } + + void pop_back() { + --this->_M_finish; + _STLP_STD::_Destroy(this->_M_finish); + } + +private: + iterator _M_erase(iterator __pos, const __true_type& /*_Movable*/) { + _STLP_STD::_Destroy(__pos); + iterator __dst = __pos, __src = __dst + 1; + iterator __end = end(); + for (; __src != __end; ++__dst, ++__src) { + _STLP_STD::_Move_Construct(__dst, *__src); + _STLP_STD::_Destroy_Moved(__src); + } + this->_M_finish = __dst; + return __pos; + } + iterator _M_erase(iterator __pos, const __false_type& /*_Movable*/) { + if (__pos + 1 != end()) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + _STLP_PRIV __copy_ptrs(__pos + 1, this->_M_finish, __pos, _TrivialCopy()); + } + --this->_M_finish; + _STLP_STD::_Destroy(this->_M_finish); + return __pos; + } + iterator _M_erase(iterator __first, iterator __last, const __true_type& /*_Movable*/) { + iterator __dst = __first, __src = __last; + iterator __end = end(); + for (; __dst != __last && __src != __end; ++__dst, ++__src) { + _STLP_STD::_Destroy(__dst); + _STLP_STD::_Move_Construct(__dst, *__src); + } + if (__dst != __last) { + //There is more elements to erase than element to move: + _STLP_STD::_Destroy_Range(__dst, __last); + _STLP_STD::_Destroy_Moved_Range(__last, __end); + } + else { + //There is more element to move than element to erase: + for (; __src != __end; ++__dst, ++__src) { + _STLP_STD::_Destroy_Moved(__dst); + _STLP_STD::_Move_Construct(__dst, *__src); + } + _STLP_STD::_Destroy_Moved_Range(__dst, __end); + } + this->_M_finish = __dst; + return __first; + } + iterator _M_erase(iterator __first, iterator __last, const __false_type& /*_Movable*/) { + typedef typename __type_traits<_Tp>::has_trivial_assignment_operator _TrivialCopy; + pointer __i = _STLP_PRIV __copy_ptrs(__last, this->_M_finish, __first, _TrivialCopy()); + _STLP_STD::_Destroy_Range(__i, this->_M_finish); + this->_M_finish = __i; + return __first; + } + +public: + iterator erase(iterator __pos) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + return _M_erase(__pos, _Movable()); + } + iterator erase(iterator __first, iterator __last) { +#if !defined (_STLP_NO_MOVE_SEMANTIC) + typedef typename __move_traits<_Tp>::implemented _Movable; +#endif + if (__first == __last) + return __first; + return _M_erase(__first, __last, _Movable()); + } + +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) { +#else + void resize(size_type __new_size, const _Tp& __x) { +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + if (__new_size < size()) + erase(begin() + __new_size, end()); + else + insert(end(), __new_size - size(), __x); + } + +#if defined (_STLP_DONT_SUP_DFLT_PARAM) + void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/ + + void clear() { + erase(begin(), end()); + } + +private: + void _M_clear() { + _STLP_STD::_Destroy_Range(rbegin(), rend()); + this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start); + } + + void _M_clear_after_move() { + _STLP_STD::_Destroy_Moved_Range(rbegin(), rend()); + this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start); + } + + void _M_set(pointer __s, pointer __f, pointer __e) { + this->_M_start = __s; + this->_M_finish = __f; + this->_M_end_of_storage._M_data = __e; + } + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _ForwardIterator> + pointer _M_allocate_and_copy(size_type& __n, + _ForwardIterator __first, _ForwardIterator __last) +#else /* _STLP_MEMBER_TEMPLATES */ + pointer _M_allocate_and_copy(size_type& __n, + const_pointer __first, const_pointer __last) +#endif /* _STLP_MEMBER_TEMPLATES */ + { + pointer __result = this->_M_end_of_storage.allocate(__n, __n); + _STLP_TRY { + uninitialized_copy(__first, __last, __result); + return __result; + } + _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n)) + _STLP_RET_AFTER_THROW(__result) + } + + +#if defined (_STLP_MEMBER_TEMPLATES) + template <class _InputIterator> + void _M_range_initialize(_InputIterator __first, _InputIterator __last, + const input_iterator_tag &) { + for ( ; __first != __last; ++__first) + push_back(*__first); + } + // This function is only called by the constructor. + template <class _ForwardIterator> + void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + const forward_iterator_tag &) { + size_type __n = _STLP_STD::distance(__first, __last); + this->_M_start = this->_M_end_of_storage.allocate(__n, __n); + this->_M_end_of_storage._M_data = this->_M_start + __n; + this->_M_finish = uninitialized_copy(__first, __last, this->_M_start); + } +#endif /* _STLP_MEMBER_TEMPLATES */ +}; + +#if defined (vector) +# undef vector +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +_STLP_END_NAMESPACE + +#if !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/_vector.c> +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# include <stl/pointers/_vector.h> +#endif + +//We define the bool specialization before the debug interfave +//to benefit of the debug version of vector even for the bool +//specialization. +#if !defined (_STLP_NO_BOOL) || !defined (_STLP_NO_EXTENSIONS) +# if !defined (_STLP_INTERNAL_BVECTOR_H) +# include <stl/_bvector.h> +# endif +#endif + +#if defined (_STLP_DEBUG) +# include <stl/debug/_vector.h> +#endif + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_NO_BOOL) && !defined (_STLP_NO_EXTENSIONS) +// This typedef is non-standard. It is provided for backward compatibility. +typedef vector<bool, allocator<bool> > bit_vector; +#endif + +#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc> +#define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc> +#include <stl/_relops_cont.h> +#undef _STLP_TEMPLATE_CONTAINER +#undef _STLP_TEMPLATE_HEADER + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !defined (_STLP_NO_MOVE_SEMANTIC) +template <class _Tp, class _Alloc> +struct __move_traits<vector<_Tp, _Alloc> > { + typedef __true_type implemented; + typedef typename __move_traits<_Alloc>::complete complete; +}; +# endif + +# if !defined (_STLP_DEBUG) +template <class _Tp, class _Alloc> +struct _DefaultZeroValue<vector<_Tp, _Alloc> > +{ typedef typename __type_traits<_Alloc>::has_trivial_default_constructor _Ret; }; +# endif + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +_STLP_END_NAMESPACE + +#endif /* _STLP_VECTOR_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/config/_android.h b/stlport/stlport/stl/config/_android.h new file mode 100755 index 0000000..fe695f2 --- /dev/null +++ b/stlport/stlport/stl/config/_android.h @@ -0,0 +1,98 @@ +#ifndef __stl_config__android_h +#define __stl_config__android_h + +/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Code Aurora nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * 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, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS 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. + * + */ + +#define _STLP_PLATFORM "Android" + +// The Android C library is mostly glibc-like +#define _STLP_USE_GLIBC 1 + +// ...and Unix-like. +#define _STLP_UNIX 1 + +// Have pthreads support. +#define _PTHREADS + +// Don't have native <cplusplus> headers +#define _STLP_HAS_NO_NEW_C_HEADERS 1 + +// Don't use wchar.h etc +//#define _STLP_NO_WCHAR_T 1 + +// Don't have (working) native wide character support. +#define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 + +// Don't use mbstate_t, define our own. +//#define _STLP_NO_NATIVE_MBSTATE_T 1 + +// No (proper) wide stream support in Android +#define _STLP_NO_NATIVE_WIDE_STREAMS 1 + +// C library is in the global namespace. +#define _STLP_VENDOR_GLOBAL_CSTD 1 + +// Don't have underlying local support. +#undef _STLP_REAL_LOCALE_IMPLEMENTED + +// No pthread_spinlock_t in Android +#define _STLP_DONT_USE_PTHREAD_SPINLOCK 1 + +// Little endian platform. +#define _STLP_LITTLE_ENDIAN 1 + +// No <exception> headers +#define _STLP_NO_EXCEPTION_HEADER 1 + +// No need to define our own namespace +#define _STLP_NO_OWN_NAMESPACE 1 + +// Need this to define STLport's own bad_alloc class (which won't be +// thrown in any case) +#define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 + +// Use __new_alloc instead of __node_alloc, so we don't need static functions. +#define _STLP_USE_SIMPLE_NODE_ALLOC 1 + +// Don't use extern versions of range errors, so we don't need to +// compile as a library. +#define _STLP_USE_NO_EXTERN_RANGE_ERRORS 1 + +// The system math library doesn't have long double variants, e.g +// sinl, cosl, etc +#define _STLP_NO_VENDOR_MATH_L 1 + +// Define how to include our native headers. +#define _STLP_NATIVE_HEADER(header) <libstdc++/include/header> +#define _STLP_NATIVE_C_HEADER(header) <../include/header> +#define _STLP_NATIVE_CPP_C_HEADER(header) <libstdc++/include/header> +#define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <libstdc++/include/header> +#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <libstdc++/include/header> + +#endif /* __stl_config__android_h */ diff --git a/stlport/stlport/stl/config/_gcc.h b/stlport/stlport/stl/config/_gcc.h new file mode 100644 index 0000000..0d41863 --- /dev/null +++ b/stlport/stlport/stl/config/_gcc.h @@ -0,0 +1,198 @@ +/* STLport configuration file + * It is internal STLport header - DO NOT include it directly + */ + +#define _STLP_COMPILER "gcc" + +#define _STLP_HAS_INCLUDE_NEXT 1 + +#if (__GNUC__ < 2) || ((__GNUC__ < 3) && ((__GNUC_MINOR__ < 95) || (__GNUC_MINOR__ == 96))) +/* We do not support neither the unofficial 2.96 gcc version. */ +# error GNU compilers before 2.95 are not supported anymore. +#endif + +/* Systems having GLIBC installed have different traits */ +#if defined (__linux__) +# ifndef _STLP_USE_GLIBC +# define _STLP_USE_GLIBC 1 +# endif +# if defined (__UCLIBC__) && !defined (_STLP_USE_UCLIBC) +# define _STLP_USE_UCLIBC 1 +# endif +#endif + +#if defined (__CYGWIN__) && \ + (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 3) && !defined (_GLIBCPP_USE_C99) +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_VENDOR_STDLIB_L +#endif + +#if (__GNUC__ < 3) +# define _STLP_NO_VENDOR_STDLIB_L +#endif + +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) +/* define for gcc versions before 3.4.0. */ +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD +#endif + +#if !defined (_REENTRANT) && (defined (_THREAD_SAFE) || \ + (defined (__OpenBSD__) && defined (_POSIX_THREADS)) || \ + (defined (__MINGW32__) && defined (_MT))) +# define _REENTRANT +#endif + +#if defined (__DJGPP) +# define _STLP_RAND48 1 +# define _NOTHREADS 1 +# undef _PTHREADS +# define _STLP_LITTLE_ENDIAN +#endif + +#if defined (__MINGW32__) +/* Mingw32, egcs compiler using the Microsoft C runtime */ +# if (__GNUC__ >= 3) +/* For gcc before version 3 this macro is defined below */ +# define _STLP_VENDOR_GLOBAL_CSTD +# endif +# undef _STLP_NO_DRAND48 +# define _STLP_NO_DRAND48 +# define _STLP_CALL +#endif /* __MINGW32__ */ + +#if defined (__CYGWIN__) || defined (__MINGW32__) +# if !defined (_STLP_USE_STATIC_LIB) +# define _STLP_USE_DECLSPEC 1 +# if !defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DYNAMIC_LIB +# endif +# define _STLP_EXPORT_DECLSPEC __declspec(dllexport) +# define _STLP_CLASS_EXPORT_DECLSPEC __declspec(dllexport) +# define _STLP_CLASS_IMPORT_DECLSPEC __declspec(dllimport) +# endif +/* The following is defined independently of _STLP_USE_STATIC_LIB because it is also + * used to import symbols from PSDK under MinGW + */ +# define _STLP_IMPORT_DECLSPEC __declspec(dllimport) +#else +# if (__GNUC__ >= 4) +# if !defined (_STLP_USE_STATIC_LIB) +# if !defined (_STLP_USE_DYNAMIC_LIB) +# define _STLP_USE_DYNAMIC_LIB +# endif +# define _STLP_USE_DECLSPEC 1 +# define _STLP_EXPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_IMPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_CLASS_EXPORT_DECLSPEC __attribute__((visibility("default"))) +# define _STLP_CLASS_IMPORT_DECLSPEC __attribute__((visibility("default"))) +# endif +# endif +#endif + +#if defined (__CYGWIN__) || defined (__MINGW32__) || !(defined (_STLP_USE_GLIBC) || defined (__sun) || defined(__APPLE__)) +# if !defined (__MINGW32__) && !defined (__CYGWIN__) +# define _STLP_NO_NATIVE_MBSTATE_T 1 +# endif +# if !defined (__MINGW32__) || (__GNUC__ < 3) || (__GNUC__ == 3) && (__GNUC_MINOR__ < 4) +# define _STLP_NO_NATIVE_WIDE_FUNCTIONS 1 +# endif +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +#endif + +#define _STLP_NORETURN_FUNCTION __attribute__((noreturn)) + +/* Mac OS X is a little different with namespaces and cannot instantiate + * static data members in template classes */ +#if defined (__APPLE__) +# if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))) +/* Mac OS X is missing a required typedef and standard macro */ +typedef unsigned int wint_t; +# endif + +# define __unix + +# define _STLP_NO_LONG_DOUBLE + +/* Mac OS X needs all "::" scope references to be "std::" */ +# define _STLP_USE_NEW_C_HEADERS + +# define _STLP_NO_VENDOR_STDLIB_L + +#endif /* __APPLE__ */ + +/* g++ 2.7.x and above */ +#define _STLP_LONG_LONG long long + +#ifdef _STLP_USE_UCLIBC + /* No *f math fuctions variants (i.e. sqrtf, fabsf, etc.) */ +# define _STLP_NO_VENDOR_MATH_F + /* No *l math fuctions variants (i.e. sqrtl, fabsl, etc.) */ +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_LONG_DOUBLE +#endif + +#if defined (__OpenBSD__) || defined (__FreeBSD__) +# define _STLP_NO_VENDOR_MATH_L +# define _STLP_NO_VENDOR_STDLIB_L /* no llabs */ +# ifndef __unix +# define __unix +# endif +#endif + +#if defined (__alpha__) +# define _STLP_NO_VENDOR_MATH_L +#endif + +#if defined (__hpux) +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_NO_VENDOR_STDLIB_L /* no llabs */ + /* No *f math fuctions variants (i.e. sqrtf, fabsf, etc.) */ +# define _STLP_NO_VENDOR_MATH_F +#endif + +#if (__GNUC__ >= 3) +# ifndef _STLP_HAS_NO_NEW_C_HEADERS +/* +# ifndef _STLP_USE_UCLIBC +*/ +# define _STLP_HAS_NATIVE_FLOAT_ABS +/* +# endif +*/ +# else +# ifdef _STLP_USE_GLIBC +# define _STLP_VENDOR_LONG_DOUBLE_MATH 1 +# endif +# endif +#endif + +#if (__GNUC__ < 3) +# define _STLP_HAS_NO_NEW_C_HEADERS 1 +# define _STLP_VENDOR_GLOBAL_CSTD 1 +# define _STLP_DONT_USE_PTHREAD_SPINLOCK 1 +# ifndef __HONOR_STD +# define _STLP_VENDOR_GLOBAL_EXCEPT_STD 1 +# endif +/* egcs fails to initialize builtin types in expr. like this : new(p) char(); */ +# define _STLP_DEF_CONST_PLCT_NEW_BUG 1 +#endif + +#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT + +/* strict ANSI prohibits "long long" ( gcc) */ +#if defined ( __STRICT_ANSI__ ) +# undef _STLP_LONG_LONG +#endif + +#ifndef __EXCEPTIONS +# undef _STLP_DONT_USE_EXCEPTIONS +# define _STLP_DONT_USE_EXCEPTIONS 1 +#endif + +#if (__GNUC__ >= 3) +/* Instantiation scheme that used (default) in gcc 3 made void of sense explicit + instantiation within library: nothing except increased library size. - ptr + */ +# define _STLP_NO_FORCE_INSTANTIATE +#endif diff --git a/stlport/stlport/stl/config/_system.h b/stlport/stlport/stl/config/_system.h new file mode 100755 index 0000000..afdc050 --- /dev/null +++ b/stlport/stlport/stl/config/_system.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + */ + +/* + * Purpose of this file : + * + * To hold COMPILER-SPECIFIC portion of STLport settings. + * In general, user should not edit this file unless + * using the compiler not recognized below. + * + * If your compiler is not being recognized yet, + * please look for definitions of macros in stl_mycomp.h, + * copy stl_mycomp.h to stl_YOUR_COMPILER_NAME, + * adjust flags for your compiler, and add <include config/stl_YOUR_COMPILER_NAME> + * to the secton controlled by unique macro defined internaly by your compiler. + * + * To change user-definable settings, please edit <user_config.h> + * + */ + +#ifndef __stl_config__system_h +#define __stl_config__system_h + +#if defined (__sun) +# include <stl/config/_solaris.h> +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# elif defined (__SUNPRO_CC) || defined (__SUNPRO_C) +# include <stl/config/_sunprocc.h> +/* +# ifdef __KCC +# include <stl/config/_kai.h> +# endif +*/ +# elif defined (__APOGEE__) /* Apogee 4.x */ +# include <stl/config/_apcc.h> +# elif defined (__FCC_VERSION) /* Fujitsu Compiler, v4.0 assumed */ +# include <stl/config/_fujitsu.h> +# endif +#elif defined (__hpux) +# include <stl/config/_hpux.h> +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# elif defined (__HP_aCC) +# include <stl/config/_hpacc.h> +# endif +#elif defined (ANDROID) +# include <stl/config/_android.h> +# include <stl/config/_gcc.h> +#elif defined (linux) || defined (__linux__) +# include <stl/config/_linux.h> +# if defined (__BORLANDC__) +# include <stl/config/_bc.h> /* Borland C++ 0x570 */ +/* Intel's icc define __GNUC__! */ +# elif defined (__INTEL_COMPILER) +# include <stl/config/_icc.h> +# elif defined (__GNUC__) +# include <stl/config/_gcc.h> +# endif +/* +# ifdef __KCC +# include <stl/config/_kai.h> +# endif +*/ +#elif defined (__FreeBSD__) +# include <stl/config/_freebsd.h> +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# endif +#elif defined (__OpenBSD__) +# include <stl/config/_openbsd.h> +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# endif +#elif defined (__sgi) /* IRIX? */ +# define _STLP_PLATFORM "SGI Irix" +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# else +# include <stl/config/_sgi.h> +# endif +#elif defined (__OS400__) /* AS/400 C++ */ +# define _STLP_PLATFORM "OS 400" +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# else +# include <stl/config/_as400.h> +# endif +#elif defined (_AIX) +# include <stl/config/_aix.h> +# if defined (__xlC__) || defined (__IBMC__) || defined ( __IBMCPP__ ) + /* AIX xlC, Visual Age C++ , OS-390 C++ */ +# include <stl/config/_ibm.h> +# endif +#elif defined (_CRAY) /* Cray C++ 3.4 or 3.5 */ +# define _STLP_PLATFORM "Cray" +# include <config/_cray.h> +#elif defined (__DECCXX) || defined (__DECC) +# define _STLP_PLATFORM "DECC" +# ifdef __vms +# include <stl/config/_dec_vms.h> +# else +# include <stl/config/_dec.h> +# endif +#elif defined (macintosh) || defined (_MAC) +# include <stl/config/_mac.h> +# if defined (__MWERKS__) +# include <stl/config/_mwerks.h> +# endif +#elif defined (__APPLE__) +# include <stl/config/_macosx.h> +# ifdef __GNUC__ +# include <stl/config/_gcc.h> +# endif +#elif defined (__CYGWIN__) +# include <stl/config/_cygwin.h> +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# endif +#elif defined (__MINGW32__) +# define _STLP_PLATFORM "MinGW" +# if defined (__GNUC__) +# include <stl/config/_gcc.h> +# endif +# include <stl/config/_windows.h> +#elif defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__) || \ + defined (__WIN16) || defined (WIN16) || defined (_WIN16) +# if defined ( __BORLANDC__ ) /* Borland C++ / CodeGear C++ */ +# include <stl/config/_bc.h> +# elif defined (__WATCOM_CPLUSPLUS__) || defined (__WATCOMC__) /* Watcom C++ */ +# include <stl/config/_watcom.h> +# elif defined (__COMO__) || defined (__COMO_VERSION_) +# include <stl/config/_como.h> +# elif defined (__DMC__) /* Digital Mars C++ */ +# include <stl/config/_dm.h> +# elif defined (__ICL) /* Intel reference compiler for Win */ +# include <stl/config/_intel.h> +# elif defined (__MWERKS__) +# include <stl/config/_mwerks.h> +# elif defined (_MSC_VER) && (_MSC_VER >= 1200) && defined (UNDER_CE) + /* Microsoft eMbedded Visual C++ 3.0, 4.0 (.NET) */ +# include <stl/config/_evc.h> +# elif defined (_MSC_VER) + /* Microsoft Visual C++ 6.0, 7.0, 7.1, 8.0 */ +# include <stl/config/_msvc.h> +# endif + +# include <stl/config/_windows.h> +#else +# error Unknown platform !! +#endif + +#if !defined (_STLP_COMPILER) +/* Unable to identify the compiler, issue error diagnostic. + * Edit <config/stl_mycomp.h> to set STLport up for your compiler. */ +# include <stl/config/stl_mycomp.h> +#endif + +#endif /* __stl_config__system_h */ diff --git a/stlport/stlport/stl/config/compat.h b/stlport/stlport/stl/config/compat.h new file mode 100644 index 0000000..434f314 --- /dev/null +++ b/stlport/stlport/stl/config/compat.h @@ -0,0 +1,80 @@ + +/* + * Compatibility section + * This section sets new-style macros based on old-style ones, for compatibility + */ + +#if defined (__STL_DEBUG) && !defined (_STLP_DEBUG) +# define _STLP_DEBUG __STL_DEBUG +#endif +#if defined (__STL_NO_ANACHRONISMS) && !defined (_STLP_NO_ANACHRONISMS) +# define _STLP_NO_ANACHRONISMS __STL_NO_ANACHRONISMS +#endif +#if defined (__STL_NO_EXTENSIONS) && !defined (_STLP_NO_EXTENSIONS) +# define _STLP_NO_EXTENSIONS __STL_NO_EXTENSIONS +#endif +#if defined (__STL_NO_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTIONS) +# define _STLP_NO_EXCEPTIONS __STL_NO_EXCEPTIONS +#endif +#if defined (__STL_NO_NAMESPACES) && !defined (_STLP_NO_NAMESPACES) +# define _STLP_NO_NAMESPACES __STL_NO_NAMESPACES +#endif +#if defined (__STL_MINIMUM_DEFAULT_TEMPLATE_PARAMS) && !defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) +# define _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS __STL_MINIMUM_DEFAULT_TEMPLATE_PARAMS +#endif +#if defined (__STL_NO_OWN_NAMESPACE) && !defined (_STLP_NO_OWN_NAMESPACE) +# define _STLP_NO_OWN_NAMESPACE __STL_NO_OWN_NAMESPACE +#endif + +#if defined (__STL_NO_RELOPS_NAMESPACE) && !defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_NO_RELOPS_NAMESPACE __STL_NO_RELOPS_NAMESPACE +#endif + +#if defined (__STL_DEBUG_UNINITIALIZED) && !defined (_STLP_DEBUG_UNINITIALIZED) +# define _STLP_DEBUG_UNINITIALIZED __STL_DEBUG_UNINITIALIZED +#endif +#if defined (__STL_SHRED_BYTE) && !defined (_STLP_SHRED_BYTE) +# define _STLP_SHRED_BYTE __STL_SHRED_BYTE +#endif +#if defined (__STL_USE_MFC) && !defined (_STLP_USE_MFC) +# define _STLP_USE_MFC __STL_USE_MFC +#endif + +#if defined (__STL_USE_NEWALLOC) && !defined (_STLP_USE_NEWALLOC) +# define _STLP_USE_NEWALLOC __STL_USE_NEWALLOC +#endif +#if defined (__STL_USE_MALLOC) && !defined (_STLP_USE_MALLOC) +# define _STLP_USE_MALLOC __STL_USE_MALLOC +#endif + +#if defined (__STL_DEBUG_ALLOC) && !defined (_STLP_DEBUG_ALLOC) +# define _STLP_DEBUG_ALLOC __STL_DEBUG_ALLOC +#endif + +#if defined (__STL_DEBUG_MESSAGE) && !defined (_STLP_DEBUG_MESSAGE) +# define _STLP_DEBUG_MESSAGE __STL_DEBUG_MESSAGE +#endif + +#if defined (__STL_DEBUG_TERMINATE) && !defined (_STLP_DEBUG_TERMINATE) +# define _STLP_DEBUG_TERMINATE __STL_DEBUG_TERMINATE +#endif + +#if defined (__STL_USE_ABBREVS) && !defined (_STLP_USE_ABBREVS) +# define _STLP_USE_ABBREVS __STL_USE_ABBREVS +#endif + +#if defined (__STL_NO_MSVC50_COMPATIBILITY) && !defined (_STLP_NO_MSVC50_COMPATIBILITY) +# define _STLP_NO_MSVC50_COMPATIBILITY __STL_NO_MSVC50_COMPATIBILITY +#endif + +/* STLport do not support anymore the iostream wrapper mode so this macro should + * always been define for other libraries that was using it: + */ +#if !defined (_STLP_OWN_IOSTREAMS) +# define _STLP_OWN_IOSTREAMS +#endif + +#if defined (_STLP_NO_OWN_IOSTREAMS) +# error STLport do not support anymore the wrapper mode. If you want to use STLport \ +use its iostreams implementation or no iostreams at all. +#endif diff --git a/stlport/stlport/stl/config/features.h b/stlport/stlport/stl/config/features.h new file mode 100644 index 0000000..b5b4e3a --- /dev/null +++ b/stlport/stlport/stl/config/features.h @@ -0,0 +1,1079 @@ + /* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_FEATURES_H +#define _STLP_FEATURES_H + +/* + * Purpose of this file: + * + * Defines all STLport settings. + * This file is actually a wrapper : it includes compiler-specific + * settings from <config/stlcomp.h> + * and user-defined settings from <config/user_config.h>. + * See <config/stl_mycomp.h> and <config/user_config.h> for the description + * of those macros + * + */ + +/* Definition of the STLport version informations */ +#include <stl/_stlport_version.h> + +/* Other macros defined by this file: + + * bool, true, and false, if _STLP_NO_BOOL is defined. + * typename, as a null macro if it's not already a keyword. + * explicit, as a null macro if it's not already a keyword. + * namespace-related macros (_STLP_STD, _STLP_BEGIN_NAMESPACE, etc.) + * exception-related macros (_STLP_TRY, _STLP_UNWIND, etc.) + * _STLP_ASSERT, either as a test or as a null macro, depending on + whether or not _STLP_ASSERTIONS is defined. +*/ + +/* Definition of the 2 STLport debug levels */ +#define _STLP_STLPORT_DBG_LEVEL 1 +#define _STLP_STANDARD_DBG_LEVEL 2 + +/* Placeholder for user to override settings. + * It could be also used to mask settings from + * different directories. + */ +#include <stl/config/user_config.h> + +#if defined (_STLP_DEBUG) && !defined (_STLP_DEBUG_LEVEL) +# define _STLP_DEBUG_LEVEL _STLP_STLPORT_DBG_LEVEL +#endif + +#if defined (__BUILDING_STLPORT) +/* For the STLport implementation we can use everything: + */ +# if defined (_STLP_NO_ANACHRONISMS) +# undef _STLP_NO_ANACHRONISMS +# endif +# if defined (_STLP_NO_EXTENSIONS) +# undef _STLP_NO_EXTENSIONS +# endif +/* Moreover there are things that have no sens: + */ +# if defined (_STLP_NO_IOSTREAMS) +# error If you do not use iostreams you do not need to build the STLport library. +# endif +#endif + +/* ========================================================= */ +/* This file is used for compatibility; it accepts old-style config + switches */ +#include <stl/config/compat.h> + +/* Common configuration file for this particular installation. */ +#include <stl/config/host.h> + +/* Operational Environment specific */ +#include <stl/config/_system.h> + +/* ========================================================= */ + +/* some fixes to configuration. This also includes modifications + * of STLport switches depending on compiler flags, + * or settings applicable to a group of compilers, such as + * to all who use EDG front-end. + */ +#include <stl/config/stl_confix.h> + +#if !defined (_STLP_NO_MEMBER_TEMPLATES) && !defined (_STLP_MEMBER_TEMPLATES) +# define _STLP_MEMBER_TEMPLATES 1 +#endif + +#if !defined (_STLP_NO_MEMBER_TEMPLATE_CLASSES) && !defined (_STLP_MEMBER_TEMPLATE_CLASSES) +# define _STLP_MEMBER_TEMPLATE_CLASSES 1 +#endif + +#if defined (_STLP_NO_MEMBER_TEMPLATE_CLASSES) && !defined (_STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE) +# define _STLP_DONT_SUPPORT_REBIND_MEMBER_TEMPLATE 1 +#endif + +#if !defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# define _STLP_CLASS_PARTIAL_SPECIALIZATION 1 +#endif + +#if !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER) +# define _STLP_FUNCTION_TMPL_PARTIAL_ORDER 1 +#endif + +#if !defined (_STLP_DONT_USE_SHORT_STRING_OPTIM) && !defined (_STLP_USE_SHORT_STRING_OPTIM) +# define _STLP_USE_SHORT_STRING_OPTIM 1 +#endif + +#if defined (_STLP_MEMBER_TEMPLATES) && !defined (_STLP_NO_EXTENSIONS) && \ + !defined (_STLP_NO_CONTAINERS_EXTENSION) && !defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_USE_CONTAINERS_EXTENSION +#endif + +#if defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_TEMPLATE_FOR_CONT_EXT template <class _KT> +#else +# define _STLP_TEMPLATE_FOR_CONT_EXT +#endif + +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) && \ + (defined (_STLP_NO_CLASS_PARTIAL_SPECIALIZATION) && defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)) +# error Sorry but according the STLport settings your compiler can not support the pointer specialization feature. +#endif + +#if defined (_STLP_WHOLE_NATIVE_STD) && defined (_STLP_NO_OWN_NAMESPACE) +# error Sorry but asking for both STLport to be in the real std namespace and also having STLport import all native std stuff \ + is invalid, chose one or none. +#endif + +#if defined (_STLP_VERBOSE) && !defined (_STLP_VERBOSE_MODE_SUPPORTED) +# error Sorry but the verbose mode is not implemented for your compiler. +#endif + +#if defined (_STLP_NO_IOSTREAMS) && \ + !defined (_STLP_USE_NEWALLOC) && !defined (_STLP_USE_MALLOC) +# define _STLP_USE_NEWALLOC +#endif + +#if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN) +# if defined (_MIPSEB) || defined (__sparc) || defined (_AIX) || \ + defined (__hpux) || defined (macintosh) || defined (_MAC) +# define _STLP_BIG_ENDIAN 1 +# elif defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \ + defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \ + defined (__alpha__) +# define _STLP_LITTLE_ENDIAN 1 +# elif defined (__ia64__) + /* itanium allows both settings (for instance via gcc -mbig-endian) - hence a seperate check is required */ +# if defined (__BIG_ENDIAN__) +# define _STLP_BIG_ENDIAN 1 +# else +# define _STLP_LITTLE_ENDIAN 1 +# endif +# else +# error "can't determine endianess" +# endif +#endif /* _STLP_BIG_ENDIAN */ + +/* ========================================================== + * final workaround tuning based on given flags + * ========================================================== */ + +#ifndef _STLP_UINT32_T +# define _STLP_UINT32_T unsigned long +#endif +#ifndef _STLP_ABORT +# define _STLP_ABORT() abort() +#endif + +#if !defined (_STLP_HAS_NO_NAMESPACES) +# if defined _STLP_NO_NAMESPACES +# undef _STLP_USE_NAMESPACES +# else +/* assume it as the default, turn it off later if NO_NAMESPACES selected */ +# undef _STLP_USE_NAMESPACES +# define _STLP_USE_NAMESPACES 1 +# endif +#endif + +#if defined (_STLP_NO_IOSTREAMS) +# define _STLP_USE_NO_IOSTREAMS +#endif + +/* Operating system recognition (basic) */ +#if (defined(__unix) || defined(__linux__) || defined(__QNX__) || defined(_AIX) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__Lynx__) || defined(__hpux) || defined(__sgi)) && \ + !defined (_STLP_UNIX) +# define _STLP_UNIX 1 +#endif /* __unix */ + +#if !defined (_STLP_NO_LONG_DOUBLE) +# define _STLP_LONGEST_FLOAT_TYPE long double +#else +# define _STLP_LONGEST_FLOAT_TYPE double +#endif + +/* Native headers access macros */ +#if !defined (_STLP_HAS_INCLUDE_NEXT) +# include <stl/config/_native_headers.h> +#endif + +/* shared library tune-up */ + +#if defined (__BUILDING_STLPORT) +/* if we are rebuilding right now, place everything here */ +# undef _STLP_DESIGNATED_DLL +# define _STLP_DESIGNATED_DLL 1 +#endif + +/* Use own namespace always if possible and not explicitly instructed otherwise */ +#if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_BROKEN_USING_DIRECTIVE) && \ + !defined (_STLP_NO_OWN_NAMESPACE) +# undef _STLP_USE_OWN_NAMESPACE +# define _STLP_USE_OWN_NAMESPACE 1 +#else +# undef _STLP_WHOLE_NATIVE_STD +#endif + +#if !defined (_NOTHREADS) && !defined (_STLP_THREADS_DEFINED) + +# if defined (_PTHREADS) +# define _STLP_PTHREADS +# define _STLP_THREADS +# endif +# if defined (_UITHREADS) +# define _STLP_UITHREADS +# define _STLP_THREADS +# endif + +# if defined (_STLP_WIN32) && !defined (_STLP_PTHREADS) +# define _STLP_WIN32THREADS 1 +# elif ((defined (__sun) && !defined (__linux__)) || defined (_UITHREADS) ) && \ + !defined(_STLP_PTHREADS) +# define _STLP_UITHREADS +# else +# define _STLP_PTHREADS +# endif /* __sgi */ +# define _STLP_THREADS_DEFINED +#endif + +#if (defined (_REENTRANT) || defined (_THREAD_SAFE)) && !defined (_STLP_THREADS) +# define _STLP_THREADS +#endif + +#ifndef _STLP_STATIC_MUTEX +# define _STLP_STATIC_MUTEX _STLP_mutex_base +#endif + +#if (defined (_MFC_VER) || defined (_AFXDLL)) && !defined (_STLP_USE_MFC) +# define _STLP_USE_MFC 1 +#endif + +#if defined (_STLP_THREADS) +# define _STLP_VOLATILE volatile +#else +# define _STLP_VOLATILE +#endif + +#if !defined (_STLP_USE_NEW_C_HEADERS) && !defined (_STLP_HAS_NO_NEW_C_HEADERS) +# define _STLP_USE_NEW_C_HEADERS +#endif +/* disable new-style headers if requested */ +#if defined (_STLP_NO_NEW_C_HEADERS) +# undef _STLP_USE_NEW_C_HEADERS +#endif + +#if defined (_STLP_BASE_TYPEDEF_BUG) +# undef _STLP_BASE_TYPEDEF_OUTSIDE_BUG +# define _STLP_BASE_TYPEDEF_OUTSIDE_BUG 1 +#endif + +#if defined (_STLP_NESTED_TYPE_PARAM_BUG) +# define _STLP_GLOBAL_NESTED_RETURN_TYPE_PARAM_BUG +#endif + +/* SUNpro 4.2 inline string literal bug */ +#ifdef _STLP_INLINE_STRING_LITERAL_BUG +# define _STLP_FIX_LITERAL_BUG(__x) __x = __x; +#else +# define _STLP_FIX_LITERAL_BUG(__x) +#endif + +#if defined (_STLP_NON_TYPE_TMPL_PARAM_BUG) +# undef _STLP_NO_DEFAULT_NON_TYPE_PARAM +# define _STLP_NO_DEFAULT_NON_TYPE_PARAM 1 +#endif + +#if !defined (_STLP_STATIC_ASSERT) +/* Some compiler support 0 size array so we use negative size array to generate + * a compilation time error. + */ +# define _STLP_STATIC_ASSERT(expr) typedef char __static_assert[expr ? 1 : -1]; +#endif + +/* apple mpw exception handling bug */ +#ifndef _STLP_MPWFIX_TRY +# define _STLP_MPWFIX_TRY +#endif +#ifndef _STLP_MPWFIX_CATCH +# define _STLP_MPWFIX_CATCH +#endif +#ifndef _STLP_MPWFIX_CATCH_ACTION +# define _STLP_MPWFIX_CATCH_ACTION(action) +#endif + +#if !defined (_STLP_WEAK) +# define _STLP_WEAK +#endif + +/* default parameters as template types derived from arguments ( not always supported ) */ +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define _STLP_DFL_TMPL_PARAM( classname, defval ) class classname +#else +# if !defined (_STLP_DEFAULT_TYPE_PARAM) +# define _STLP_DEFAULT_TYPE_PARAM 1 +# endif +# define _STLP_DFL_TMPL_PARAM( classname, defval ) class classname = defval +#endif + +#if defined (_STLP_LIMITED_DEFAULT_TEMPLATES) +# define _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_Key, _Tp ) class _Alloc +#else +# define _STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_Key, _Tp ) \ + class _Alloc = allocator< pair < _Key, _Tp > > +#endif + +/* default parameters as complete types */ +#if defined (_STLP_DEFAULT_TYPE_PARAM) +# define _STLP_DFL_TYPE_PARAM( classname, defval ) class classname = defval +# define _STLP_DFL_NON_TYPE_PARAM(type,name,val) type name = val +#else +# define _STLP_DFL_TYPE_PARAM( classname, defval ) class classname +# define _STLP_DFL_NON_TYPE_PARAM(type,name,val) type name +#endif + +/* SGI compatibility */ + +#ifdef _STLP_NO_WCHAR_T +# ifndef _STLP_NO_NATIVE_WIDE_STREAMS +# define _STLP_NO_NATIVE_WIDE_STREAMS 1 +# endif +#else +# define _STLP_HAS_WCHAR_T 1 +#endif + +#if !defined (_STLP_NO_AT_MEMBER_FUNCTION) +# define _STLP_CAN_THROW_RANGE_ERRORS 1 +#endif + +/* debug mode tool */ +#if defined (_STLP_DEBUG) +# define _STLP_NON_DBG_NAME(X) _NonDbg_##X +#endif + +/* pointer specialization tool */ +#if defined (_STLP_USE_PTR_SPECIALIZATIONS) +# define _STLP_PTR_IMPL_NAME(X) _Impl_##X +#endif + +#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \ + defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# define _STLP_NO_MEM_T_NAME(X) _NoMemT_##X +#endif + +/* this always mean the C library is in global namespace */ +#if defined (_STLP_HAS_NO_NEW_C_HEADERS) && !defined (_STLP_VENDOR_GLOBAL_CSTD) +# define _STLP_VENDOR_GLOBAL_CSTD 1 +#endif + +/* Depending of whether compiler supports namespaces, + * tune the parameters for vendor-supplied libraries. + * This section is guarded by _STLP_HAS_NO_NAMESPACES, not by _STLP_USE_NAMESPACES, + * since it depends only on the native features, not on user's preference whether + * to use namespace for STLport or not. + */ +#if !defined (_STLP_HAS_NO_NAMESPACES) +/* Import some vendor's headers into corresponding STLport ones if they might be needed + * (if we wrap native iostreams and use namepace other than std::) */ +# if defined (_STLP_WHOLE_NATIVE_STD) +# define _STLP_IMPORT_VENDOR_STD 1 +# endif + +/* if using stlport:: namespace or if C library stuff is not in vendor's std::, + * try importing 'em. + * MSVC has ambiguity problem when we try to import C-style std:: stuff back into global namespace */ +# if defined (_STLP_USE_NAMESPACES) && (defined(_STLP_USE_OWN_NAMESPACE) || defined (_STLP_VENDOR_GLOBAL_CSTD)) +# define _STLP_IMPORT_VENDOR_CSTD 1 +# endif + +# if defined (_STLP_NO_USING_FOR_GLOBAL_FUNCTIONS) && !defined (_STLP_DO_IMPORT_CSTD_FUNCTIONS) +# define _STLP_NO_CSTD_FUNCTION_IMPORTS +# endif + +# define _STLP_USING_NAMESPACE(x) using namespace x ; + +namespace std { } +namespace __std_alias = std; + +/* assume std:: namespace for C++ std library if not being told otherwise */ +# if defined (_STLP_VENDOR_GLOBAL_STD) +# define _STLP_VENDOR_STD +# else +# define _STLP_VENDOR_STD std +# endif + +/* tune things that come from C library */ +# if defined (_STLP_VENDOR_GLOBAL_CSTD) || !defined(_STLP_USE_NEW_C_HEADERS) +/* in old-style headers, C functions go to global scope. */ +# define _STLP_VENDOR_CSTD +# define _STLP_USING_VENDOR_CSTD +# else +# define _STLP_VENDOR_CSTD _STLP_VENDOR_STD +# define _STLP_USING_VENDOR_CSTD _STLP_USING_NAMESPACE(_STLP_VENDOR_CSTD) +# endif /* _STLP_VENDOR_CSTD */ +/* exception, typeinfo, new - always come from the vendor */ +# if !defined (_STLP_VENDOR_EXCEPT_STD) +# if defined (_STLP_VENDOR_GLOBAL_EXCEPT_STD) +# define _STLP_VENDOR_EXCEPT_STD +# else +# define _STLP_VENDOR_EXCEPT_STD _STLP_VENDOR_STD +# endif +# endif +# define _STLP_OLD_IO_NAMESPACE +# if !defined (_STLP_VENDOR_MB_NAMESPACE) +# define _STLP_VENDOR_MB_NAMESPACE _STLP_VENDOR_CSTD +# endif +#else +/* compiler has no namespace support */ +# define _STLP_VENDOR_STD +# define _STLP_VENDOR_CSTD +# define _STLP_USING_NAMESPACE(x) +# define _STLP_USING_VENDOR_CSTD +# define _STLP_VENDOR_EXCEPT_STD +#endif + +#if defined (_STLP_USE_NAMESPACES) + +# if defined (_STLP_USE_OWN_NAMESPACE) +# if !defined (_STLP_STD_NAME) +# if !defined (_STLP_DEBUG) +# if !defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpmtx_std +# else +# define _STLP_STD_NAME stlp_std +# endif +# else +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpxmtx_std +# else +# define _STLP_STD_NAME stlpx_std +# endif +# endif +# else +/* + * The STLport debug mode is binary incompatible with the other modes, + * lets make it clear on the STLport namespace to generate link errors rather + * than runtime ones. + */ +# if !defined (_STLP_USING_CROSS_NATIVE_RUNTIME_LIB) +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpdmtx_std +# else +# define _STLP_STD_NAME stlpd_std +# endif +# else +# ifndef _STLP_THREADS +# define _STLP_STD_NAME stlpdxmtx_std +# else +# define _STLP_STD_NAME stlpdx_std +# endif +# endif +# endif +# endif +namespace _STLP_STD_NAME { } +# else +# define _STLP_STD_NAME std +# endif /* _STLP_USE_OWN_NAMESPACE */ + +# define _STLP_BEGIN_NAMESPACE namespace _STLP_STD_NAME { +# define _STLP_BEGIN_TR1_NAMESPACE namespace tr1 { +# define _STLP_END_NAMESPACE } + +/* decide whether or not we use separate namespace for rel ops */ +# if defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_BEGIN_RELOPS_NAMESPACE _STLP_BEGIN_NAMESPACE namespace rel_ops {} +# define _STLP_END_RELOPS_NAMESPACE } +# else +/* Use std::rel_ops namespace */ +# define _STLP_BEGIN_RELOPS_NAMESPACE _STLP_BEGIN_NAMESPACE namespace rel_ops { +# define _STLP_END_RELOPS_NAMESPACE } } +# define _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# endif /* Use std::rel_ops namespace */ + +# define _STLP_STD ::_STLP_STD_NAME +# if !defined (_STLP_TR1) +# define _STLP_TR1 _STLP_STD::tr1:: +# endif + +# if !defined (_STLP_DONT_USE_PRIV_NAMESPACE) +# define _STLP_PRIV_NAME priv +# define _STLP_PRIV _STLP_STD::_STLP_PRIV_NAME:: +# define _STLP_MOVE_TO_PRIV_NAMESPACE namespace _STLP_PRIV_NAME { +# define _STLP_MOVE_TO_STD_NAMESPACE } +# else +# if !defined (_STLP_PRIV) +# define _STLP_PRIV _STLP_STD:: +# endif +# define _STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_MOVE_TO_STD_NAMESPACE +# endif + +/* Official STLport namespace when std is not redefined. + * Here we don't use a macro because we do not need it and because + * stlport is used as file name by boost and folder name under beos: + */ +namespace stlport = _STLP_STD_NAME; + +/* Backward compatibility: + */ +namespace _STL = _STLP_STD_NAME; +#undef __STLPORT_NAMESPACE +#define __STLPORT_NAMESPACE _STLP_STD_NAME + +#else /* _STLP_USE_NAMESPACES */ +/* STLport is being put into global namespace */ +# define _STLP_STD +# define _STLP_PRIV +# define _STLP_TR1 +# define _STLP_BEGIN_NAMESPACE +# define _STLP_BEGIN_TR1_NAMESPACE +# define _STLP_END_NAMESPACE +# define _STLP_MOVE_TO_PRIV_NAMESPACE +# define _STLP_MOVE_TO_STD_NAMESPACE + +/* boris : it was found out that _STLP_USE_SEPARATE_RELOPS_NAMESPACE + causes less problems than having relational operator templates in global namespace + Please define _STLP_NO_RELOPS_NAMESPACE in config/user_config.h if your code rely on them. */ +# if !defined (_STLP_NO_RELOPS_NAMESPACE) +# define _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# endif +# define _STLP_BEGIN_RELOPS_NAMESPACE +# define _STLP_END_RELOPS_NAMESPACE +# undef _STLP_USE_OWN_NAMESPACE +#endif /* _STLP_USE_NAMESPACES */ + +#define STLPORT_CSTD _STLP_VENDOR_CSTD +#define STLPORT _STLP_STD_NAME + +#if defined(_STLP_BOGUS_TEMPLATE_TYPE_MATCHING_BUG) +# define _STLP_SIMPLE_TYPE(T) _stl_trivial_proxy<T> +#else +# define _STLP_SIMPLE_TYPE(T) T +#endif + +#ifndef _STLP_RAND48 +# define _STLP_NO_DRAND48 +#endif + +/* advanced keywords usage */ +#define __C_CAST(__x, __y) ((__x)(__y)) +#ifndef _STLP_NO_NEW_STYLE_CASTS +# define __CONST_CAST(__x,__y) const_cast<__x>(__y) +# define __STATIC_CAST(__x,__y) static_cast<__x>(__y) +# define __REINTERPRET_CAST(__x,__y) reinterpret_cast<__x>(__y) +#else +# define __STATIC_CAST(__x,__y) __C_CAST(__x, __y) +# define __CONST_CAST(__x,__y) __C_CAST(__x, __y) +# define __REINTERPRET_CAST(__x,__y) __C_CAST(__x, __y) +#endif + +#if defined (_STLP_NEED_TYPENAME) && ! defined (typename) +# define typename +#endif + +#if defined (_STLP_NEED_TYPENAME) || defined (_STLP_NO_TYPENAME_ON_RETURN_TYPE ) +# define _STLP_TYPENAME_ON_RETURN_TYPE +#else +# define _STLP_TYPENAME_ON_RETURN_TYPE typename +#endif + +#ifdef _STLP_NO_TYPENAME_IN_TEMPLATE_HEADER +# define _STLP_HEADER_TYPENAME +#else +# define _STLP_HEADER_TYPENAME typename +#endif + +#ifdef _STLP_NO_TYPENAME_BEFORE_NAMESPACE +# define _STLP_TYPENAME +#else +# define _STLP_TYPENAME typename +#endif + +#ifndef _STLP_NO_MEMBER_TEMPLATE_KEYWORD +# define _STLP_TEMPLATE template +#else +# define _STLP_TEMPLATE +#endif + +#if defined (_STLP_USE_CONTAINERS_EXTENSION) +# define _STLP_KEY_TYPE_FOR_CONT_EXT(type) +# define _STLP_TEMPLATE_FOR_CONT_EXT template <class _KT> +#else +# define _STLP_KEY_TYPE_FOR_CONT_EXT(type) typedef type _KT; +# define _STLP_TEMPLATE_FOR_CONT_EXT +#endif + +#if defined (_STLP_NEED_EXPLICIT) && !defined (explicit) +# define explicit +#endif + +#if !defined (_STLP_NEED_MUTABLE) +# define _STLP_MUTABLE(type, x) x +#else +# define _STLP_MUTABLE(type, x) __CONST_CAST(type*, this)->x +# define mutable +#endif + +#if defined (_STLP_NO_SIGNED_BUILTINS) +/* old HP-UX doesn't understand "signed" keyword */ +# define signed +#endif + +#if defined (_STLP_LOOP_INLINE_PROBLEMS) +# define _STLP_INLINE_LOOP +#else +# define _STLP_INLINE_LOOP inline +#endif + +#ifndef _STLP_NO_PARTIAL_SPECIALIZATION_SYNTAX +# define _STLP_TEMPLATE_NULL template<> +#else +# define _STLP_TEMPLATE_NULL +#endif + +#ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER +# define _STLP_OPERATOR_TEMPLATE +#else +# define _STLP_OPERATOR_TEMPLATE _STLP_TEMPLATE_NULL +#endif + +#ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION +/* unless we have other compiler problem, try simulating partial spec here */ +# if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +# define _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS +# endif +/* For your own iterators, please use inheritance from iterator<> instead of these obsolete queries. */ +# if (defined (_STLP_NESTED_TYPE_PARAM_BUG) || !defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)) +# if ! defined ( _STLP_USE_OLD_HP_ITERATOR_QUERIES ) +# define _STLP_USE_OLD_HP_ITERATOR_QUERIES +# endif +# elif defined ( _STLP_NO_ANACHRONISMS ) +# undef _STLP_USE_OLD_HP_ITERATOR_QUERIES +# endif +#endif + +#ifndef _STLP_NO_EXPLICIT_FUNCTION_TMPL_ARGS +# define _STLP_NULL_TMPL_ARGS <> +# else +# define _STLP_NULL_TMPL_ARGS +#endif + +#if !defined (_STLP_ALLOCATOR_TYPE_DFL) +# if defined (_STLP_DONT_SUP_DFLT_PARAM) +# define _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS +# endif +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) +# define _STLP_ALLOCATOR_TYPE_DFL +# else +# define _STLP_ALLOCATOR_TYPE_DFL = allocator_type() +# endif +#endif + +/* When the compiler do not correctly initialized the basic types value in default parameters we prefer + * to avoid them to be able to correct this bug. + */ +#if defined (_STLP_DEF_CONST_DEF_PARAM_BUG) +# define _STLP_DONT_SUP_DFLT_PARAM 1 +#endif + +#if defined (__SGI_STL_NO_ARROW_OPERATOR) && ! defined (_STLP_NO_ARROW_OPERATOR) +# define _STLP_NO_ARROW_OPERATOR +#endif + +#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if !(defined (_STLP_NO_ARROW_OPERATOR)) && \ + !defined (_STLP_NO_MSVC50_COMPATIBILITY) && !defined (_STLP_MSVC50_COMPATIBILITY) +/* this one is needed for proper reverse_iterator<> operator ->() handling */ +# define _STLP_MSVC50_COMPATIBILITY 1 +# endif +#endif + +#if defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) +# if (defined(__IBMCPP__) && (500 <= __IBMCPP__) && (__IBMCPP__ < 600) ) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef typename _STLP_STD :: reverse_iterator<const_iterator> const_reverse_iterator; \ + typedef typename _STLP_STD :: reverse_iterator<iterator> reverse_iterator +# elif (defined (__sgi) && ! defined (__GNUC__)) || defined (__SUNPRO_CC) || defined (__xlC__) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD:: _STLP_TEMPLATE reverse_iterator<const_iterator> const_reverse_iterator; \ + typedef _STLP_STD:: _STLP_TEMPLATE reverse_iterator<iterator> reverse_iterator +# else +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::reverse_iterator<const_iterator> const_reverse_iterator; \ + typedef _STLP_STD::reverse_iterator<iterator> reverse_iterator +# endif +#else /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ +# if defined (_STLP_MSVC50_COMPATIBILITY) +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::__reverse_iterator<const_iterator, value_type, const_reference, \ + const_pointer, difference_type> const_reverse_iterator; \ + typedef _STLP_STD::__reverse_iterator<iterator, value_type, reference, pointer, difference_type> \ + reverse_iterator +# else +# define _STLP_DECLARE_REVERSE_ITERATORS(__reverse_iterator) \ + typedef _STLP_STD::__reverse_iterator<const_iterator, value_type, const_reference, \ + difference_type> const_reverse_iterator; \ + typedef _STLP_STD::__reverse_iterator<iterator, value_type, \ + reference, difference_type> \ + reverse_iterator +# endif +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +#define _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS \ + _STLP_DECLARE_REVERSE_ITERATORS(reverse_bidirectional_iterator) +#define _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS \ + _STLP_DECLARE_REVERSE_ITERATORS(reverse_iterator) + +#define __IMPORT_CONTAINER_TYPEDEFS(_Super) \ + typedef typename _Super::value_type value_type; \ + typedef typename _Super::size_type size_type; \ + typedef typename _Super::difference_type difference_type; \ + typedef typename _Super::reference reference; \ + typedef typename _Super::const_reference const_reference; \ + typedef typename _Super::pointer pointer; \ + typedef typename _Super::const_pointer const_pointer; \ + typedef typename _Super::allocator_type allocator_type; + + +#define __IMPORT_ITERATORS(_Super) \ + typedef typename _Super::iterator iterator; \ + typedef typename _Super::const_iterator const_iterator; + +#define __IMPORT_REVERSE_ITERATORS(_Super) \ + typedef typename _Super::const_reverse_iterator const_reverse_iterator; \ + typedef typename _Super::reverse_iterator reverse_iterator; + +#define __IMPORT_SUPER_COPY_ASSIGNMENT(__derived_name, _Self, _SUPER) \ + __derived_name(const _Super& __x) : _SUPER(__x) {} \ + _Self& operator=(const _Super& __x) { \ + *(_Super*)this = __x; \ + return *this; \ + } \ + __derived_name(const _Self& __x) : _SUPER(__x) {} \ + _Self& operator=(const _Self& __x) { \ + *(_Super*)this = __x; \ + return *this; \ + } + +#define __IMPORT_WITH_ITERATORS(_Super) \ + __IMPORT_CONTAINER_TYPEDEFS(_Super) __IMPORT_ITERATORS(_Super) + +#define __IMPORT_WITH_REVERSE_ITERATORS(_Super) \ + __IMPORT_WITH_ITERATORS(_Super) __IMPORT_REVERSE_ITERATORS(_Super) + +#if defined (_STLP_TRIVIAL_CONSTRUCTOR_BUG) +# define __TRIVIAL_CONSTRUCTOR(__type) __type() {} +#else +# define __TRIVIAL_CONSTRUCTOR(__type) +#endif + +#if defined (_STLP_TRIVIAL_DESTRUCTOR_BUG) +# define __TRIVIAL_DESTRUCTOR(__type) ~__type() {} +#else +# define __TRIVIAL_DESTRUCTOR(__type) +#endif + +#define __TRIVIAL_STUFF(__type) \ + __TRIVIAL_CONSTRUCTOR(__type) __TRIVIAL_DESTRUCTOR(__type) + +#if defined (_STLP_STATIC_CONST_INIT_BUG) +# define _STLP_STATIC_CONSTANT(__type, __assignment) enum { __assignment } +#else +# define _STLP_STATIC_CONSTANT(__type, __assignment) static const __type __assignment +#endif + +#if defined (_STLP_HAS_NO_EXCEPTIONS) +# define _STLP_NO_EXCEPTIONS +#endif + +#if !defined (_STLP_DONT_USE_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTIONS) && !defined (_STLP_USE_EXCEPTIONS) +# define _STLP_USE_EXCEPTIONS +#endif + +#if defined (_STLP_USE_EXCEPTIONS) +# define _STLP_TRY try +# define _STLP_CATCH_ALL catch(...) +# ifndef _STLP_THROW +# define _STLP_THROW(x) throw x +# endif +# define _STLP_RETHROW throw + +# define _STLP_UNWIND(action) catch(...) { action; throw; } + +# ifdef _STLP_THROW_RETURN_BUG +# define _STLP_RET_AFTER_THROW(data) return data; +# else +# define _STLP_RET_AFTER_THROW(data) +# endif + +# if !defined (_STLP_THROWS) +# define _STLP_THROWS(x) throw(x) +# endif +# if !defined (_STLP_NOTHROW) +# define _STLP_NOTHROW throw() +# endif +#else +# define _STLP_TRY +# define _STLP_CATCH_ALL if (false) +# ifndef _STLP_THROW +# define _STLP_THROW(x) +# endif +# define _STLP_RETHROW {} +# define _STLP_UNWIND(action) +# define _STLP_THROWS(x) +# define _STLP_NOTHROW +# define _STLP_RET_AFTER_THROW(data) +#endif + +/* + * Here we check _STLP_NO_EXCEPTIONS which means that the compiler has no + * exception support but not the _STLP_USE_EXCEPTIONS which simply means + * that the user do not want to use them. + */ +#if !defined (_STLP_NO_EXCEPTIONS) && !defined (_STLP_NO_EXCEPTION_SPEC) +# define _STLP_THROWS_INHERENTLY(x) throw x +# define _STLP_NOTHROW_INHERENTLY throw() +#else +# define _STLP_THROWS_INHERENTLY(x) +# define _STLP_NOTHROW_INHERENTLY +#endif + +/* STLport function not returning are functions that throw so we translate + * the noreturn functions in throwing functions taking also into account + * exception support activation. + */ +#if defined (_STLP_NORETURN_FUNCTION) && !defined (_STLP_NO_EXCEPTIONS) && \ + !defined (_STLP_FUNCTION_THROWS) +# define _STLP_FUNCTION_THROWS _STLP_NORETURN_FUNCTION +#else +# define _STLP_FUNCTION_THROWS +#endif + +#if defined(_STLP_NO_BOOL) +# if (defined (__IBMCPP__) && (__IBMCPP__ < 400)) && ! defined (_AIX) +# include <isynonym.hpp> +# if defined (__OS400__) +typedef int bool; +# elif !( defined (__xlC__) || defined (_AIX)) +typedef Boolean bool; +# endif +# else +# if defined(_STLP_YVALS_H) +# include <yvals.h> +# else +# if defined (_STLP_DONT_USE_BOOL_TYPEDEF) +# define bool int +# else +typedef int bool; +# endif +# define true 1 +# define false 0 +# endif +# endif /* __IBMCPP__ */ +#else +# define _STLP_BOOL_KEYWORD 1 +#endif /* _STLP_NO_BOOL */ + +/* uninitialized value filler */ +#ifndef _STLP_SHRED_BYTE +/* This value is designed to cause problems if an error occurs */ +# define _STLP_SHRED_BYTE 0xA3 +#endif /* _STLP_SHRED_BYTE */ + +/* shared library tune-up */ +#ifndef _STLP_IMPORT_DECLSPEC +# define _STLP_IMPORT_DECLSPEC +#endif + +/* a keyword used to instantiate export template */ +#ifndef _STLP_EXPORT_TEMPLATE_KEYWORD +# define _STLP_EXPORT_TEMPLATE_KEYWORD +#endif +#ifndef _STLP_IMPORT_TEMPLATE_KEYWORD +# define _STLP_IMPORT_TEMPLATE_KEYWORD +#endif + +#if !defined (_STLP_NO_CONST_IN_PAIR) +# define _STLP_CONST const +#else +# define _STLP_CONST +#endif + +#ifdef _STLP_USE_NO_IOSTREAMS +/* + * If we do not use iostreams we do not use the export/import + * techniques to avoid build of the STLport library. + */ +# undef _STLP_USE_DECLSPEC +/* We also undef USE_DYNAMIC_LIB macro as this macro add some code + * to use the dynamic (shared) STLport library for some platform/compiler + * configuration leading to problem when not linking to the STLport lib. + */ +# undef _STLP_USE_DYNAMIC_LIB +#endif + +#if defined (_STLP_DLLEXPORT_NEEDS_PREDECLARATION) && defined (_STLP_USE_DECLSPEC) +# if ! defined (_STLP_USE_TEMPLATE_EXPORT) +/* this setting turns on "extern template" extension use */ +# define _STLP_USE_TEMPLATE_EXPORT +# endif +# if defined (_STLP_DESIGNATED_DLL) && ! defined (_STLP_NO_FORCE_INSTANTIATE) +# define _STLP_NO_FORCE_INSTANTIATE +# endif +#endif + +#if defined (_STLP_DESIGNATED_DLL) /* This is a lib which will contain STLport exports */ +# define _STLP_EXPORT _STLP_EXPORT_TEMPLATE_KEYWORD +#else +# define _STLP_EXPORT _STLP_IMPORT_TEMPLATE_KEYWORD +#endif + +#ifndef _STLP_EXPORT_TEMPLATE +# define _STLP_EXPORT_TEMPLATE _STLP_EXPORT template +#endif + +#if defined (_STLP_USE_DECLSPEC) /* using export/import technique */ + +# ifndef _STLP_EXPORT_DECLSPEC +# define _STLP_EXPORT_DECLSPEC +# endif +# ifndef _STLP_IMPORT_DECLSPEC +# define _STLP_IMPORT_DECLSPEC +# endif +# ifndef _STLP_CLASS_EXPORT_DECLSPEC +# define _STLP_CLASS_EXPORT_DECLSPEC +# endif +# ifndef _STLP_CLASS_IMPORT_DECLSPEC +# define _STLP_CLASS_IMPORT_DECLSPEC +# endif +# if defined (_STLP_DESIGNATED_DLL) /* This is a lib which will contain STLport exports */ +# define _STLP_DECLSPEC _STLP_EXPORT_DECLSPEC +# define _STLP_CLASS_DECLSPEC _STLP_CLASS_EXPORT_DECLSPEC +# else +# define _STLP_DECLSPEC _STLP_IMPORT_DECLSPEC /* Other modules, importing STLport exports */ +# define _STLP_CLASS_DECLSPEC _STLP_CLASS_IMPORT_DECLSPEC +# endif + +#else /* Not using DLL export/import specifications */ + +# define _STLP_DECLSPEC +# define _STLP_CLASS_DECLSPEC + +#endif + +#define _STLP_EXPORT_TEMPLATE_CLASS _STLP_EXPORT template class _STLP_CLASS_DECLSPEC + +#if defined (_STLP_NEED_ADDITIONAL_STATIC_DECLSPEC) +# define _STLP_STATIC_DECLSPEC _STLP_DECLSPEC +#else +# define _STLP_STATIC_DECLSPEC +#endif + +#if !defined (_STLP_CALL) +# define _STLP_CALL +#endif + +#ifndef _STLP_USE_NO_IOSTREAMS + +# if defined (__DECCXX) && ! defined (__USE_STD_IOSTREAM) +# define __USE_STD_IOSTREAM +# endif + +/* We only need to expose details of streams implementation + if we use non-standard i/o or are building STLport*/ +# if defined (__BUILDING_STLPORT) || defined (_STLP_NO_FORCE_INSTANTIATE) || !defined(_STLP_NO_CUSTOM_IO) +# define _STLP_EXPOSE_STREAM_IMPLEMENTATION 1 +# endif + +/* We only need to expose details of global implementation if we are building STLport + or have not instantiated everything in the lib */ +# if defined (__BUILDING_STLPORT) || defined (_STLP_NO_FORCE_INSTANTIATE) +# undef _STLP_EXPOSE_GLOBALS_IMPLEMENTATION +# define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION 1 +# endif + +#else /* _STLP_USE_NO_IOSTREAMS */ +/* when we are not using SGI iostreams, we must expose globals, but not streams implementation */ +# define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION +#endif /* _STLP_USE_NO_IOSTREAMS */ + +#ifdef _STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS +# define _STLP_PSPEC2(t1,t2) < t1,t2 > +# define _STLP_PSPEC3(t1,t2,t3) < t1,t2,t3 > +#else +# define _STLP_PSPEC2(t1,t2) /* nothing */ +# define _STLP_PSPEC3(t1,t2,t3) /* nothing */ +#endif + +/* Activation of the partial template workaround: + */ +#if !defined(_STLP_DONT_USE_PARTIAL_SPEC_WRKD) &&\ + (!defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) || !defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER)) +# define _STLP_USE_PARTIAL_SPEC_WORKAROUND +#endif + +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE +# define _STLP_RELOPS_OPERATORS(_TMPL, _TP) \ +_TMPL inline bool _STLP_CALL operator!=(const _TP& __x, const _TP& __y) {return !(__x == __y);}\ +_TMPL inline bool _STLP_CALL operator>(const _TP& __x, const _TP& __y) {return __y < __x;}\ +_TMPL inline bool _STLP_CALL operator<=(const _TP& __x, const _TP& __y) { return !(__y < __x);}\ +_TMPL inline bool _STLP_CALL operator>=(const _TP& __x, const _TP& __y) { return !(__x < __y);} +#else +# define _STLP_RELOPS_OPERATORS(_TMPL, _TP) +#endif + +#if defined ( _STLP_USE_ABBREVS ) +# include <stl/_abbrevs.h> +#endif + +/* Some really useful macro */ +#define _STLP_ARRAY_SIZE(A) sizeof(A) / sizeof(A[0]) +#define _STLP_ARRAY_AND_SIZE(A) A, sizeof(A) / sizeof(A[0]) + +#if !defined (_STLP_MARK_PARAMETER_AS_UNUSED) +# define _STLP_MARK_PARAMETER_AS_UNUSED(X) (void*)X; +#endif + +#if defined (_STLP_CHECK_RUNTIME_COMPATIBILITY) +# if defined (_STLP_USE_NO_IOSTREAMS) +# undef _STLP_CHECK_RUNTIME_COMPATIBILITY +# else +/* The extern "C" simply makes the symbol simpler. */ +#if defined (__cplusplus) +extern "C" +#endif +void _STLP_DECLSPEC _STLP_CALL _STLP_CHECK_RUNTIME_COMPATIBILITY(); +# endif +#endif + +/* some cleanup */ +#undef _STLP_DONT_USE_BOOL_TYPEDEF +#undef _STLP_YVALS_H +#undef _STLP_LOOP_INLINE_PROBLEMS +#undef _STLP_NEED_EXPLICIT +#undef _STLP_NEED_TYPENAME +#undef _STLP_NO_NEW_STYLE_CASTS +#undef __AUTO_CONFIGURED + +#endif /* _STLP_FEATURES_H */ diff --git a/stlport/stlport/stl/config/host.h b/stlport/stlport/stl/config/host.h new file mode 100644 index 0000000..b4b6089 --- /dev/null +++ b/stlport/stlport/stl/config/host.h @@ -0,0 +1,342 @@ +/* + * This file defines site configuration. + */ + +/* + * _STLP_NO_THREADS: if defined, STLport don't use any + * multithreading support. Synonym is _NOTHREADS + */ +/* +#define _NOTHREADS +#define _STLP_NO_THREADS +*/ + +/* _PTHREADS: if defined, use POSIX threads for multithreading support. */ +/* +#define _PTHREADS +*/ + +/* compatibility section + */ + +#if (defined (_STLP_NOTHREADS) || defined (_STLP_NO_THREADS) || defined (NOTHREADS)) +# if !defined (_NOTHREADS) +# define _NOTHREADS +# endif +# if !defined (_STLP_NO_THREADS) +# define _STLP_NO_THREADS +# endif +#endif + +#if !defined(_STLP_USE_DYNAMIC_LIB) && !defined(_STLP_USE_STATIC_LIB) +/* + * Turn _STLP_USE_DYNAMIC_LIB to enforce use of .dll version of STLport library. + * NOTE: please do that only if you know what you are doing! + * Changing default will require you to change makefiles in "build" accordingly + * and to rebuild STLPort library! + * On UNIX, this has no effect, see build/lib/README for make tags. + * See STLport configuration file (build/lib/configure.bat) for help in building + * the require library versions. + */ +/* +#define _STLP_USE_DYNAMIC_LIB +*/ + +/* + * Turn _STLP_USE_STATIC_LIB to enforce use of static version of STLport library. + * NOTE: please do that only if you know what you are doing! + * Changing default will require you to change makefile in "build" accordingly + * and to rebuild STLPort library! + * On UNIX, this has no effect, see build/lib/README for make tags. + * See STLport configuration file (build/lib/configure.bat) for help in building + * the require library versions. + */ +/* +#define _STLP_USE_STATIC_LIB +*/ +#endif + +/* + * Edit relative path below (or put full path) to get native + * compiler vendor's headers included. Default is "../include" + * for _STLP_NATIVE_INCLUDE_PATH, default for other macros is + * _STLP_NATIVE_INCLUDE_PATH. + * Hint: never install STLport in the directory that ends with "include" + */ +/* +#undef _STLP_NATIVE_INCLUDE_PATH +#define _STLP_NATIVE_INCLUDE_PATH ../include +*/ +/* same for C library headers like <cstring> */ +/* +#undef _STLP_NATIVE_CPP_C_INCLUDE_PATH +#define _STLP_NATIVE_CPP_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ +/* same for C headers like <string.h> */ +/* +#undef _STLP_NATIVE_C_INCLUDE_PATH +#define _STLP_NATIVE_C_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ +/* Some compilers locate basic C++ runtime support headers (<new>, <typeinfo>, <exception>) in separate directory */ +/* +#undef _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH +#define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH _STLP_NATIVE_INCLUDE_PATH +*/ + +/* + * If namespases available, STLport use own namespace (and masquerade + * it as std). Disable own namespace may cause undefined behaviour. + */ +/* +#define _STLP_NO_OWN_NAMESPACE 1 +*/ + +/* + * Uncomment _STLP_LEAKS_PEDANTIC to force deallocation of ALL allocated + * memory chunks. Normally not required. But if you worry about quazi-leaks + * (may be reported by some leaks detection tools), use + * _STLP_LEAKS_PEDANTIC. It should be used with _STLP_USE_NEWALLOC or + * _STLP_USE_MALLOC (see below), the default node_alloc allocator also clean + * its internal memory pool but only if STLport is used as a dynamic library + * under Win32 (using MSVC like compilers). + */ +/* +#define _STLP_LEAKS_PEDANTIC 1 +*/ + +/* + * Uncomment _STLP_USE_NEWALLOC to force allocator<T> to use plain "new" + * instead of STLport optimized node allocator engine. + */ +/* +#define _STLP_USE_NEWALLOC 1 +*/ + +/* + * Uncomment _STLP_USE_MALLOC to force allocator<T> to use plain "malloc" + * instead of STLport optimized node allocator engine. + * + * This is default allocator for glibc 2.3.x and later, if not mentioned other + */ +/* +#define _STLP_USE_MALLOC 1 +*/ + +/* + * Uncomment _STLP_USE_PERTHREAD_ALLOC to force allocator<T> to use + * a specific implementation targetting the massively multi-threaded + * environment. The implementation is based on the POSIX pthread + * interface. + */ +/* +#define _STLP_USE_PERTHREAD_ALLOC 1 +*/ + +/* + * Uncomment _STLP_USE_NODE_ALLOC if you want to force allocator<T> to use + * "node_alloc" allocator (this is default allocator for STLport, if not + * used other above, except glibc 2.3.x and later, where default is + * "malloc", due to better results) + */ +/* +#define _STLP_USE_NODE_ALLOC 1 +*/ + +/* + * Set _STLP_DEBUG_ALLOC to use allocators that perform memory debugging, + * such as padding/checking for memory consistency + */ +/* +#define _STLP_DEBUG_ALLOC 1 +*/ + +/* + * For compiler not supporting partial template specialization or ordering of + * template functions STLport implement a workaround based on inheritance + * detection. This inheritance can introduce trouble in client code when + * a user class derived a STL container (which is not advised as STL containers + * do not have virtual destructors). To disable this workaround turn this macro on: + */ +/* +#define _STLP_DONT_USE_PARTIAL_SPEC_WRKD 1 +*/ + +/* + * Uncomment this to force all debug diagnostic to be directed through a + * user-defined global function: + * void __stl_debug_message(const char * format_str, ...) + * instead of predefined STLport routine. + * This allows you to take control of debug message output. + * Default routine calls fprintf(stderr,...) + * Note : If you set this macro, you must supply __stl_debug_message + * function definition somewhere. + */ +/* +#define _STLP_DEBUG_MESSAGE 1 +*/ + +/* + * Uncomment this to force all failed assertions to be executed through + * user-defined global function: + * void __stl_debug_terminate(void). This allows + * you to take control of assertion behaviour for debugging purposes. + * Default routine calls _STLP_ABORT(). + * Note : If you set this macro, you must supply __stl_debug_terminate + * function definition somewhere. + */ +/* +#define _STLP_DEBUG_TERMINATE 1 +*/ + +/* + * Uncomment that to disable exception handling code + */ +/* +#define _STLP_DONT_USE_EXCEPTIONS 1 +*/ + +/* + * _STLP_NO_NAMESPACES: if defined, don't put the library in namespace + * stlport:: or std::, even if the compiler supports namespaces + */ +/* +#define _STLP_NO_NAMESPACES 1 +*/ + +/*========================================================== + * Compatibility section + *==========================================================*/ + +/* + * Use abbreviated class names for linker benefit (don't affect interface). + * This option is obsolete, but should work in this release. + * + */ +/* +#define _STLP_USE_ABBREVS +*/ + +/* + * This definition precludes STLport reverse_iterator to be compatible with + * other parts of MSVC library. (With partial specialization, it just + * has no effect). + * Use it _ONLY_ if you use SGI-style reverse_iterator<> template explicitly + */ +/* +#define _STLP_NO_MSVC50_COMPATIBILITY 1 +*/ + +/* + * Use obsolete overloaded template functions iterator_category(), value_type(), distance_type() + * for querying iterator properties. Please note those names are non-standard and are not guaranteed + * to be used by every implementation. However, this setting is on by default when partial specialization + * is not implemented in the compiler and cannot be simulated (only if _STLP_NO_ANACHRONISMS is not set). + * Use of those interfaces for user-defined iterators is strongly discouraged: + * please use public inheritance from iterator<> template to achieve desired effect. + * Second form is to disable old-style queries in any case. + */ +/* +#define _STLP_USE_OLD_HP_ITERATOR_QUERIES +#define _STLP_NO_OLD_HP_ITERATOR_QUERIES +*/ + + +/* + * On systems with support of large files (_LARGEFILE_SOURCE, + * _LARGEFILE64_SOURCE defined) we will use 64-bit file offset, even if + * __USE_FILE_OFFSET64 or _FILE_OFFSET_BITS not defined or _FILE_OFFSET_BITS + * less than 64. In the last case sizeof(std::streamoff) may not be equal to + * sizeof(off_t); if you want to force equal size of off_t and streamoff, + * uncomment macro below. But pay attention, this has influence on libstlport + * and in future usage it may cause conflict with defined _FILE_OFFSET_BITS macro. + */ + +/* +#define _STLP_USE_DEFAULT_FILE_OFFSET +*/ + +/* + * _STLP_USE_STDIO_IO, _STLP_USE_UNIX_IO: force selection of stdio calls + * (fopen/flose/fread/fwrite) under fstream buffers or unistd calls + * (open/close/read/write + mmap). On systems that have both (i.e. most Unixes) + * _STLP_USE_UNIX_IO is used. + * + * There is a third variant for Windows: _STLP_USE_WIN32_IO, that based + * on Windows calls (CreateFile/CloseHandle/ReadFile/WriteFile + CreateFileMapping, + * MapViewOfFile) + * + * Uncomment only one define here! + */ +/* +#define _STLP_USE_UNIX_IO +*/ +/* +#define _STLP_USE_STDIO_IO +*/ +/* +#define _STLP_USE_WIN32_IO + */ + +/*==========================================================================*/ + +/* This section contains swithes which should be off by default, + * but so few compilers would have it undefined, so that we set them here, + * with the option to be turned off later in compiler-specific file + */ + +#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT +#define _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT + +/*==========================================================================*/ + +#if defined(__sun) && defined(__GNUC__) +/* __SunOS_5_x is not defined in headers, and there is no way to derive it from headers only; + * nevertheless this macro defined automagically by SunPro compilers family; + * + * gcc know nothing about it, but defining it with -D on compiler command line + * is a bad idea from one side, and this info still useful when we want to use + * (or don't use) some Solaris version-specific features from other side. + * Of course, the best way is to define it in spec file, but this is beyond our scope. + * + * Uncomment ONE of the following, depends on what Solaris version you use. + */ + +/* +#define __SunOS_5_5_1 + */ +/* +#define __SunOS_5_6 + */ +/* +#define __SunOS_5_7 + */ +/* +#define __SunOS_5_8 + */ +/* +#define __SunOS_5_9 + */ +/* +#define __SunOS_5_10 + */ +#endif + +#if defined(__sun) +/* With following patches Solaris 8 and 9 will have *l and *f (long double and float) + * variants of math functions: + * SunOS 5.8 patch 111721-04 (May/08/2003) + * <http://sunsolve.sun.com/search/document.do?assetkey=1-21-111721-04-1> + * SunOS 5.9 patch 111722-04 (May/08/2003) + * <http://sunsolve.sun.com/search/document.do?assetkey=1-21-111722-04-1> + * Solaris 10 has this functions from box. + */ +/* +#define _STLP_SOLARIS_MATH_PATCH + */ +#endif + +/* + Local Variables: + mode:C++ + End: +*/ diff --git a/stlport/stlport/stl/config/stl_confix.h b/stlport/stlport/stl/config/stl_confix.h new file mode 100644 index 0000000..ddcdf1d --- /dev/null +++ b/stlport/stlport/stl/config/stl_confix.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* + * STLport configuration file + * It is internal STLport header - DO NOT include it directly + * Purpose of this file : to define STLport settings that depend on + * compiler flags or can be otherwise missed + * + */ + +#ifndef _STLP_CONFIX_H +#define _STLP_CONFIX_H + +/* If, by any chance, C compiler gets there, try to help it to pass smoothly */ +#if ! defined (__cplusplus) && ! defined (_STLP_HAS_NO_NAMESPACES) +# define _STLP_HAS_NO_NAMESPACES +#endif + +#if defined (__MINGW32__) +# define _STLP_NO_DRAND48 +#endif + +/* Modena C++ library */ +#if defined (__MWERKS__) && __MWERKS__ <= 0x2303 || (defined (__KCC) && __KCC_VERSION < 3400) +# include <mcompile.h> +# define _STLP_USE_MSIPL 1 +# if defined (__KCC) || (defined(__MSL_CPP__) && \ + ( (__MSL_CPP__ >= 0x5000 && defined( _MSL_NO_MESSAGE_FACET )) || \ + (__MSL_CPP__ < 0x5000 && defined( MSIPL_NL_TYPES )))) +# define _STLP_NO_NATIVE_MESSAGE_FACET 1 +# endif +#endif + +/* common switches for EDG front-end */ +/* __EDG_SWITCHES do not seem to be an official EDG macro. + * We keep it for historical reason. */ +#if defined (__EDG_SWITCHES) +# if !(defined(_TYPENAME) || defined (_TYPENAME_IS_KEYWORD)) +# undef _STLP_NEED_TYPENAME +# define _STLP_NEED_TYPENAME 1 +# endif +# ifndef _WCHAR_T_IS_KEYWORD +# undef _STLP_NO_WCHAR_T +# define _STLP_NO_WCHAR_T 1 +# endif +# ifndef _PARTIAL_SPECIALIZATION_OF_CLASS_TEMPLATES +# undef _STLP_NO_CLASS_PARTIAL_SPECIALIZATION +# define _STLP_NO_CLASS_PARTIAL_SPECIALIZATION 1 +# endif +# ifndef _MEMBER_TEMPLATES +# undef _STLP_NO_MEMBER_TEMPLATES +# define _STLP_NO_MEMBER_TEMPLATES 1 +# undef _STLP_NO_MEMBER_TEMPLATE_CLASSES +# define _STLP_NO_MEMBER_TEMPLATE_CLASSES 1 +# endif +# ifndef _MEMBER_TEMPLATE_KEYWORD +# undef _STLP_NO_MEMBER_TEMPLATE_KEYWORD +# define _STLP_NO_MEMBER_TEMPLATE_KEYWORD 1 +# endif +# if !defined (__EXCEPTIONS) && ! defined (_EXCEPTIONS) +# undef _STLP_HAS_NO_EXCEPTIONS +# define _STLP_HAS_NO_EXCEPTIONS +# endif +# undef __EDG_SWITCHES +#endif /* EDG */ + +/* __EDG_VERSION__ is an official EDG macro, compilers based + * on EDG have to define it. */ +#if defined (__EDG_VERSION__) +# if (__EDG_VERSION__ >= 244) && !defined (_STLP_HAS_INCLUDE_NEXT) +# define _STLP_HAS_INCLUDE_NEXT +# endif +# if (__EDG_VERSION__ <= 240) && !defined (_STLP_DONT_RETURN_VOID) +# define _STLP_DONT_RETURN_VOID +# endif +# if !defined (__EXCEPTIONS) && !defined (_STLP_HAS_NO_EXCEPTIONS) +# define _STLP_HAS_NO_EXCEPTIONS +# endif +# if !defined (__NO_LONG_LONG) && !defined (_STLP_LONG_LONG) +# define _STLP_LONG_LONG long long +# endif +#endif + +#endif diff --git a/stlport/stlport/stl/config/user_config.h b/stlport/stlport/stl/config/user_config.h new file mode 100755 index 0000000..9485923 --- /dev/null +++ b/stlport/stlport/stl/config/user_config.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + */ + +/* + * Purpose of this file : + * + * To hold user-definable portion of STLport settings which may be overridden + * on per-project basis. + * Please note that if you use STLport iostreams (compiled library) then you have + * to use consistent settings when you compile STLport library and your project. + * Those settings are defined in host.h and have to be the same for a given + * STLport installation. + */ + +/*========================================================== + * User-settable macros that control compilation: + * Features selection + *==========================================================*/ + +/* + * Use this switch for embedded systems where no iostreams are available + * at all. STLport own iostreams will also get disabled automatically then. + * You can either use STLport iostreams, or no iostreams. + * If you want iostreams, you have to compile library in ../build/lib + * and supply resulting library at link time. + */ +#define _STLP_NO_IOSTREAMS 1 + +/* + * Set _STLP_DEBUG to turn the "Debug Mode" on. + * That gets you checked iterators/ranges in the manner + * of "Safe STL". Very useful for debugging. Thread-safe. + * Please do not forget to link proper STLport library flavor + * (e.g libstlportstlg.so or libstlportstlg.a) when you set this flag + * in STLport iostreams mode, namespace customization guaranty that you + * link to the right library. + */ +/* +#define _STLP_DEBUG 1 +*/ +/* + * You can also choose the debug level: + * STLport debug level: Default value + * Check only what the STLport implementation consider as invalid. + * It also change the iterator invalidation schema. + * Standard debug level: Check for all operations the standard consider as "undefined behavior" + * even if STlport implement it correctly. It also invalidates iterators + * more often. + */ +/* +#define _STLP_DEBUG_LEVEL _STLP_STLPORT_DBG_LEVEL +#define _STLP_DEBUG_LEVEL _STLP_STANDARD_DBG_LEVEL +*/ +/* When an inconsistency is detected by the 'safe STL' the program will abort. + * If you prefer an exception define the following macro. The thrown exception + * will be the Standard runtime_error exception. + */ +/* +#define _STLP_DEBUG_MODE_THROWS + */ + +/* + * _STLP_NO_CUSTOM_IO : define this if you do not instantiate basic_xxx iostream + * classes with custom types (which is most likely the case). Custom means types + * other than char, wchar_t, char_traits<> and allocator<> like + * basic_ostream<my_char_type, my_traits<my_char_type> > or + * basic_string<char, char_traits<char>, my_allocator > + * When this option is on, most non-inline template functions definitions for iostreams + * are not seen by the client which saves a lot of compile time for most compilers, + * also object and executable size for some. + * Default is off, just not to break compilation for those who do use those types. + * That also guarantees that you still use optimized standard i/o when you compile + * your program without optimization. Option does not affect STLport library build; you + * may use the same binary library with and without this option, on per-project basis. + */ +/* +#define _STLP_NO_CUSTOM_IO +*/ + +/* + * _STLP_NO_RELOPS_NAMESPACE: if defined, don't put the relational + * operator templates (>, <=, >=, !=) in namespace std::rel_ops, even + * if the compiler supports namespaces. + * Note : if the compiler do not support namespaces, those operators are not be provided by default, + * to simulate hiding them into rel_ops. This was proved to resolve many compiler bugs with ambiguity. + */ +/* +#define _STLP_NO_RELOPS_NAMESPACE 1 +*/ + +/* + * If STLport use its own namespace, see _STLP_NO_OWN_NAMESPACE in host.h, it will try + * by default to rename std:: for the user to stlport::. If you do not want this feature, + * please define the following switch and then use stlport:: + */ +/* +#define _STLP_DONT_REDEFINE_STD 1 +*/ + +/* + * _STLP_WHOLE_NATIVE_STD : only meaningful if STLport uses its own namespace. + * Normally, STLport only imports necessary components from native std:: namespace. + * You might want everything from std:: being available in std:: namespace when you + * include corresponding STLport header (like STLport <map> provides std::map as well, etc.), + * if you are going to use both stlport:: and std:: components in your code. + * Otherwise this option is not recommended as it increases the size of your object files + * and slows down compilation. + * Beware, if you do not use STLport iostream (_STLP_NO_IOSTREAMS above), ask STLport to + * not rename std:: in stlport:: and try to have access to whole native Standard stuff then + * STLport will only throw exceptions from the std namespace and not from stlport. + * For instance a problem in stlport::vector::at will throw a std::out_of_range exception + * and not a stlport::out_of_range. + * Notice that STLport exceptions inherits from std::exception. + */ +/* +#define _STLP_WHOLE_NATIVE_STD +*/ + +/* + * Use this option to catch uninitialized members in your classes. + * When it is set, construct() and destroy() fill the class storage + * with _STLP_SHRED_BYTE (see below). + * Note : _STLP_DEBUG and _STLP_DEBUG_ALLOC don't set this option automatically. + */ +/* +#define _STLP_DEBUG_UNINITIALIZED 1 +#define _STLP_DEBUG_ALLOC 1 +*/ + +/* + * Uncomment and provide a definition for the byte with which raw memory + * will be filled if _STLP_DEBUG_ALLOC or _STLP_DEBUG_UNINITIALIZED is defined. + * Choose a value which is likely to cause a noticeable problem if dereferenced + * or otherwise abused. A good value may already be defined for your platform. + */ +/* +#define _STLP_SHRED_BYTE 0xA3 +*/ + +/* + * This option is for gcc users only and only affects systems where native linker + * does not let gcc to implement automatic instantiation of static template data members/ + * It is being put in this file as there is no way to check if we are using GNU ld automatically, + * so it becomes user's responsibility. + */ +/* +#define _STLP_GCC_USES_GNU_LD +*/ + +/*========================================================== + * Compatibility section + *==========================================================*/ + +/* + * Define this macro to disable anachronistic constructs (like the ones used in HP STL and + * not included in final standard, etc. + */ +/* +#define _STLP_NO_ANACHRONISMS 1 +*/ + +/* + * Define this macro to disable STLport extensions (for example, to make sure your code will + * compile with some other implementation ) + */ +/* +#define _STLP_NO_EXTENSIONS 1 +*/ + +/* + * You should define this macro if compiling with MFC - STLport <stl/config/_windows.h> + * then include <afx.h> instead of <windows.h> to get synchronisation primitives + */ +/* +#define _STLP_USE_MFC 1 +*/ + +/* + * boris : this setting is here as we cannot detect precense of new Platform SDK automatically + * If you are using new PSDK with VC++ 6.0 or lower, + * please define this to get correct prototypes for InterlockedXXX functions + */ +/* +#define _STLP_NEW_PLATFORM_SDK 1 +*/ + +/* + * For the same reason as the one above we are not able to detect easily use + * of the compiler coming with the Platform SDK instead of the one coming with + * a Microsoft Visual Studio release. This change native C/C++ library location + * and implementation, please define this to get correct STLport configuration. + */ +/* +#define _STLP_USING_PLATFORM_SDK_COMPILER 1 +*/ + +/* + * Some compilers support the automatic linking feature. + * Uncomment the following if you prefer to specify the STLport library + * to link with yourself. + * For the moment, this feature is only supported and implemented within STLport + * by the Microsoft compilers. + */ +#define _STLP_DONT_USE_AUTO_LINK 1 + +/* + * If you customize the STLport generated library names don't forget to give + * the motif you used during configuration here if you still want the auto link + * to work. (Do not remove double quotes in the macro value) + */ +/* +#define _STLP_LIB_NAME_MOTIF "???" + */ + +/* + * Uncomment to get feedback at compilation time about result of build environment + * introspection. + */ +/* +#define _STLP_VERBOSE 1 +*/ + +/* + * Use minimum set of default arguments on template classes that have more + * than one - for example map<>, set<>. + * This has effect only if _STLP_LIMITED_DEFAULT_TEMPLATES is on. + * If _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS is set, you'll be able to compile + * set<T> with those compilers, but you'll have to use __set__<T, less<T>> + * + * Affects : map<>, multimap<>, set<>, multiset<>, hash_*<>, + * queue<>, priority_queue<>, stack<>, istream_iterator<> + */ +/* +#define _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS 1 +*/ + +/* + * The agregation of strings using the + operator is an expensive operation + * as it requires construction of temporary objects that need memory allocation + * and deallocation. The problem can be even more important if you are adding + * several strings together in a single expression. To avoid this problem STLport + * implement expression template. With this technique addition of 2 strings is not + * a string anymore but a temporary object having a reference to each of the + * original strings involved in the expression. This object carry information + * directly to the destination string to set its size correctly and only make + * a single call to the allocator. This technique also works for the addition of + * N elements where elements are basic_string, C string or a single character. + * The drawback can be longer compilation time and bigger executable size. + * Another problem is that some compilers (gcc) fail to use string proxy object + * if do with class derived from string (see unit tests for details). + * STLport rebuild: Yes + */ +/* +#define _STLP_USE_TEMPLATE_EXPRESSION 1 +*/ + + +/* + * By default the STLport basic_string implementation use a little static buffer + * (of 16 chars when writing this doc) to avoid systematically memory allocation + * in case of little basic_string. The drawback of such a method is bigger + * basic_string size and some performance penalty for method like swap. If you + * prefer systematical dynamic allocation turn on this macro. + * STLport rebuild: Yes + */ +/* +#define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 +*/ + +/* + * To reduce the famous code bloat trouble due to the use of templates STLport grant + * a specialization of some containers for pointer types. So all instanciations + * of those containers with a pointer type will use the same implementation based on + * a container of void*. This feature has shown very good result on object files size + * but after link phase and optimization you will only experiment benefit if you use + * many container with pointer types. + * There are however a number of limitation to use this option: + * - with compilers not supporting partial template specialization feature, you won't + * be able to access some nested container types like iterator as long as the + * definition of the type used to instanciate the container will be incomplete + * (see IncompleteClass definition in test/unit/vector_test.cpp). + * - you won't be able to use complex Standard allocator implementations which are + * allocators having pointer nested type not being a real C pointer. + */ +/* +#define _STLP_USE_PTR_SPECIALIZATIONS 1 +*/ + +/* + * To achieve many different optimizations within the template implementations STLport + * uses some type traits technique. With this macro you can ask STLport to use the famous + * boost type traits rather than the internal one. The advantages are more compiler + * integration and a better support. If you only define this macro once the STLport has been + * built you just have to add the boost install path within your include path. If you want + * to use this feature at STLport built time you will have to define the + * STLP_BUILD_BOOST_PATH enrironment variable with the value of the boost library path. + */ + +/* +#define _STLP_USE_BOOST_SUPPORT 1 +*/ + + +/*==========================================================*/ + +/* + Local Variables: + mode: C++ + End: +*/ diff --git a/stlport/stlport/stl/debug/_debug.h b/stlport/stlport/stl/debug/_debug.h new file mode 100644 index 0000000..6a2a8ce --- /dev/null +++ b/stlport/stlport/stl/debug/_debug.h @@ -0,0 +1,473 @@ +/* + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_DEBUG_H +#define _STLP_DEBUG_H + +#if (defined (_STLP_DEBUG) || defined (_STLP_DEBUG_ALLOC)) && \ + !defined (_STLP_ASSERTIONS) +# define _STLP_ASSERTIONS 1 +#endif + +#if defined (_STLP_ASSERTIONS) + +# if !defined (_STLP_FILE__) +# define _STLP_FILE__ __FILE__ +# endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +enum { + //General errors + _StlFormat_ERROR_RETURN, + _StlFormat_ASSERTION_FAILURE, + _StlFormat_VERBOSE_ASSERTION_FAILURE, + _StlMsg_INVALID_ARGUMENT, + //Container/Iterator related errors + _StlMsg_INVALID_CONTAINER, + _StlMsg_EMPTY_CONTAINER, + _StlMsg_ERASE_PAST_THE_END, + _StlMsg_OUT_OF_BOUNDS, + _StlMsg_NOT_OWNER, + _StlMsg_SHOULD_NOT_OWNER, + _StlMsg_INVALID_ITERATOR, + _StlMsg_INVALID_LEFTHAND_ITERATOR, + _StlMsg_INVALID_RIGHTHAND_ITERATOR, + _StlMsg_DIFFERENT_OWNERS , + _StlMsg_NOT_DEREFERENCEABLE , + _StlMsg_INVALID_RANGE , + _StlMsg_NOT_IN_RANGE_1 , + _StlMsg_NOT_IN_RANGE_2 , + _StlMsg_INVALID_ADVANCE , + _StlMsg_SINGULAR_ITERATOR , + //Bad predicate for sorting + _StlMsg_INVALID_STRICT_WEAK_PREDICATE, + _StlMsg_INVALID_EQUIVALENT_PREDICATE, + // debug alloc messages + _StlMsg_DBA_DELETED_TWICE , + _StlMsg_DBA_NEVER_ALLOCATED , + _StlMsg_DBA_TYPE_MISMATCH , + _StlMsg_DBA_SIZE_MISMATCH , + _StlMsg_DBA_UNDERRUN , + _StlMsg_DBA_OVERRUN , + // auto_ptr messages + _StlMsg_AUTO_PTR_NULL , + //Memory alignent message + _StlMsg_WRONG_MEMORY_ALIGNMENT, + _StlMsg_UNKNOWN + /* _StlMsg_MAX */ +}; + +/* have to hardcode that ;() */ +# define _StlMsg_MAX 31 + +class __owned_link; +class __owned_list; + +# if defined (_STLP_DEBUG_MODE_THROWS) +# define _STLP_MESSAGE_NORETURN _STLP_FUNCTION_THROWS +# else +# define _STLP_MESSAGE_NORETURN +# endif + +template <class _Dummy> +class __stl_debug_engine { +public: + // Basic routine to report any debug message + // Use _STLP_DEBUG_MESSAGE to override + static void _STLP_MESSAGE_NORETURN _STLP_CALL _Message(const char * format_str, ...); + + // Micsellanous function to report indexed error message + static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l); + + // Basic assertion report mechanism. + // Reports failed assertion via __stl_debug_message and calls _Terminate + // if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead + static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l); + + // The same, with additional diagnostics + static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l); + + // If exceptions are present, sends unique exception + // If not, calls _STLP_ABORT() to terminate + // Use _STLP_DEBUG_TERMINATE to override + static void _STLP_CALL _Terminate(); + +# if defined (_STLP_DEBUG) + // owned_list/link delegate non-inline functions here + + static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1, + const __owned_link& __i2); + static bool _STLP_CALL _Check_same_or_null_owner( const __owned_link& __i1, + const __owned_link& __i2); + static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&); + + static bool _STLP_CALL _Check_if_not_owner( const __owned_list*, const __owned_link&); + + static void _STLP_CALL _Verify(const __owned_list*); + + static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list&); + + static void _STLP_CALL _Invalidate_all(__owned_list*); + + static void _STLP_CALL _Set_owner(__owned_list& /*src*/, __owned_list& /*dst*/); + + static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*); + + static void _STLP_CALL _M_detach(__owned_list*, __owned_link*); + + static void _STLP_CALL _M_attach(__owned_list*, __owned_link*); + + // accessor : check and get pointer to the container + static void* _STLP_CALL _Get_container_ptr(const __owned_link*); +# endif + + // debug messages and formats + static const char* _Message_table[_StlMsg_MAX]; +}; + +# undef _STLP_MESSAGE_NORETURN + +# if defined (_STLP_USE_TEMPLATE_EXPORT) +_STLP_EXPORT_TEMPLATE_CLASS __stl_debug_engine<bool>; +# endif + +typedef __stl_debug_engine<bool> __stl_debugger; + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +# if !defined (_STLP_ASSERT) +# define _STLP_ASSERT(expr) \ + if (!(expr)) { _STLP_PRIV __stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__); } +# endif + +#else +# define _STLP_ASSERT(expr) +#endif + +// this section is for _STLP_DEBUG only +#if defined (_STLP_DEBUG) + +# if !defined (_STLP_VERBOSE_ASSERT) +// fbp : new form not requiring ";" +# define _STLP_VERBOSE_ASSERT(expr, __diag_num) \ + if (!(expr)) { _STLP_PRIV __stl_debugger::_VerboseAssert\ + ( # expr, _STLP_PRIV __diag_num, _STLP_FILE__, __LINE__ ); \ + } +# endif + +# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr) + +# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) +# define _STLP_STD_DEBUG_CHECK(expr) _STLP_DEBUG_CHECK(expr) +# else +# define _STLP_STD_DEBUG_CHECK(expr) +# endif + +# if !defined (_STLP_VERBOSE_RETURN) +# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \ + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__ , __LINE__); \ + return false; } +# endif + +# if !defined (_STLP_VERBOSE_RETURN_0) +# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \ + _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__, __LINE__); \ + return 0; } +# endif + +# ifndef _STLP_INTERNAL_THREADS_H +# include <stl/_threads.h> +# endif + +# ifndef _STLP_INTERNAL_ITERATOR_BASE_H +# include <stl/_iterator_base.h> +# endif + +# ifndef _STLP_TYPE_TRAITS_H +# include <stl/type_traits.h> +# endif + +_STLP_BEGIN_NAMESPACE + +_STLP_MOVE_TO_PRIV_NAMESPACE + +/* + * Special debug iterator traits having an additionnal static member + * method _Check. It is used by the slist debug implementation to check + * the special before_begin iterator. + */ +template <class _Traits> +struct _DbgTraits : _Traits { + typedef _DbgTraits<typename _Traits::_ConstTraits> _ConstTraits; + typedef _DbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits; + + template <class _Iterator> + static bool _Check(const _Iterator&) {return true;} +}; + +//============================================================= +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const random_access_iterator_tag&) +{ return (__i1 < __i2) || (__i1 == __i2); } + +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const bidirectional_iterator_tag&) { + // check if comparable + bool __dummy(__i1==__i2); + return (__dummy==__dummy); +} + +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2, + const forward_iterator_tag&) { + // check if comparable + bool __dummy(__i1==__i2); + return (__dummy==__dummy); +} + +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, + const input_iterator_tag&) +{ return true; } + +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&, + const output_iterator_tag&) +{ return true; } + +template <class _Iterator> +inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2) +{ return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)); } + +// Note : that means in range [i1, i2]. +template <class _Iterator> +inline bool _STLP_CALL stlp_in_range(const _Iterator& _It, + const _Iterator& __i1, const _Iterator& __i2) +{ return __valid_range(__i1,_It) && __valid_range(_It,__i2); } + +template <class _Iterator> +inline bool _STLP_CALL stlp_in_range(const _Iterator& __first, const _Iterator& __last, + const _Iterator& __start, const _Iterator& __finish) +{ return __valid_range(__first,__last) && __valid_range(__start,__first) && __valid_range(__last,__finish); } + +//========================================================== +class _STLP_CLASS_DECLSPEC __owned_link { +public: + // Note: This and the following special defines for compiling under Windows CE under ARM + // is needed for correctly using _STLP_DEBUG mode. This comes from a bug in the ARM + // compiler where checked iterators that are passed by value call _M_attach with the wrong + // this pointer and calling _M_detach can't find the correct pointer to the __owned_link. + // This is circumvented by managing a _M_self pointer that points to the correct value. + // Ugly but works. +#if defined(_STLP_WCE) && defined(_ARM_) + __owned_link() : _M_self(this), _M_owner(0) {} + __owned_link(const __owned_list* __c) : _M_self(this), _M_owner(0), _M_next(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); } + __owned_link(const __owned_link& __rhs): _M_self(this), _M_owner(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); } +#else + __owned_link() : _M_owner(0) {} + __owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); } + __owned_link(const __owned_link& __rhs): _M_owner(0) + { __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); } +#endif + __owned_link& operator=(const __owned_link& __rhs) { + __owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner); + __owned_list* __old_owner = _M_owner; + if ( __old_owner != __new_owner ) { + __stl_debugger::_M_detach(__old_owner, this); + __stl_debugger::_M_attach(__new_owner, this); + } + return *this; + } +#if defined(_STLP_WCE) && defined(_ARM_) + ~__owned_link() { + __stl_debugger::_M_detach(_M_owner, _M_self); + _Invalidate(); + } +#else + ~__owned_link() { + __stl_debugger::_M_detach(_M_owner, this); + _Invalidate(); + } +#endif + + const __owned_list* _Owner() const { return _M_owner; } + __owned_list* _Owner() { return _M_owner; } + void _Set_owner(const __owned_list* __o) { _M_owner= __CONST_CAST(__owned_list*,__o); } + bool _Valid() const { return _M_owner != 0; } + void _Invalidate() { _M_owner = 0; _M_next = 0; } + void _Link_to_self() { _M_next = 0; } + + __owned_link* _Next() { return _M_next; } + const __owned_link* _Next() const { return _M_next; } + +public: +#if defined(_STLP_WCE) && defined(_ARM_) + __owned_link* _M_self; +#endif + + __owned_list* _M_owner; + __owned_link* _M_next; +}; + + +class _STLP_CLASS_DECLSPEC __owned_list { +public: + __owned_list(void* __o) { + // fprintf(stderr, "__owned_list(): %p\n",(void*)this); + _M_node._M_owner = __REINTERPRET_CAST(__owned_list*,__o); + _M_node._M_next = 0; + } + ~__owned_list() { + // fprintf(stderr, "~__owned_list(): %p\n",(void*)this); + _Invalidate_all(); + // that prevents detach + _M_node._Invalidate(); + } + const void* _Owner() const { return (const void*)_M_node._M_owner; } + void* _Owner() { return (void*)_M_node._M_owner; } + bool _Valid() const { return _M_node._M_owner != 0; } + void _Invalidate() { _M_node._M_owner = 0; } + + __owned_link* _First() { return _M_node._Next(); } + __owned_link* _Last() { return 0 ; } + + const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; } + const __owned_link* _Last() const { return 0 ;} + + void _Verify() const { __stl_debugger::_Verify(this); } + void _Swap_owners(__owned_list& __y) { __stl_debugger::_Swap_owners(*this, __y); } + void _Invalidate_all() { __stl_debugger::_Invalidate_all(this); } + void _Set_owner(__owned_list& __y) { __stl_debugger::_Set_owner(*this, __y); } + + mutable __owned_link _M_node; + mutable _STLP_mutex _M_lock; + +private: + // should never be called, should be left not implemented, + // but some compilers complain about it ;( + __owned_list(const __owned_list&){} + __owned_list& operator = (const __owned_list&) { return *this; } + + friend class __owned_link; + friend class __stl_debug_engine<bool>; +}; + + +//========================================================== + +// forward declaratioins + +template <class _Iterator> +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&); +template <class _Iterator> +bool _STLP_CALL __check_range(const _Iterator&, + const _Iterator&, const _Iterator&); +template <class _Iterator> +bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& , + const _Iterator&, const _Iterator& ); +template <class _Tp> +bool _STLP_CALL __check_ptr_range(const _Tp*, const _Tp*); + +template <class _Iterator> +void _STLP_CALL __invalidate_range(const __owned_list* __base, + const _Iterator& __first, + const _Iterator& __last); + +template <class _Iterator> +void _STLP_CALL __invalidate_iterator(const __owned_list* __base, + const _Iterator& __it); + +template <class _Iterator> +void _STLP_CALL __change_range_owner(const _Iterator& __first, + const _Iterator& __last, + const __owned_list* __dst); + +template <class _Iterator> +void _STLP_CALL __change_ite_owner(const _Iterator& __it, + const __owned_list* __dst); + +//============================================================ +inline bool _STLP_CALL +__check_same_owner(const __owned_link& __i1, const __owned_link& __i2) +{ return __stl_debugger::_Check_same_owner(__i1,__i2); } + +inline bool _STLP_CALL +__check_same_or_null_owner(const __owned_link& __i1, const __owned_link& __i2) +{ return __stl_debugger::_Check_same_or_null_owner(__i1,__i2); } + +template <class _Iterator> +inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner, + const _Iterator& __it) +{ return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it); } + +template <class _Iterator> +inline bool _STLP_CALL __check_if_not_owner( const __owned_list* __owner, + const _Iterator& __it) +{ return __stl_debugger::_Check_if_not_owner(__owner, (const __owned_link&)__it); } + +_STLP_MOVE_TO_STD_NAMESPACE + +_STLP_END_NAMESPACE + +#else +# define _STLP_VERBOSE_ASSERT(expr, diagnostic) +# define _STLP_DEBUG_CHECK(expr) +#endif /* _STLP_DEBUG */ + +#if defined (_STLP_ASSERTIONS) + +# if !defined (_STLP_ASSERT_MSG_TRAILER) +# define _STLP_ASSERT_MSG_TRAILER +# endif + +// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition. +# if !defined (_STLP_DEBUG_MESSAGE) +# define __stl_debug_message __stl_debugger::_Message +# else +extern void __stl_debug_message(const char * format_str, ...); +# endif + +// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition. +# if !defined (_STLP_DEBUG_TERMINATE) +# define __stl_debug_terminate __stl_debugger::_Terminate +# else +extern void __stl_debug_terminate(); +# endif + +#endif + +#if defined (_STLP_ASSERTIONS) && !defined (_STLP_LINK_TIME_INSTANTIATION) +# include <stl/debug/_debug.c> +#endif + +#endif /* DEBUG_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/stl/type_manips.h b/stlport/stlport/stl/type_manips.h new file mode 100644 index 0000000..410b59d --- /dev/null +++ b/stlport/stlport/stl/type_manips.h @@ -0,0 +1,321 @@ +/* + * + * Copyright (c) 2003 + * Francois Dumont + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + +#ifndef _STLP_TYPE_MANIPS_H +#define _STLP_TYPE_MANIPS_H + +_STLP_BEGIN_NAMESPACE + +struct __true_type {}; +struct __false_type {}; + +#if defined (_STLP_USE_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE) +_STLP_MOVE_TO_PRIV_NAMESPACE +using _STLP_STD::__true_type; +using _STLP_STD::__false_type; +_STLP_MOVE_TO_STD_NAMESPACE +#endif + +//bool to type +template <int _Is> +struct __bool2type +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct __bool2type<1> { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct __bool2type<0> { typedef __false_type _Ret; }; + +//type to bool +template <class __bool_type> +struct __type2bool { enum {_Ret = 1}; }; + +_STLP_TEMPLATE_NULL +struct __type2bool<__true_type> { enum {_Ret = 1}; }; + +_STLP_TEMPLATE_NULL +struct __type2bool<__false_type> { enum {_Ret = 0}; }; + +//Negation +template <class _BoolType> +struct _Not { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Not<__false_type> { typedef __true_type _Ret; }; + +// logical and of 2 predicated +template <class _P1, class _P2> +struct _Land2 { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Land2<__true_type, __true_type> { typedef __true_type _Ret; }; + +// logical and of 3 predicated +template <class _P1, class _P2, class _P3> +struct _Land3 { typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Land3<__true_type, __true_type, __true_type> { typedef __true_type _Ret; }; + +//logical or of 2 predicated +template <class _P1, class _P2> +struct _Lor2 { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Lor2<__false_type, __false_type> { typedef __false_type _Ret; }; + +// logical or of 3 predicated +template <class _P1, class _P2, class _P3> +struct _Lor3 { typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL +struct _Lor3<__false_type, __false_type, __false_type> { typedef __false_type _Ret; }; + +//////////////////////////////////////////////////////////////////////////////// +// class template __select +// Selects one of two types based upon a boolean constant +// Invocation: __select<_Cond, T, U>::Result +// where: +// flag is a compile-time boolean constant +// T and U are types +// Result evaluates to T if flag is true, and to U otherwise. +//////////////////////////////////////////////////////////////////////////////// +// BEWARE: If the compiler do not support partial template specialization or nested template +//classes the default behavior of the __select is to consider the condition as false and so return +//the second template type!! + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +# if defined (__BORLANDC__) +template <class _CondT, class _Tp1, class _Tp2> +struct __selectT { typedef _Tp1 _Ret; }; + +template <class _Tp1, class _Tp2> +struct __selectT<__false_type, _Tp1, _Tp2> { typedef _Tp2 _Ret; }; +# endif + +# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) +template <bool _Cond, class _Tp1, class _Tp2> +struct __select { typedef _Tp1 _Ret; }; + +template <class _Tp1, class _Tp2> +struct __select<false, _Tp1, _Tp2> { typedef _Tp2 _Ret; }; +# else +template <bool _Cond, class _Tp1, class _Tp2> +struct __select +{ typedef __selectT<typename __bool2type<_Cond>::_Ret, _Tp1, _Tp2>::_Ret _Ret; }; +# endif + +#else + +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) +template <int _Cond> +struct __select_aux { + template <class _Tp1, class _Tp2> + struct _In { + typedef _Tp1 _Ret; + }; +}; + +_STLP_TEMPLATE_NULL +struct __select_aux<0> { + template <class _Tp1, class _Tp2> + struct _In { + typedef _Tp2 _Ret; + }; +}; + +template <int _Cond, class _Tp1, class _Tp2> +struct __select { + typedef typename __select_aux<_Cond>::_STLP_TEMPLATE _In<_Tp1, _Tp2>::_Ret _Ret; +}; +# else /* _STLP_MEMBER_TEMPLATE_CLASSES */ +//default behavior +template <int _Cond, class _Tp1, class _Tp2> +struct __select { + typedef _Tp2 _Ret; +}; +# endif /* _STLP_MEMBER_TEMPLATE_CLASSES */ + +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +/* Rather than introducing a new macro for the following constrution we use + * an existing one (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) that + * is used for a similar feature. + */ +#if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && \ + (!defined (__GNUC__) || (__GNUC__ > 2)) +// Helper struct that will forbid volatile qualified types: +# if !defined (__BORLANDC__) +struct _NoVolatilePointerShim { _NoVolatilePointerShim(const void*); }; +template <class _Tp> +char _STLP_CALL _IsCopyableFun(bool, _NoVolatilePointerShim, _Tp const*, _Tp*); // no implementation is required +char* _STLP_CALL _IsCopyableFun(bool, ...); // no implementation is required + +template <class _Src, class _Dst> +struct _Copyable { + static _Src* __null_src(); + static _Dst* __null_dst(); + enum { _Ret = (sizeof(_IsCopyableFun(false, __null_src(), __null_src(), __null_dst())) == sizeof(char)) }; + typedef typename __bool2type<_Ret>::_Ret _RetT; +}; +# else +template <class _Tp1, class _Tp2> struct _AreSameTypes; +template <class _Tp> struct _IsUnQual; +template <class _Src, class _Dst> +struct _Copyable { + typedef typename _AreSameTypes<_Src, _Dst>::_Ret _Tr1; + typedef typename _IsUnQual<_Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _RetT; + enum { _Ret = __type2bool<_RetT>::_Ret }; +}; +# endif +#else +template <class _Src, class _Dst> +struct _Copyable { + enum { _Ret = 0 }; + typedef __false_type _RetT; +}; +#endif + +/* + * The following struct will tell you if 2 types are the same and if copying memory + * from the _Src type to the _Dst type is right considering qualifiers. If _Src and + * _Dst types are the same unqualified types _Ret will be false if: + * - any of the type has the volatile qualifier + * - _Dst is const qualified + */ +template <class _Src, class _Dst> +struct _AreCopyable { + enum { _Same = _Copyable<_Src, _Dst>::_Ret }; + typedef typename _Copyable<_Src, _Dst>::_RetT _Ret; +}; + +template <class _Tp1, class _Tp2> +struct _AreSameTypes { + enum { _Same = 0 }; + typedef __false_type _Ret; +}; + +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Tp> +struct _AreSameTypes<_Tp, _Tp> { + enum { _Same = 1 }; + typedef __true_type _Ret; +}; +#endif + +#if !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +template <class _Src, class _Dst> +struct _ConversionHelper { + static char _Test(bool, _Dst); + static char* _Test(bool, ...); + static _Src _MakeSource(); +}; + +template <class _Src, class _Dst> +struct _IsConvertible { + typedef _ConversionHelper<_Src*, const volatile _Dst*> _H; + enum { value = (sizeof(char) == sizeof(_H::_Test(false, _H::_MakeSource()))) }; + typedef typename __bool2type<value>::_Ret _Ret; +}; + +# if defined (__BORLANDC__) +# if (__BORLANDC__ < 0x590) +template<class _Tp> +struct _UnConstPtr { typedef _Tp _Type; }; + +template<class _Tp> +struct _UnConstPtr<_Tp*> { typedef _Tp _Type; }; + +template<class _Tp> +struct _UnConstPtr<const _Tp*> { typedef _Tp _Type; }; +# endif + +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template <class _Tp> +struct _IsConst { typedef __false_type _Ret; }; +# else +template <class _Tp> +struct _IsConst { typedef _AreSameTypes<_Tp, const _Tp>::_Ret _Ret; }; +# endif + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template <class _Tp> +struct _IsConst <const _Tp> { typedef __true_type _Ret; }; +# endif + +# if (__BORLANDC__ < 0x590) +template<class _Tp> +struct _IsConst<_Tp*> { typedef _AreSameTypes<_Tp*, const _Tp*>::_Ret _Ret; }; +# endif +template <class _Tp> +struct _IsVolatile { typedef _AreSameTypes<_Tp, volatile _Tp>::_Ret _Ret; }; + +template<class _Tp> +struct _IsUnQual { + typedef _IsConst<_Tp>::_Ret _Tr1; + typedef _IsVolatile<_Tp>::_Ret _Tr2; + typedef _Not<_Tr1>::_Ret _NotCon; + typedef _Not<_Tr2>::_Ret _NotVol; + typedef _Land2<_NotCon, _NotVol>::_Ret _Ret; +}; + +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +template <class _Tp> struct _UnQual { typedef _Tp _Type; }; +template <class _Tp> struct _UnQual<const _Tp> { typedef _Tp _Type; }; +template <class _Tp> struct _UnQual<volatile _Tp> { typedef _Tp _Type; }; +template <class _Tp> struct _UnQual<const volatile _Tp> { typedef _Tp _Type; }; +# endif +# endif + +/* This struct is intended to say if a pointer can be convertible to an other + * taking into account cv qualifications. It shouldn't be instanciated with + * something else than pointer type as it uses pass by value parameter that + * results in compilation error when parameter type has a special memory + * alignment + */ +template <class _Src, class _Dst> +struct _IsCVConvertible { +# if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x590) + typedef _ConversionHelper<_Src, _Dst> _H; + enum { value = (sizeof(char) == sizeof(_H::_Test(false, _H::_MakeSource()))) }; +# else + enum { _Is1 = __type2bool<_IsConst<_Src>::_Ret>::_Ret }; + enum { _Is2 = _IsConvertible<_UnConstPtr<_Src>::_Type, _UnConstPtr<_Dst>::_Type>::value }; + enum { value = _Is1 ? 0 : _Is2 }; +# endif + typedef typename __bool2type<value>::_Ret _Ret; +}; + +#else +template <class _Src, class _Dst> +struct _IsConvertible { + enum { value = 0 }; + typedef __false_type _Ret; +}; + +template <class _Src, class _Dst> +struct _IsCVConvertible { + enum { value = 0 }; + typedef __false_type _Ret; +}; +#endif + +_STLP_END_NAMESPACE + +#endif /* _STLP_TYPE_MANIPS_H */ diff --git a/stlport/stlport/stl/type_traits.h b/stlport/stlport/stl/type_traits.h new file mode 100755 index 0000000..11bd41d --- /dev/null +++ b/stlport/stlport/stl/type_traits.h @@ -0,0 +1,588 @@ +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1997 + * Moscow Center for SPARC Technology + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + * Copyright (c) 2010, Code Aurora Forum. All rights reserved. + */ + +#ifndef _STLP_TYPE_TRAITS_H +#define _STLP_TYPE_TRAITS_H + +/* +This header file provides a framework for allowing compile time dispatch +based on type attributes. This is useful when writing template code. +For example, when making a copy of an array of an unknown type, it helps +to know if the type has a trivial copy constructor or not, to help decide +if a memcpy can be used. + +The class template __type_traits provides a series of typedefs each of +which is either __true_type or __false_type. The argument to +__type_traits can be any type. The typedefs within this template will +attain their correct values by one of these means: + 1. The general instantiation contain conservative values which work + for all types. + 2. Specializations may be declared to make distinctions between types. + 3. Some compilers (such as the Silicon Graphics N32 and N64 compilers) + will automatically provide the appropriate specializations for all + types. + +EXAMPLE: + +//Copy an array of elements which have non-trivial copy constructors +template <class T> void copy(T* source, T* destination, int n, __false_type); +//Copy an array of elements which have trivial copy constructors. Use memcpy. +template <class T> void copy(T* source, T* destination, int n, __true_type); + +//Copy an array of any type by using the most efficient copy mechanism +template <class T> inline void copy(T* source,T* destination,int n) { + copy(source, destination, n, + typename __type_traits<T>::has_trivial_copy_constructor()); +} +*/ + +#ifdef __WATCOMC__ +# include <stl/_cwchar.h> +#endif + +#ifndef _STLP_TYPE_MANIPS_H +# include <stl/type_manips.h> +#endif + +#ifdef _STLP_USE_BOOST_SUPPORT +# include <stl/boost_type_traits.h> +# include <boost/type_traits/add_reference.hpp> +# include <boost/type_traits/add_const.hpp> +#endif /* _STLP_USE_BOOST_SUPPORT */ + +_STLP_BEGIN_NAMESPACE + +#if !defined (_STLP_USE_BOOST_SUPPORT) + +// The following could be written in terms of numeric_limits. +// We're doing it separately to reduce the number of dependencies. + +template <class _Tp> struct _IsIntegral +{ typedef __false_type _Ret; }; + +# ifndef _STLP_NO_BOOL +_STLP_TEMPLATE_NULL struct _IsIntegral<bool> +{ typedef __true_type _Ret; }; +# endif /* _STLP_NO_BOOL */ + +_STLP_TEMPLATE_NULL struct _IsIntegral<char> +{ typedef __true_type _Ret; }; + +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_TEMPLATE_NULL struct _IsIntegral<signed char> +{ typedef __true_type _Ret; }; +# endif + +_STLP_TEMPLATE_NULL struct _IsIntegral<unsigned char> +{ typedef __true_type _Ret; }; + +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_TEMPLATE_NULL struct _IsIntegral<wchar_t> +{ typedef __true_type _Ret; }; +# endif /* _STLP_HAS_WCHAR_T */ + +_STLP_TEMPLATE_NULL struct _IsIntegral<short> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<unsigned short> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<int> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<unsigned int> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<long> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<unsigned long> +{ typedef __true_type _Ret; }; + +# ifdef _STLP_LONG_LONG +_STLP_TEMPLATE_NULL struct _IsIntegral<_STLP_LONG_LONG> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsIntegral<unsigned _STLP_LONG_LONG> +{ typedef __true_type _Ret; }; +# endif /* _STLP_LONG_LONG */ + +template <class _Tp> struct _IsRational +{ typedef __false_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsRational<float> +{ typedef __true_type _Ret; }; + +_STLP_TEMPLATE_NULL struct _IsRational<double> +{ typedef __true_type _Ret; }; + +# if !defined ( _STLP_NO_LONG_DOUBLE ) +_STLP_TEMPLATE_NULL struct _IsRational<long double> +{ typedef __true_type _Ret; }; +# endif + +// Forward declarations. +template <class _Tp> struct __type_traits; +template <class _IsPOD> struct __type_traits_aux { + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_TEMPLATE_NULL +struct __type_traits_aux<__false_type> { + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +}; + +_STLP_TEMPLATE_NULL +struct __type_traits_aux<__true_type> { + typedef __true_type has_trivial_default_constructor; + typedef __true_type has_trivial_copy_constructor; + typedef __true_type has_trivial_assignment_operator; + typedef __true_type has_trivial_destructor; + typedef __true_type is_POD_type; +}; + +template <class _Tp> +struct _IsRef { + typedef __false_type _Ret; +}; + +# if defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) +#error "_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS not supported" +# else /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ + +template <class _Tp> struct _IsPtr { + typedef __false_type _Ret; +}; + +template <class _Tp> +struct __type_traits { + typedef __true_type this_dummy_member_must_be_first; + /* Do not remove this member. It informs a compiler which + automatically specializes __type_traits that this + __type_traits template is special. It just makes sure that + things work if an implementation is using a template + called __type_traits for something unrelated. */ + + /* The following restrictions should be observed for the sake of + compilers which automatically produce type specific specializations + of this class: + - You may reorder the members below if you wish + - You may remove any of the members below if you wish + - You must not rename members without making the corresponding + name change in the compiler + - Members you add will be treated like regular members unless + + you add the appropriate support in the compiler. */ +# if !defined (_STLP_HAS_TYPE_TRAITS_INTRINSICS) + typedef __false_type has_trivial_default_constructor; + typedef __false_type has_trivial_copy_constructor; + typedef __false_type has_trivial_assignment_operator; + typedef __false_type has_trivial_destructor; + typedef __false_type is_POD_type; +# else + typedef typename __bool2type<_STLP_HAS_TRIVIAL_CONSTRUCTOR(_Tp)>::_Ret has_trivial_default_constructor; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_COPY(_Tp)>::_Ret has_trivial_copy_constructor; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_ASSIGN(_Tp)>::_Ret has_trivial_assignment_operator; + typedef typename __bool2type<_STLP_HAS_TRIVIAL_DESTRUCTOR(_Tp)>::_Ret has_trivial_destructor; + typedef typename __bool2type<_STLP_IS_POD(_Tp)>::_Ret is_POD_type; +# endif +}; + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Tp> struct _IsPtr<_Tp*> +{ typedef __true_type _Ret; }; +template <class _Tp> struct _IsRef<_Tp&> +{ typedef __true_type _Ret; }; + +template <class _Tp> struct __type_traits<_Tp*> : __type_traits_aux<__true_type> +{}; +# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */ + +# endif /* _STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS */ + +// Provide some specializations. This is harmless for compilers that +// have built-in __types_traits support, and essential for compilers +// that don't. +# if !defined (_STLP_QUALIFIED_SPECIALIZATION_BUG) +# define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ +_STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< const Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< volatile Type > : __type_traits_aux<__true_type> {}; \ +_STLP_TEMPLATE_NULL struct __type_traits< const volatile Type > : __type_traits_aux<__true_type> {} +# else +# define _STLP_DEFINE_TYPE_TRAITS_FOR(Type) \ +_STLP_TEMPLATE_NULL struct __type_traits< Type > : __type_traits_aux<__true_type> {}; +# endif + +# ifndef _STLP_NO_BOOL +_STLP_DEFINE_TYPE_TRAITS_FOR(bool); +# endif /* _STLP_NO_BOOL */ +_STLP_DEFINE_TYPE_TRAITS_FOR(char); +# ifndef _STLP_NO_SIGNED_BUILTINS +_STLP_DEFINE_TYPE_TRAITS_FOR(signed char); +# endif +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned char); +# if defined ( _STLP_HAS_WCHAR_T ) && ! defined (_STLP_WCHAR_T_IS_USHORT) +_STLP_DEFINE_TYPE_TRAITS_FOR(wchar_t); +# endif /* _STLP_HAS_WCHAR_T */ + +_STLP_DEFINE_TYPE_TRAITS_FOR(short); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned short); +_STLP_DEFINE_TYPE_TRAITS_FOR(int); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned int); +_STLP_DEFINE_TYPE_TRAITS_FOR(long); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned long); + +# ifdef _STLP_LONG_LONG +_STLP_DEFINE_TYPE_TRAITS_FOR(_STLP_LONG_LONG); +_STLP_DEFINE_TYPE_TRAITS_FOR(unsigned _STLP_LONG_LONG); +# endif /* _STLP_LONG_LONG */ + +_STLP_DEFINE_TYPE_TRAITS_FOR(float); +_STLP_DEFINE_TYPE_TRAITS_FOR(double); + +# if !defined ( _STLP_NO_LONG_DOUBLE ) +_STLP_DEFINE_TYPE_TRAITS_FOR(long double); +# endif + +# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _ArePtrs, class _Src, class _Dst> +struct _IsCVConvertibleIf +{ typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; + +template <class _Src, class _Dst> +struct _IsCVConvertibleIf<__false_type, _Src, _Dst> +{ typedef __false_type _Ret; }; +# else +# if defined (_STLP_MEMBER_TEMPLATE_CLASSES) +template <class _ArePtrs> +struct _IsCVConvertibleIfAux { + template <class _Src, class _Dst> + struct _In + { typedef typename _IsCVConvertible<_Src, _Dst>::_Ret _Ret; }; +}; + +_STLP_TEMPLATE_NULL +struct _IsCVConvertibleIfAux<__false_type> { + template <class _Src, class _Dst> + struct _In + { typedef __false_type _Ret; }; +}; + +template <class _ArePtrs, class _Src, class _Dst> +struct _IsCVConvertibleIf { + typedef typename _IsCVConvertibleIfAux<_ArePtrs>::_STLP_TEMPLATE _In<_Src, _Dst>::_Ret _Ret; +}; +# else +/* default behavior: we prefer to miss an optimization rather than taking the risk of + * a compilation error if playing with types with exotic memory alignment. + */ +template <class _ArePtrs, class _Src, class _Dst> +struct _IsCVConvertibleIf +{ typedef __false_type _Ret; }; +# endif +# endif + +template <class _Src, class _Dst> +struct _TrivialNativeTypeCopy { + typedef typename _IsPtr<_Src>::_Ret _Ptr1; + typedef typename _IsPtr<_Dst>::_Ret _Ptr2; + typedef typename _Land2<_Ptr1, _Ptr2>::_Ret _BothPtrs; + typedef typename _IsCVConvertibleIf<_BothPtrs, _Src, _Dst>::_Ret _Convertible; + typedef typename _Land2<_BothPtrs, _Convertible>::_Ret _Trivial1; + + typedef typename __bool2type<(sizeof(_Src) == sizeof(_Dst))>::_Ret _SameSize; + +#if !defined (__BORLANDC__) || (__BORLANDC__ < 0x564) + typedef typename _IsIntegral<_Src>::_Ret _Int1; +#else + typedef typename _UnQual<_Src>::_Type _UnQuSrc; + typedef typename _IsIntegral<_UnQuSrc>::_Ret _Int1; +#endif + typedef typename _IsIntegral<_Dst>::_Ret _Int2; + typedef typename _Land2<_Int1, _Int2>::_Ret _BothInts; + + typedef typename _IsRational<_Src>::_Ret _Rat1; + typedef typename _IsRational<_Dst>::_Ret _Rat2; + typedef typename _Land2<_Rat1, _Rat2>::_Ret _BothRats; + + typedef typename _Lor2<_BothInts, _BothRats>::_Ret _BothNatives; +#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564) + typedef typename _Land2<_BothNatives, _SameSize>::_Ret _Trivial2; +#else + typedef typename _IsUnQual<_Dst>::_Ret _UnQualDst; + typedef typename _Land3<_BothNatives, _SameSize, _UnQualDst>::_Ret _Trivial2; +#endif + typedef typename _Lor2<_Trivial1, _Trivial2>::_Ret _Ret; +}; + +template <class _Src, class _Dst> +struct _TrivialCopy { + typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Src>::has_trivial_assignment_operator _Tr1; +# else + typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; + typedef typename __type_traits<_UnConstSrc>::has_trivial_assignment_operator _Tr1; +# endif + typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; + typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template <class _Src, class _Dst> +struct _TrivialUCopy { + typedef typename _TrivialNativeTypeCopy<_Src, _Dst>::_Ret _NativeRet; +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Src>::has_trivial_copy_constructor _Tr1; +# else + typedef typename _UnConstPtr<_Src*>::_Type _UnConstSrc; + typedef typename __type_traits<_UnConstSrc>::has_trivial_copy_constructor _Tr1; +# endif + typedef typename _AreCopyable<_Src, _Dst>::_Ret _Tr2; + typedef typename _Land2<_Tr1, _Tr2>::_Ret _UserRet; + typedef typename _Lor2<_NativeRet, _UserRet>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template <class _Tp> +struct _DefaultZeroValue { + typedef typename _IsIntegral<_Tp>::_Ret _Tr1; + typedef typename _IsRational<_Tp>::_Ret _Tr2; + typedef typename _IsPtr<_Tp>::_Ret _Tr3; + typedef typename _Lor3<_Tr1, _Tr2, _Tr3>::_Ret _Ret; +}; + +template <class _Tp> +struct _TrivialInit { +# if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560) + typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Tr1; +# else + typedef typename _UnConstPtr<_Tp*>::_Type _Tp1; + typedef typename __type_traits<_Tp1>::has_trivial_copy_constructor _Tr1; +# endif + typedef typename _DefaultZeroValue<_Tp>::_Ret _Tr2; + typedef typename _Not<_Tr2>::_Ret _Tr3; + typedef typename _Land2<_Tr1, _Tr3>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +#endif /* !_STLP_USE_BOOST_SUPPORT */ + +template <class _Tp> +struct _IsPtrType { + typedef typename _IsPtr<_Tp>::_Ret _Type; + static _Type _Ret() { return _Type(); } +}; + +template <class _Tp> +struct _IsRefType { + typedef typename _IsRef<_Tp>::_Ret _Type; + static _Type _Ret() { return _Type();} +}; + +template <class _Tp> +struct __call_traits { +#if defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) + typedef typename __select< ::boost::is_reference<_Tp>::value, + typename ::boost::add_const<_Tp>::type, + typename ::boost::add_reference< typename ::boost::add_const<_Tp>::type >::type>::_Ret const_param_type; + typedef typename __select< ::boost::is_reference<_Tp>::value, + typename ::boost::remove_const<_Tp>::type, + typename ::boost::add_reference<_Tp>::type>::_Ret param_type; +#else + typedef const _Tp& const_param_type; + typedef _Tp& param_type; +#endif +}; + +#if !defined (_STLP_USE_BOOST_SUPPORT) && !defined (_STLP_NO_EXTENSIONS) && defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) +template <class _Tp> +struct __call_traits<_Tp&> { + typedef _Tp& param_type; + typedef const _Tp& const_param_type; +}; +template <class _Tp> +struct __call_traits<const _Tp&> { + typedef _Tp& param_type; + typedef const _Tp& const_param_type; +}; +#endif + +template <class _Tp1, class _Tp2> +struct _BothPtrType { + typedef typename _IsPtr<_Tp1>::_Ret _IsPtr1; + typedef typename _IsPtr<_Tp2>::_Ret _IsPtr2; + + typedef typename _Land2<_IsPtr1, _IsPtr2>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2> +struct _OKToSwap { + typedef typename _AreSameTypes<_Tp1, _Tp2>::_Ret _Same; + typedef typename _Land3<_Same, _IsRef1, _IsRef2>::_Ret _Type; + static _Type _Answer() { return _Type(); } +}; + +template <class _Tp1, class _Tp2, class _IsRef1, class _IsRef2> +inline _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2> +_IsOKToSwap(_Tp1*, _Tp2*, const _IsRef1&, const _IsRef2&) +{ return _OKToSwap<_Tp1, _Tp2, _IsRef1, _IsRef2>(); } + +template <class _Src, class _Dst> +inline _TrivialCopy<_Src, _Dst> _UseTrivialCopy(_Src*, _Dst*) +{ return _TrivialCopy<_Src, _Dst>(); } + +template <class _Src, class _Dst> +inline _TrivialUCopy<_Src, _Dst> _UseTrivialUCopy(_Src*, _Dst*) +{ return _TrivialUCopy<_Src, _Dst>(); } + +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) || defined (__BORLANDC__) || \ + defined (__DMC__) +struct _NegativeAnswer { + typedef __false_type _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialCopy(_Src*, const _Dst*) +{ return _NegativeAnswer(); } + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialCopy(_Src*, volatile _Dst*) +{ return _NegativeAnswer(); } + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialCopy(_Src*, const volatile _Dst*) +{ return _NegativeAnswer(); } + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialUCopy(_Src*, const _Dst*) +{ return _NegativeAnswer(); } + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialUCopy(_Src*, volatile _Dst*) +{ return _NegativeAnswer(); } + +template <class _Src, class _Dst> +inline _NegativeAnswer _UseTrivialUCopy(_Src*, const volatile _Dst*) +{ return _NegativeAnswer(); } +#endif + +template <class _Tp> +inline _TrivialInit<_Tp> _UseTrivialInit(_Tp*) +{ return _TrivialInit<_Tp>(); } + +template <class _Tp> +struct _IsPOD { + typedef typename __type_traits<_Tp>::is_POD_type _Type; + static _Type _Answer() { return _Type(); } +}; + +template <class _Tp> +inline _IsPOD<_Tp> _Is_POD(_Tp*) +{ return _IsPOD<_Tp>(); } + +template <class _Tp> +struct _DefaultZeroValueQuestion { + typedef typename _DefaultZeroValue<_Tp>::_Ret _Ret; + static _Ret _Answer() { return _Ret(); } +}; + +template <class _Tp> +inline _DefaultZeroValueQuestion<_Tp> _HasDefaultZeroValue(_Tp*) +{ return _DefaultZeroValueQuestion<_Tp>(); } + +/* + * Base class used: + * - to simulate partial template specialization + * - to simulate partial function ordering + * - to recognize STLport class from user specialized one + */ +template <class _Tp> +struct __stlport_class +{ typedef _Tp _Type; }; + +template <class _Tp> +struct _IsSTLportClass { + typedef typename _IsConvertible<_Tp, __stlport_class<_Tp> >::_Ret _Ret; +#if defined (__BORLANDC__) + enum { _Is = _IsConvertible<_Tp, __stlport_class<_Tp> >::value }; +#endif +}; + +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) +template <class _Tp> +struct _SwapImplemented { + typedef typename _IsSTLportClass<_Tp>::_Ret _Ret; +# if defined (__BORLANDC__) + enum { _Is = _IsSTLportClass<_Tp>::_Is }; +# endif +}; +#endif + +template <class _Tp> +class _TpWithState : private _Tp { + _TpWithState(); + int _state; +}; + +/* This is an internal helper struct used to guess if we are working + * on a stateless class. It can only be instanciated with a class type. */ +template <class _Tp> +struct _IsStateless { + enum { _Is = sizeof(_TpWithState<_Tp>) == sizeof(int) }; + typedef typename __bool2type<_Is>::_Ret _Ret; +}; + +_STLP_END_NAMESPACE + +#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION +# if defined (__BORLANDC__) || \ + defined (__SUNPRO_CC) || \ + (defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ + (defined (__sgi) && defined (_COMPILER_VERSION)) || \ + defined (__DMC__) +# define _STLP_IS_POD_ITER(_It, _Tp) __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() +# else +# define _STLP_IS_POD_ITER(_It, _Tp) typename __type_traits< typename iterator_traits< _Tp >::value_type >::is_POD_type() +# endif +#else +# define _STLP_IS_POD_ITER(_It, _Tp) _Is_POD( _STLP_VALUE_TYPE( _It, _Tp ) )._Answer() +#endif + +#endif /* _STLP_TYPE_TRAITS_H */ + +// Local Variables: +// mode:C++ +// End: diff --git a/stlport/stlport/string.h b/stlport/stlport/string.h new file mode 100644 index 0000000..52013cf --- /dev/null +++ b/stlport/stlport/string.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* Workaround for a "misbehaviour" when compiling resource scripts using + * eMbedded Visual C++. The standard .rc file includes windows header files, + * which in turn include string.h, which results in warnings and errors + */ +#ifndef _STLP_STRING_H + +#if !defined (RC_INVOKED) + +# ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x269 +# include <stl/_cprolog.h> +# elif (_STLP_OUTERMOST_HEADER_ID == 0x269) && !defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +# define _STLP_STRING_H +# endif + +# if defined(_STLP_WCE_EVC3) +struct _exception; +# endif +# if (_STLP_OUTERMOST_HEADER_ID != 0x269) || defined (_STLP_DONT_POP_HEADER_ID) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <string.h> +# else +# include _STLP_NATIVE_C_HEADER(string.h) +# endif +# else +# if defined (__BORLANDC__) && !defined (__linux__) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <_str.h> +# else +# include _STLP_NATIVE_CPP_C_HEADER(_str.h) +# endif +# else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <string.h> +# else +# include _STLP_NATIVE_C_HEADER(string.h) +# endif +# endif +# endif + +# if (_STLP_OUTERMOST_HEADER_ID == 0x269) +# if !defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +# endif +#endif /* RC_INVOKED */ +#endif /* _STLP_STRING_H */ diff --git a/stlport/stlport/time.h b/stlport/stlport/time.h new file mode 100644 index 0000000..e73aa85 --- /dev/null +++ b/stlport/stlport/time.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#if !defined (_STLP_OUTERMOST_HEADER_ID) +# define _STLP_OUTERMOST_HEADER_ID 0x272 +# include <stl/_cprolog.h> +#elif (_STLP_OUTERMOST_HEADER_ID == 0x272) && ! defined (_STLP_DONT_POP_HEADER_ID) +# define _STLP_DONT_POP_HEADER_ID +#endif + +#ifdef _STLP_WCE_EVC3 +/* only show message when directly including this file in a non-library build */ +# if !defined(__BUILDING_STLPORT) && (_STLP_OUTERMOST_HEADER_ID == 0x272) +# pragma message("eMbedded Visual C++ 3 doesn't have a time.h header; STLport won't include native time.h here") +# endif +#else +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <time.h> +# else +# include _STLP_NATIVE_C_HEADER(time.h) +# endif +#endif + + +#if (_STLP_OUTERMOST_HEADER_ID == 0x272) +# if ! defined (_STLP_DONT_POP_HEADER_ID) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +# else +# undef _STLP_DONT_POP_HEADER_ID +# endif +#endif diff --git a/stlport/stlport/using/cstring b/stlport/stlport/using/cstring new file mode 100644 index 0000000..42c5660 --- /dev/null +++ b/stlport/stlport/using/cstring @@ -0,0 +1,60 @@ +using _STLP_VENDOR_CSTD::size_t; + +#if !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS) +# if defined (__MSL__) && __MC68K__ && !_No_BlockMove && __dest_os == __mac_os +# undef memcpy +# undef memmove +inline void* memcpy(void* dst, const void* src, size_t len) +{ return _STLP_VENDOR_CSTD::__memcpy(dst, src, len); } +inline void* memmove(void* dst, const void* src, size_t len) +{ return _STLP_VENDOR_CSTD::__memmove(dst, src, len); } +# else +using _STLP_VENDOR_CSTD::memmove; +using _STLP_VENDOR_CSTD::memcpy; +# endif + +# if !defined (_STLP_WCE) +// these functions just don't exist on Windows CE +using _STLP_VENDOR_CSTD::strcoll; +using _STLP_VENDOR_CSTD::strerror; +using _STLP_VENDOR_CSTD::strxfrm; +# endif + +# if defined (__BORLANDC__) +extern "C++" { +# endif +using _STLP_VENDOR_CSTD::memchr; +using _STLP_VENDOR_CSTD::strchr; +using _STLP_VENDOR_CSTD::strpbrk; +using _STLP_VENDOR_CSTD::strrchr; +using _STLP_VENDOR_CSTD::strstr; +# if defined (__BORLANDC__) +} +# endif + +using _STLP_VENDOR_CSTD::memcmp; +using _STLP_VENDOR_CSTD::memset; + +using _STLP_VENDOR_CSTD::strcat; + +# if !defined (strcmp) || !defined (__BORLANDC__) +using _STLP_VENDOR_CSTD::strcmp; +# else +using ::strcmp; +# endif + +# if !defined (strcpy) || !defined (__BORLANDC__) +using _STLP_VENDOR_CSTD::strcpy; +# else +using ::strcpy; +# endif +using _STLP_VENDOR_CSTD::strcspn; +using _STLP_VENDOR_CSTD::strlen; +using _STLP_VENDOR_CSTD::strncat; +using _STLP_VENDOR_CSTD::strncmp; + +using _STLP_VENDOR_CSTD::strncpy; +using _STLP_VENDOR_CSTD::strspn; + +using _STLP_VENDOR_CSTD::strtok; +#endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */ diff --git a/stlport/stlport/vector b/stlport/stlport/vector new file mode 100644 index 0000000..92c41b7 --- /dev/null +++ b/stlport/stlport/vector @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#ifndef _STLP_VECTOR + +#ifndef _STLP_OUTERMOST_HEADER_ID +# define _STLP_OUTERMOST_HEADER_ID 0x77 +# include <stl/_prolog.h> +# define _STLP_VECTOR +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x77) +# ifndef _STLP_INTERNAL_ALGOBASE_H +# include <stl/_algobase.h> +# endif + +# ifndef _STLP_INTERNAL_VECTOR_H +# include <stl/_vector.h> +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID != 0x77) || defined (_STLP_IMPORT_VENDOR_STD) +# if defined (_STLP_HAS_INCLUDE_NEXT) +# include_next <vector> +# else +# include _STLP_NATIVE_HEADER(vector) +# endif +#endif + +#if (_STLP_OUTERMOST_HEADER_ID == 0x77) +# include <stl/_epilog.h> +# undef _STLP_OUTERMOST_HEADER_ID +#endif + +#endif /* _STLP_VECTOR */ + +// Local Variables: +// mode:C++ +// End: + |