diff options
87 files changed, 7843 insertions, 6429 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4fb6895844f..651861d77f2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,96 @@ +2010-11-02 Paolo Carlini <paolo.carlini@oracle.com> + + * include/tr1_impl/cinttypes: Remove, move contents to C++0x + and TR1 headers. + * include/tr1_impl/cstdlib: Likewise. + * include/tr1_impl/cstdio: Likewise. + * include/tr1_impl/cctype: Likewise. + * include/tr1_impl/boost_sp_counted_base.h: Likewise. + * include/tr1_impl/cmath: Likewise. + * include/tr1_impl/cfenv: Likewise. + * include/tr1_impl/utility: Likewise. + * include/tr1_impl/complex: Likewise. + * include/tr1_impl/cwchar: Likewise. + * include/tr1_impl/type_traits: Likewise. + * include/tr1_impl/cstdint: Likewise. + * include/tr1_impl/regex: Likewise. + * include/tr1_impl/array: Likewise. + * include/tr1_impl/cwctype: Likewise. + * include/Makefile.am: Adjust. + * include/Makefile.in: Regenerate. + * src/condition_variable.cc: Adjust; consistently use + _GLIBCXX_BEGIN_NAMESPACE and _GLIBCXX_END_NAMESPACE. + * src/mutex.cc: Likewise. + * src/future.cc: Likewise. + * src/atomic.cc: Likewise. + * src/chrono.cc: Likewise. + * src/thread.cc: Likewise. + * include/std/tuple: Likewise. + * include/std/utility: Likewise. + * include/std/thread: Likewise.: Likewise. + * include/std/type_traits: Likewise. + * include/std/memory: Likewise. + * include/std/future: Likewise. + * include/std/ratio: Likewise. + * include/std/chrono: Likewise. + * include/std/condition_variable: Likewise. + * include/std/mutex: Likewise. + * include/std/functional: Likewise. + * include/std/complex: Likewise. + * include/std/typeindex: Likewise. + * include/std/array: Likewise. + * include/bits/regex_compiler.h: Likewise. + * include/bits/regex_grep_matcher.tcc: Likewise. + * include/bits/regex_grep_matcher.h: Likewise. + * include/bits/regex_constants.h: Likewise. + * include/bits/regex_cursor.h: Likewise. + * include/bits/regex_nfa.tcc: Likewise. + * include/bits/shared_ptr_base.h: Likewise. + * include/bits/regex_nfa.h: Likewise. + * include/bits/random.tcc: Likewise. + * include/bits/regex.h: Likewise. + * include/bits/random.h: Likewise. + * include/bits/regex_error.h: Likewise. + * include/c_global/cinttypes: Likewise. + * include/c_global/cstdlib: Likewise. + * include/c_global/cstdio: Likewise. + * include/c_global/cctype: Likewise. + * include/c_global/cmath: Likewise. + * include/c_global/cfenv: Likewise. + * include/c_global/cwchar: Likewise. + * include/c_global/cstdint: Likewise. + * include/c_global/cwctype: Likewise. + * include/tr1/shared_ptr.h: Likewise. + * include/tr1/cinttypes: Likewise. + * include/tr1/cstdio: Likewise. + * include/tr1/cfenv: Likewise. + * include/tr1/utility: Likewise. + * include/tr1/cwchar: Likewise. + * include/tr1/type_traits: Likewise. + * include/tr1/memory: Likewise. + * include/tr1/cstdint: Likewise. + * include/tr1/regex: Likewise. + * include/tr1/cwctype: Likewise. + * include/tr1/cstdlib: Likewise. + * include/tr1/cctype: Likewise. + * include/tr1/cmath: Likewise. + * include/tr1/complex: Likewise. + * include/tr1/array: Likewise. + * include/c_compatibility/fenv.h: Likewise. + * include/c_compatibility/stdint.h: Likewise. + * include/c_compatibility/inttypes.h: Likewise. + * testsuite/tr1/2_general_utilities/shared_ptr/cons/43820.cc: Adjust + dg-error line numbers. + * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Likewise. + * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise. + * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Likewise. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. + * testsuite/20_util/make_unsigned/requirements/ + typedefs_neg.cc: Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. + * testsuite/20_util/shared_ptr/cons/43820.cc: Likewise. + * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise. + 2010-11-02 Paolo Carlini <paolo.carlini@oracle.com * testsuite/28_regex/05_constants/syntax_option_type.cc: Avoid diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index d1ac203aee7..3fb1876fb47 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -610,26 +610,6 @@ tr1_headers = \ ${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wctype.h - -tr1_impl_srcdir = ${glibcxx_srcdir}/include/tr1_impl -tr1_impl_builddir = ./tr1_impl -tr1_impl_headers = \ - ${tr1_impl_srcdir}/array \ - ${tr1_impl_srcdir}/boost_sp_counted_base.h \ - ${tr1_impl_srcdir}/cctype \ - ${tr1_impl_srcdir}/cfenv \ - ${tr1_impl_srcdir}/cinttypes \ - ${tr1_impl_srcdir}/cmath \ - ${tr1_impl_srcdir}/complex \ - ${tr1_impl_srcdir}/cstdint \ - ${tr1_impl_srcdir}/cstdio \ - ${tr1_impl_srcdir}/cstdlib \ - ${tr1_impl_srcdir}/cwchar \ - ${tr1_impl_srcdir}/cwctype \ - ${tr1_impl_srcdir}/regex \ - ${tr1_impl_srcdir}/type_traits \ - ${tr1_impl_srcdir}/utility - decimal_srcdir = ${glibcxx_srcdir}/include/decimal decimal_builddir = ./decimal decimal_headers = \ @@ -908,9 +888,9 @@ endif # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr1-impl \ - stamp-decimal stamp-debug stamp-parallel stamp-profile \ - stamp-profile-impl stamp-host + stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \ + stamp-debug stamp-parallel stamp-profile stamp-profile-impl \ + stamp-host # List of all files that are created by explicit building, editing, or # catenation. @@ -1019,11 +999,6 @@ stamp-tr1: ${tr1_headers} @-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null @$(STAMP) stamp-tr1 -stamp-tr1-impl: ${tr1_impl_headers} - @-mkdir -p ${tr1_impl_builddir} - @-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null - @$(STAMP) stamp-tr1-impl - stamp-decimal: ${decimal_headers} @-mkdir -p ${decimal_builddir} @-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null @@ -1254,9 +1229,6 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} for file in ${tr1_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir} - for file in ${tr1_impl_headers}; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir} for file in ${decimal_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done @@ -1303,11 +1275,10 @@ clean-local: # developer tries to create them via make in the include build # directory. (This is more of an example of how this kind of rule can # be made.) -.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers) +.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(decimal_headers) $(ext_headers) $(std_headers): ; @: $(c_base_headers): ; @: $(tr1_headers): ; @: -$(tr1_impl_headers): ; @: $(decimal_headers): ; @: $(ext_headers): ; @: diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 778b0c0445a..82cdd922049 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -848,25 +848,6 @@ tr1_headers = \ ${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wctype.h -tr1_impl_srcdir = ${glibcxx_srcdir}/include/tr1_impl -tr1_impl_builddir = ./tr1_impl -tr1_impl_headers = \ - ${tr1_impl_srcdir}/array \ - ${tr1_impl_srcdir}/boost_sp_counted_base.h \ - ${tr1_impl_srcdir}/cctype \ - ${tr1_impl_srcdir}/cfenv \ - ${tr1_impl_srcdir}/cinttypes \ - ${tr1_impl_srcdir}/cmath \ - ${tr1_impl_srcdir}/complex \ - ${tr1_impl_srcdir}/cstdint \ - ${tr1_impl_srcdir}/cstdio \ - ${tr1_impl_srcdir}/cstdlib \ - ${tr1_impl_srcdir}/cwchar \ - ${tr1_impl_srcdir}/cwctype \ - ${tr1_impl_srcdir}/regex \ - ${tr1_impl_srcdir}/type_traits \ - ${tr1_impl_srcdir}/utility - decimal_srcdir = ${glibcxx_srcdir}/include/decimal decimal_builddir = ./decimal decimal_headers = \ @@ -1133,9 +1114,9 @@ PCHFLAGS = -x c++-header -nostdinc++ $(CXXFLAGS) # CLEANFILES and all-local are kept up-to-date. allstamped = \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ - stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr1-impl \ - stamp-decimal stamp-debug stamp-parallel stamp-profile \ - stamp-profile-impl stamp-host + stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \ + stamp-debug stamp-parallel stamp-profile stamp-profile-impl \ + stamp-host # List of all files that are created by explicit building, editing, or @@ -1406,11 +1387,6 @@ stamp-tr1: ${tr1_headers} @-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null @$(STAMP) stamp-tr1 -stamp-tr1-impl: ${tr1_impl_headers} - @-mkdir -p ${tr1_impl_builddir} - @-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null - @$(STAMP) stamp-tr1-impl - stamp-decimal: ${decimal_headers} @-mkdir -p ${decimal_builddir} @-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null @@ -1629,9 +1605,6 @@ install-headers: $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} for file in ${tr1_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done - $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir} - for file in ${tr1_impl_headers}; do \ - $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir} for file in ${decimal_headers}; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done @@ -1675,12 +1648,11 @@ clean-local: # developer tries to create them via make in the include build # directory. (This is more of an example of how this kind of rule can # be made.) -.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers) +.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(decimal_headers) $(ext_headers) $(std_headers): ; @: $(c_base_headers): ; @: $(tr1_headers): ; @: -$(tr1_impl_headers): ; @: $(decimal_headers): ; @: $(ext_headers): ; @: diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 28ced236e27..2fa8e6c35a1 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -33,8 +33,8 @@ #include <vector> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // [26.4] Random number generation /** @@ -5376,6 +5376,6 @@ namespace std /* @} */ // group random_utilities /* @} */ // group random -} +_GLIBCXX_END_NAMESPACE #endif diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index bfc43887b02..323741d25db 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -32,8 +32,8 @@ #include <numeric> // std::accumulate and std::partial_sum -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /* * (Further) implementation-space details. */ @@ -2818,6 +2818,6 @@ namespace std } return __sum / __tmp; } -} +_GLIBCXX_END_NAMESPACE #endif diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 65de5532289..807bf0dda69 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -28,8 +28,7 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @defgroup regex Regular Expressions @@ -2422,6 +2421,5 @@ namespace std #endif //@} // group regex - -} +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h index b15807aa762..90c96ff93ea 100644 --- a/libstdc++-v3/include/bits/regex_compiler.h +++ b/libstdc++-v3/include/bits/regex_compiler.h @@ -28,8 +28,8 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace __regex { struct _Scanner_base @@ -1110,6 +1110,7 @@ namespace __regex __f)._M_nfa())); } } // namespace __regex -} // namespace std + +_GLIBCXX_END_NAMESPACE /* vim: set ts=8 sw=2 sts=2: */ diff --git a/libstdc++-v3/include/bits/regex_constants.h b/libstdc++-v3/include/bits/regex_constants.h index ae462b3234f..15e29532c51 100644 --- a/libstdc++-v3/include/bits/regex_constants.h +++ b/libstdc++-v3/include/bits/regex_constants.h @@ -30,8 +30,7 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) /** * @namespace std::regex_constants @@ -295,5 +294,6 @@ namespace regex_constants //@} } // namespace regex_constants -} // namespace std + +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/regex_cursor.h b/libstdc++-v3/include/bits/regex_cursor.h index e8330fb7885..32ea8c97d85 100644 --- a/libstdc++-v3/include/bits/regex_cursor.h +++ b/libstdc++-v3/include/bits/regex_cursor.h @@ -28,8 +28,8 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace __regex { // ABC for pattern matching @@ -87,6 +87,5 @@ namespace __regex { return _SpecializedCursor<_FwdIterT>(__b, __e); } } // namespace __regex -} // namespace std -/* vim: set ts=8 sw=2 sts=2: */ +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h index 283eabfd9fb..91dd59778fc 100644 --- a/libstdc++-v3/include/bits/regex_error.h +++ b/libstdc++-v3/include/bits/regex_error.h @@ -30,8 +30,7 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) namespace regex_constants { @@ -156,5 +155,4 @@ namespace regex_constants __throw_regex_error(regex_constants::error_type __ecode) { throw regex_error(__ecode); } -} // namespace std - +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.h b/libstdc++-v3/include/bits/regex_grep_matcher.h index 33890e4257c..470e6297f39 100644 --- a/libstdc++-v3/include/bits/regex_grep_matcher.h +++ b/libstdc++-v3/include/bits/regex_grep_matcher.h @@ -28,9 +28,8 @@ * You should not attempt to use it directly. */ +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ template<typename _BiIter> class sub_match; @@ -124,8 +123,7 @@ namespace __regex }; } // namespace __regex -} // namespace std -#include <bits/regex_grep_matcher.tcc> +_GLIBCXX_END_NAMESPACE -/* vim: set ts=8 sw=2 sts=2: */ +#include <bits/regex_grep_matcher.tcc> diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.tcc b/libstdc++-v3/include/bits/regex_grep_matcher.tcc index 6964592ab1d..48e7482b2ed 100644 --- a/libstdc++-v3/include/bits/regex_grep_matcher.tcc +++ b/libstdc++-v3/include/bits/regex_grep_matcher.tcc @@ -25,10 +25,10 @@ /** * @file bits/regex_grep_matcher.tcc */ + #include <regex> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) namespace { @@ -172,6 +172,5 @@ namespace __regex } } // namespace __regex -} // namespace std -/* vim: set ts=8 sw=2 sts=2: */ +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/regex_nfa.h b/libstdc++-v3/include/bits/regex_nfa.h index 2a938915b97..0a412891311 100644 --- a/libstdc++-v3/include/bits/regex_nfa.h +++ b/libstdc++-v3/include/bits/regex_nfa.h @@ -28,8 +28,8 @@ * You should not attempt to use it directly. */ -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace __regex { @@ -397,7 +397,8 @@ namespace __regex }; } // namespace __regex -} // namespace std + +_GLIBCXX_END_NAMESPACE #include <bits/regex_nfa.tcc> diff --git a/libstdc++-v3/include/bits/regex_nfa.tcc b/libstdc++-v3/include/bits/regex_nfa.tcc index 2a1a4d07679..4a5d5ffd120 100644 --- a/libstdc++-v3/include/bits/regex_nfa.tcc +++ b/libstdc++-v3/include/bits/regex_nfa.tcc @@ -27,8 +27,8 @@ */ #include <regex> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace __regex { #ifdef _GLIBCXX_DEBUG @@ -166,5 +166,5 @@ _M_clone() { return 0; } } // namespace __regex -} // namespace std +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index 183c241e29b..4a30ea4da6a 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -51,6 +51,202 @@ _GLIBCXX_BEGIN_NAMESPACE(std) + /** + * @brief Exception possibly thrown by @c shared_ptr. + * @ingroup exceptions + */ + class bad_weak_ptr : public std::exception + { + public: + virtual char const* + what() const throw() + { return "std::bad_weak_ptr"; } + }; + + // Substitute for bad_weak_ptr object in the case of -fno-exceptions. + inline void + __throw_bad_weak_ptr() + { +#if __EXCEPTIONS + throw bad_weak_ptr(); +#else + __builtin_abort(); +#endif + } + + using __gnu_cxx::_Lock_policy; + using __gnu_cxx::__default_lock_policy; + using __gnu_cxx::_S_single; + using __gnu_cxx::_S_mutex; + using __gnu_cxx::_S_atomic; + + // Empty helper class except when the template argument is _S_mutex. + template<_Lock_policy _Lp> + class _Mutex_base + { + protected: + // The atomic policy uses fully-fenced builtins, single doesn't care. + enum { _S_need_barriers = 0 }; + }; + + template<> + class _Mutex_base<_S_mutex> + : public __gnu_cxx::__mutex + { + protected: + // This policy is used when atomic builtins are not available. + // The replacement atomic operations might not have the necessary + // memory barriers. + enum { _S_need_barriers = 1 }; + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class _Sp_counted_base + : public _Mutex_base<_Lp> + { + public: + _Sp_counted_base() + : _M_use_count(1), _M_weak_count(1) { } + + virtual + ~_Sp_counted_base() // nothrow + { } + + // Called when _M_use_count drops to zero, to release the resources + // managed by *this. + virtual void + _M_dispose() = 0; // nothrow + + // Called when _M_weak_count drops to zero. + virtual void + _M_destroy() // nothrow + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) = 0; + + void + _M_add_ref_copy() + { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } + + void + _M_add_ref_lock(); + + void + _M_release() // nothrow + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); + _M_dispose(); + // There must be a memory barrier between dispose() and destroy() + // to ensure that the effects of dispose() are observed in the + // thread that runs destroy(). + // See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html + if (_Mutex_base<_Lp>::_S_need_barriers) + { + _GLIBCXX_READ_MEM_BARRIER; + _GLIBCXX_WRITE_MEM_BARRIER; + } + + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, + -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + _M_destroy(); + } + } + } + + void + _M_weak_add_ref() // nothrow + { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } + + void + _M_weak_release() // nothrow + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + if (_Mutex_base<_Lp>::_S_need_barriers) + { + // See _M_release(), + // destroy() must observe results of dispose() + _GLIBCXX_READ_MEM_BARRIER; + _GLIBCXX_WRITE_MEM_BARRIER; + } + _M_destroy(); + } + } + + long + _M_get_use_count() const // nothrow + { + // No memory barrier is used here so there is no synchronization + // with other threads. + return const_cast<const volatile _Atomic_word&>(_M_use_count); + } + + private: + _Sp_counted_base(_Sp_counted_base const&); + _Sp_counted_base& operator=(_Sp_counted_base const&); + + _Atomic_word _M_use_count; // #shared + _Atomic_word _M_weak_count; // #weak + (#shared != 0) + }; + + template<> + inline void + _Sp_counted_base<_S_single>:: + _M_add_ref_lock() + { + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + __throw_bad_weak_ptr(); + } + } + + template<> + inline void + _Sp_counted_base<_S_mutex>:: + _M_add_ref_lock() + { + __gnu_cxx::__scoped_lock sentry(*this); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + __throw_bad_weak_ptr(); + } + } + + template<> + inline void + _Sp_counted_base<_S_atomic>:: + _M_add_ref_lock() + { + // Perform lock-free add-if-not-zero operation. + _Atomic_word __count; + do + { + __count = _M_use_count; + if (__count == 0) + __throw_bad_weak_ptr(); + + // Replace the current counter value with the old value + 1, as + // long as it's not changed meanwhile. + } + while (!__sync_bool_compare_and_swap(&_M_use_count, __count, + __count + 1)); + } + + // Forward declarations. template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> class __shared_ptr; diff --git a/libstdc++-v3/include/c_compatibility/fenv.h b/libstdc++-v3/include/c_compatibility/fenv.h index 5db6d9d0125..3eb5b207d7a 100644 --- a/libstdc++-v3/include/c_compatibility/fenv.h +++ b/libstdc++-v3/include/c_compatibility/fenv.h @@ -37,22 +37,46 @@ #endif #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cfenv> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cfenv> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif -#endif + +#if _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_FENV_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // _GLIBCXX_FENV_H diff --git a/libstdc++-v3/include/c_compatibility/inttypes.h b/libstdc++-v3/include/c_compatibility/inttypes.h index 31fd43169ef..2273dfe652e 100644 --- a/libstdc++-v3/include/c_compatibility/inttypes.h +++ b/libstdc++-v3/include/c_compatibility/inttypes.h @@ -48,22 +48,38 @@ # endif # endif -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cinttypes> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cinttypes> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif +#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + + // May collide with _Longlong abs(_Longlong), and is not described + // anywhere outside the synopsis. Likely, a defect. + // + // intmax_t abs(intmax_t) + + using ::imaxdiv; + + // Likewise, with lldiv_t div(_Longlong, _Longlong). + // + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + using ::wcstoimax; + using ::wcstoumax; +#endif + +_GLIBCXX_END_NAMESPACE + +#endif _GLIBCXX_USE_C99_INTTYPES_TR1 #else diff --git a/libstdc++-v3/include/c_compatibility/stdint.h b/libstdc++-v3/include/c_compatibility/stdint.h index 78a66d0d1b6..9f3a65bbe46 100644 --- a/libstdc++-v3/include/c_compatibility/stdint.h +++ b/libstdc++-v3/include/c_compatibility/stdint.h @@ -56,22 +56,49 @@ # endif # endif -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cstdint> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cstdint> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_STDINT_TR1 #else diff --git a/libstdc++-v3/include/c_global/cctype b/libstdc++-v3/include/c_global/cctype index 1dfe1720c4f..cab2a5089f6 100644 --- a/libstdc++-v3/include/c_global/cctype +++ b/libstdc++-v3/include/c_global/cctype @@ -80,22 +80,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cctype> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cctype> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif -#endif + +#ifdef _GLIBCXX_USE_C99_CTYPE_TR1 + +#undef isblank + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using ::isblank; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_CTYPE_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv index 4e401411767..9686e8d35ec 100644 --- a/libstdc++-v3/include/c_global/cfenv +++ b/libstdc++-v3/include/c_global/cfenv @@ -33,29 +33,53 @@ #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <bits/c++0x_warning.h> -#endif - -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -#endif +#else #include <bits/c++config.h> + #if _GLIBCXX_HAVE_FENV_H # include <fenv.h> #endif -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cfenv> -#else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cfenv> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -#endif +#ifdef _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_FENV_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // _GLIBCXX_CFENV diff --git a/libstdc++-v3/include/c_global/cinttypes b/libstdc++-v3/include/c_global/cinttypes index d8de5ee5c92..0017e75d509 100644 --- a/libstdc++-v3/include/c_global/cinttypes +++ b/libstdc++-v3/include/c_global/cinttypes @@ -33,11 +33,7 @@ #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <bits/c++0x_warning.h> -#endif - -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -#endif +#else #include <cstdint> @@ -54,18 +50,39 @@ # endif #endif -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cinttypes> -#else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cinttypes> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X +#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + + // May collide with _Longlong abs(_Longlong), and is not described + // anywhere outside the synopsis. Likely, a defect. + // + // intmax_t abs(intmax_t) + + using ::imaxdiv; + + // Likewise, with lldiv_t div(_Longlong, _Longlong). + // + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + using ::wcstoimax; + using ::wcstoumax; #endif +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_INTTYPES_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #endif // _GLIBCXX_CINTTYPES diff --git a/libstdc++-v3/include/c_global/cmath b/libstdc++-v3/include/c_global/cmath index 3469b3884e8..b1b6e2d29e2 100644 --- a/libstdc++-v3/include/c_global/cmath +++ b/libstdc++-v3/include/c_global/cmath @@ -846,22 +846,928 @@ _GLIBCXX_END_NAMESPACE #endif #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cmath> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cmath> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif + +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +#undef acosh +#undef acoshf +#undef acoshl +#undef asinh +#undef asinhf +#undef asinhl +#undef atanh +#undef atanhf +#undef atanhl +#undef cbrt +#undef cbrtf +#undef cbrtl +#undef copysign +#undef copysignf +#undef copysignl +#undef erf +#undef erff +#undef erfl +#undef erfc +#undef erfcf +#undef erfcl +#undef exp2 +#undef exp2f +#undef exp2l +#undef expm1 +#undef expm1f +#undef expm1l +#undef fdim +#undef fdimf +#undef fdiml +#undef fma +#undef fmaf +#undef fmal +#undef fmax +#undef fmaxf +#undef fmaxl +#undef fmin +#undef fminf +#undef fminl +#undef hypot +#undef hypotf +#undef hypotl +#undef ilogb +#undef ilogbf +#undef ilogbl +#undef lgamma +#undef lgammaf +#undef lgammal +#undef llrint +#undef llrintf +#undef llrintl +#undef llround +#undef llroundf +#undef llroundl +#undef log1p +#undef log1pf +#undef log1pl +#undef log2 +#undef log2f +#undef log2l +#undef logb +#undef logbf +#undef logbl +#undef lrint +#undef lrintf +#undef lrintl +#undef lround +#undef lroundf +#undef lroundl +#undef nan +#undef nanf +#undef nanl +#undef nearbyint +#undef nearbyintf +#undef nearbyintl +#undef nextafter +#undef nextafterf +#undef nextafterl +#undef nexttoward +#undef nexttowardf +#undef nexttowardl +#undef remainder +#undef remainderf +#undef remainderl +#undef remquo +#undef remquof +#undef remquol +#undef rint +#undef rintf +#undef rintl +#undef round +#undef roundf +#undef roundl +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef scalbn +#undef scalbnf +#undef scalbnl +#undef tgamma +#undef tgammaf +#undef tgammal +#undef trunc +#undef truncf +#undef truncl + +_GLIBCXX_BEGIN_NAMESPACE(std) + + // types + using ::double_t; + using ::float_t; + + // functions + using ::acosh; + using ::acoshf; + using ::acoshl; + + using ::asinh; + using ::asinhf; + using ::asinhl; + + using ::atanh; + using ::atanhf; + using ::atanhl; + + using ::cbrt; + using ::cbrtf; + using ::cbrtl; + + using ::copysign; + using ::copysignf; + using ::copysignl; + + using ::erf; + using ::erff; + using ::erfl; + + using ::erfc; + using ::erfcf; + using ::erfcl; + + using ::exp2; + using ::exp2f; + using ::exp2l; + + using ::expm1; + using ::expm1f; + using ::expm1l; + + using ::fdim; + using ::fdimf; + using ::fdiml; + + using ::fma; + using ::fmaf; + using ::fmal; + + using ::fmax; + using ::fmaxf; + using ::fmaxl; + + using ::fmin; + using ::fminf; + using ::fminl; + + using ::hypot; + using ::hypotf; + using ::hypotl; + + using ::ilogb; + using ::ilogbf; + using ::ilogbl; + + using ::lgamma; + using ::lgammaf; + using ::lgammal; + + using ::llrint; + using ::llrintf; + using ::llrintl; + + using ::llround; + using ::llroundf; + using ::llroundl; + + using ::log1p; + using ::log1pf; + using ::log1pl; + + using ::log2; + using ::log2f; + using ::log2l; + + using ::logb; + using ::logbf; + using ::logbl; + + using ::lrint; + using ::lrintf; + using ::lrintl; + + using ::lround; + using ::lroundf; + using ::lroundl; + + using ::nan; + using ::nanf; + using ::nanl; + + using ::nearbyint; + using ::nearbyintf; + using ::nearbyintl; + + using ::nextafter; + using ::nextafterf; + using ::nextafterl; + + using ::nexttoward; + using ::nexttowardf; + using ::nexttowardl; + + using ::remainder; + using ::remainderf; + using ::remainderl; + + using ::remquo; + using ::remquof; + using ::remquol; + + using ::rint; + using ::rintf; + using ::rintl; + + using ::round; + using ::roundf; + using ::roundl; + + using ::scalbln; + using ::scalblnf; + using ::scalblnl; + + using ::scalbn; + using ::scalbnf; + using ::scalbnl; + + using ::tgamma; + using ::tgammaf; + using ::tgammal; + + using ::trunc; + using ::truncf; + using ::truncl; + +#if _GLIBCXX_USE_C99_MATH +#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + + /// Function template definitions [8.16.3]. + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + fpclassify(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isfinite(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isfinite(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isinf(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isinf(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnan(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnan(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnormal(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnormal(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + signbit(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_signbit(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreater(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreaterequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreaterequal(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isless(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isless(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessequal(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessgreater(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isunordered(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isunordered(__type(__f1), __type(__f2)); + } + +#endif #endif + /// Additional overloads [8.16.4]. + inline float + acosh(float __x) + { return __builtin_acoshf(__x); } + + inline long double + acosh(long double __x) + { return __builtin_acoshl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + acosh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return acosh(__type(__x)); + } + + inline float + asinh(float __x) + { return __builtin_asinhf(__x); } + + inline long double + asinh(long double __x) + { return __builtin_asinhl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + asinh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return asinh(__type(__x)); + } + + inline float + atanh(float __x) + { return __builtin_atanhf(__x); } + + inline long double + atanh(long double __x) + { return __builtin_atanhl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + atanh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return atanh(__type(__x)); + } + + inline float + cbrt(float __x) + { return __builtin_cbrtf(__x); } + + inline long double + cbrt(long double __x) + { return __builtin_cbrtl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + cbrt(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return cbrt(__type(__x)); + } + + inline float + copysign(float __x, float __y) + { return __builtin_copysignf(__x, __y); } + + inline long double + copysign(long double __x, long double __y) + { return __builtin_copysignl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + copysign(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return copysign(__type(__x), __type(__y)); + } + + inline float + erf(float __x) + { return __builtin_erff(__x); } + + inline long double + erf(long double __x) + { return __builtin_erfl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + erf(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erf(__type(__x)); + } + + inline float + erfc(float __x) + { return __builtin_erfcf(__x); } + + inline long double + erfc(long double __x) + { return __builtin_erfcl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + erfc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erfc(__type(__x)); + } + + inline float + exp2(float __x) + { return __builtin_exp2f(__x); } + + inline long double + exp2(long double __x) + { return __builtin_exp2l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + exp2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return exp2(__type(__x)); + } + + inline float + expm1(float __x) + { return __builtin_expm1f(__x); } + + inline long double + expm1(long double __x) + { return __builtin_expm1l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + expm1(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return expm1(__type(__x)); + } + + inline float + fdim(float __x, float __y) + { return __builtin_fdimf(__x, __y); } + + inline long double + fdim(long double __x, long double __y) + { return __builtin_fdiml(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fdim(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fdim(__type(__x), __type(__y)); + } + + inline float + fma(float __x, float __y, float __z) + { return __builtin_fmaf(__x, __y, __z); } + + inline long double + fma(long double __x, long double __y, long double __z) + { return __builtin_fmal(__x, __y, __z); } + + template<typename _Tp, typename _Up, typename _Vp> + inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + fma(_Tp __x, _Up __y, _Vp __z) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; + return fma(__type(__x), __type(__y), __type(__z)); + } + + inline float + fmax(float __x, float __y) + { return __builtin_fmaxf(__x, __y); } + + inline long double + fmax(long double __x, long double __y) + { return __builtin_fmaxl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmax(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmax(__type(__x), __type(__y)); + } + + inline float + fmin(float __x, float __y) + { return __builtin_fminf(__x, __y); } + + inline long double + fmin(long double __x, long double __y) + { return __builtin_fminl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmin(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmin(__type(__x), __type(__y)); + } + + inline float + hypot(float __x, float __y) + { return __builtin_hypotf(__x, __y); } + + inline long double + hypot(long double __x, long double __y) + { return __builtin_hypotl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + hypot(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return hypot(__type(__x), __type(__y)); + } + + inline int + ilogb(float __x) + { return __builtin_ilogbf(__x); } + + inline int + ilogb(long double __x) + { return __builtin_ilogbl(__x); } + + template<typename _Tp> + inline int + ilogb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return ilogb(__type(__x)); + } + + inline float + lgamma(float __x) + { return __builtin_lgammaf(__x); } + + inline long double + lgamma(long double __x) + { return __builtin_lgammal(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + lgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lgamma(__type(__x)); + } + + inline long long + llrint(float __x) + { return __builtin_llrintf(__x); } + + inline long long + llrint(long double __x) + { return __builtin_llrintl(__x); } + + template<typename _Tp> + inline long long + llrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llrint(__type(__x)); + } + + inline long long + llround(float __x) + { return __builtin_llroundf(__x); } + + inline long long + llround(long double __x) + { return __builtin_llroundl(__x); } + + template<typename _Tp> + inline long long + llround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llround(__type(__x)); + } + + inline float + log1p(float __x) + { return __builtin_log1pf(__x); } + + inline long double + log1p(long double __x) + { return __builtin_log1pl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + log1p(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log1p(__type(__x)); + } + + // DR 568. + inline float + log2(float __x) + { return __builtin_log2f(__x); } + + inline long double + log2(long double __x) + { return __builtin_log2l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + log2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log2(__type(__x)); + } + + inline float + logb(float __x) + { return __builtin_logbf(__x); } + + inline long double + logb(long double __x) + { return __builtin_logbl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + logb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return logb(__type(__x)); + } + + inline long + lrint(float __x) + { return __builtin_lrintf(__x); } + + inline long + lrint(long double __x) + { return __builtin_lrintl(__x); } + + template<typename _Tp> + inline long + lrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lrint(__type(__x)); + } + + inline long + lround(float __x) + { return __builtin_lroundf(__x); } + + inline long + lround(long double __x) + { return __builtin_lroundl(__x); } + + template<typename _Tp> + inline long + lround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lround(__type(__x)); + } + + inline float + nearbyint(float __x) + { return __builtin_nearbyintf(__x); } + + inline long double + nearbyint(long double __x) + { return __builtin_nearbyintl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + nearbyint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nearbyint(__type(__x)); + } + + inline float + nextafter(float __x, float __y) + { return __builtin_nextafterf(__x, __y); } + + inline long double + nextafter(long double __x, long double __y) + { return __builtin_nextafterl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + nextafter(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return nextafter(__type(__x), __type(__y)); + } + + inline float + nexttoward(float __x, long double __y) + { return __builtin_nexttowardf(__x, __y); } + + inline long double + nexttoward(long double __x, long double __y) + { return __builtin_nexttowardl(__x, __y); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + nexttoward(_Tp __x, long double __y) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nexttoward(__type(__x), __y); + } + + inline float + remainder(float __x, float __y) + { return __builtin_remainderf(__x, __y); } + + inline long double + remainder(long double __x, long double __y) + { return __builtin_remainderl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remainder(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remainder(__type(__x), __type(__y)); + } + + inline float + remquo(float __x, float __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + inline long double + remquo(long double __x, long double __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remquo(_Tp __x, _Up __y, int* __pquo) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remquo(__type(__x), __type(__y), __pquo); + } + + inline float + rint(float __x) + { return __builtin_rintf(__x); } + + inline long double + rint(long double __x) + { return __builtin_rintl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + rint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return rint(__type(__x)); + } + + inline float + round(float __x) + { return __builtin_roundf(__x); } + + inline long double + round(long double __x) + { return __builtin_roundl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + round(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return round(__type(__x)); + } + + inline float + scalbln(float __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + inline long double + scalbln(long double __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbln(_Tp __x, long __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbln(__type(__x), __ex); + } + + inline float + scalbn(float __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + inline long double + scalbn(long double __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbn(_Tp __x, int __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbn(__type(__x), __ex); + } + + inline float + tgamma(float __x) + { return __builtin_tgammaf(__x); } + + inline long double + tgamma(long double __x) + { return __builtin_tgammal(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + tgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return tgamma(__type(__x)); + } + + inline float + trunc(float __x) + { return __builtin_truncf(__x); } + + inline long double + trunc(long double __x) + { return __builtin_truncl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + trunc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return trunc(__type(__x)); + } + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_MATH_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #endif diff --git a/libstdc++-v3/include/c_global/cstdint b/libstdc++-v3/include/c_global/cstdint index 28e449cff81..45aa7fa84f0 100644 --- a/libstdc++-v3/include/c_global/cstdint +++ b/libstdc++-v3/include/c_global/cstdint @@ -33,11 +33,7 @@ #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <bits/c++0x_warning.h> -#endif - -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -#endif +#else #include <bits/c++config.h> @@ -62,18 +58,50 @@ # endif #endif -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cstdint> -#else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cstdint> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -#endif +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +_GLIBCXX_BEGIN_NAMESPACE(std) + + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_C99_STDINT_TR1 + +#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // _GLIBCXX_CSTDINT diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio index 9124229248b..c7eb129cc5f 100644 --- a/libstdc++-v3/include/c_global/cstdio +++ b/libstdc++-v3/include/c_global/cstdio @@ -185,23 +185,4 @@ _GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_USE_C99 -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cstdio> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cstdio> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif -#endif - #endif diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib index 943f26328f0..31fad41bdd6 100644 --- a/libstdc++-v3/include/c_global/cstdlib +++ b/libstdc++-v3/include/c_global/cstdlib @@ -215,27 +215,38 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE -#endif // _GLIBCXX_USE_C99 - #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cstdlib> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cstdlib> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif + +_GLIBCXX_BEGIN_NAMESPACE(std) + +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + // types + using std::lldiv_t; + + // functions + using std::llabs; + using std::lldiv; #endif + using std::atoll; + using std::strtoll; + using std::strtoull; + + using std::strtof; + using std::strtold; + + // overloads + using std::abs; +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using std::div; +#endif + +_GLIBCXX_END_NAMESPACE + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_USE_C99 + #endif // !_GLIBCXX_HOSTED #endif diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar index c2bbde09c51..bbfcb64cb44 100644 --- a/libstdc++-v3/include/c_global/cwchar +++ b/libstdc++-v3/include/c_global/cwchar @@ -273,22 +273,34 @@ _GLIBCXX_END_NAMESPACE #endif //_GLIBCXX_USE_WCHAR_T #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cwchar> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cwchar> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif + +#ifdef _GLIBCXX_USE_WCHAR_T + +_GLIBCXX_BEGIN_NAMESPACE(std) + +#if _GLIBCXX_HAVE_WCSTOF + using std::wcstof; +#endif +#if _GLIBCXX_HAVE_VFWSCANF + using std::vfwscanf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using std::vswscanf; #endif +#if _GLIBCXX_HAVE_VWSCANF + using std::vwscanf; +#endif + +#if _GLIBCXX_USE_C99 + using std::wcstold; + using std::wcstoll; + using std::wcstoull; +#endif + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_WCHAR_T + +#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif diff --git a/libstdc++-v3/include/c_global/cwctype b/libstdc++-v3/include/c_global/cwctype index 2ac1155aa9b..ff196434c82 100644 --- a/libstdc++-v3/include/c_global/cwctype +++ b/libstdc++-v3/include/c_global/cwctype @@ -111,22 +111,19 @@ _GLIBCXX_END_NAMESPACE #endif //_GLIBCXX_USE_WCHAR_T #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/cwctype> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/cwctype> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif -#endif -#endif +#ifdef _GLIBCXX_USE_WCHAR_T + +_GLIBCXX_BEGIN_NAMESPACE(std) + +#if _GLIBCXX_HAVE_ISWBLANK + using std::iswblank; +#endif + +_GLIBCXX_END_NAMESPACE + +#endif // _GLIBCXX_USE_WCHAR_T + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + +#endif // _GLIBCXX_CWCTYPE diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 26e762de339..3cad7e8f5ad 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -35,26 +35,236 @@ # include <bits/c++0x_warning.h> #else -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -#endif - #include <bits/stl_algobase.h> #include <bits/range_access.h> -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/array> -#else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/array> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -#endif +_GLIBCXX_BEGIN_NAMESPACE(std) + + /** + * @brief A standard container for storing a fixed size sequence of elements. + * + * @ingroup sequences + * + * Meets the requirements of a <a href="tables.html#65">container</a>, a + * <a href="tables.html#66">reversible container</a>, and a + * <a href="tables.html#67">sequence</a>. + * + * Sets support random access iterators. + * + * @param Tp Type of element. Required to be a complete type. + * @param N Number of elements. + */ + template<typename _Tp, std::size_t _Nm> + struct array + { + typedef _Tp value_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + + // Support for zero-sized arrays mandatory. + value_type _M_instance[_Nm ? _Nm : 1]; + + // No explicit construct/copy/destroy for aggregate type. + + // DR 776. + void + fill(const value_type& __u) + { std::fill_n(begin(), size(), __u); } + + void + swap(array& __other) + { std::swap_ranges(begin(), end(), __other.begin()); } + + // Iterators. + iterator + begin() + { return iterator(std::__addressof(_M_instance[0])); } + + const_iterator + begin() const + { return const_iterator(std::__addressof(_M_instance[0])); } + + iterator + end() + { return iterator(std::__addressof(_M_instance[_Nm])); } + + const_iterator + end() const + { return const_iterator(std::__addressof(_M_instance[_Nm])); } + + 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()); } + + const_iterator + cbegin() const + { return const_iterator(std::__addressof(_M_instance[0])); } + + const_iterator + cend() const + { return const_iterator(std::__addressof(_M_instance[_Nm])); } + + const_reverse_iterator + crbegin() const + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const + { return const_reverse_iterator(begin()); } + + // Capacity. + constexpr size_type + size() const { return _Nm; } + + constexpr size_type + max_size() const { return _Nm; } + + constexpr bool + empty() const { return size() == 0; } + + // Element access. + reference + operator[](size_type __n) + { return _M_instance[__n]; } + + const_reference + operator[](size_type __n) const + { return _M_instance[__n]; } + + reference + at(size_type __n) + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + const_reference + at(size_type __n) const + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + reference + front() + { return *begin(); } + + const_reference + front() const + { return *begin(); } + + reference + back() + { return _Nm ? *(end() - 1) : *end(); } + + const_reference + back() const + { return _Nm ? *(end() - 1) : *end(); } + + _Tp* + data() + { return std::__addressof(_M_instance[0]); } + + const _Tp* + data() const + { return std::__addressof(_M_instance[0]); } + }; + + // Array comparisons. + template<typename _Tp, std::size_t _Nm> + inline bool + operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return std::equal(__one.begin(), __one.end(), __two.begin()); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + return std::lexicographical_compare(__a.begin(), __a.end(), + __b.begin(), __b.end()); + } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one < __two); } + + // Specialized algorithms [6.2.2.2]. + template<typename _Tp, std::size_t _Nm> + inline void + swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) + { __one.swap(__two); } + + // Tuple interface to class template array [6.2.2.5]. + + /// tuple_size + template<typename _Tp> + class tuple_size; + + /// tuple_element + template<std::size_t _Int, typename _Tp> + class tuple_element; + + template<typename _Tp, std::size_t _Nm> + struct tuple_size<array<_Tp, _Nm> > + { static const std::size_t value = _Nm; }; + + template<typename _Tp, std::size_t _Nm> + const std::size_t + tuple_size<array<_Tp, _Nm> >::value; + + template<std::size_t _Int, typename _Tp, std::size_t _Nm> + struct tuple_element<_Int, array<_Tp, _Nm> > + { typedef _Tp type; }; + + template<std::size_t _Int, typename _Tp, std::size_t _Nm> + inline _Tp& + get(array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } + + template<std::size_t _Int, typename _Tp, std::size_t _Nm> + inline const _Tp& + get(const array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } + +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 1d9552a9914..6361fdac95b 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -35,10 +35,6 @@ # include <bits/c++0x_warning.h> #else -#ifdef _GLIBCXX_INCLUDE_AS_TR1 -# error C++0x header cannot be included from TR1 header -#endif - #include <ratio> #include <type_traits> #include <limits> @@ -46,8 +42,8 @@ #ifdef _GLIBCXX_USE_C99_STDINT_TR1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup chrono Time * @ingroup utilities @@ -689,7 +685,7 @@ namespace std } // namespace chrono // @} group chrono -} // namespace std +_GLIBCXX_END_NAMESPACE #endif //_GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index 6f0fe44eefc..46a198c7e92 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1523,26 +1523,324 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_END_NAMESPACE #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/complex> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/complex> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif _GLIBCXX_BEGIN_NAMESPACE(std) // Forward declarations. + template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&); + + template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&); + // DR 595. + template<typename _Tp> _Tp fabs(const std::complex<_Tp>&); + + template<typename _Tp> + inline std::complex<_Tp> + __complex_acos(const std::complex<_Tp>& __z) + { + const std::complex<_Tp> __t = std::asin(__z); + const _Tp __pi_2 = 1.5707963267948966192313216916397514L; + return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acos(__complex__ float __z) + { return __builtin_cacosf(__z); } + + inline __complex__ double + __complex_acos(__complex__ double __z) + { return __builtin_cacos(__z); } + + inline __complex__ long double + __complex_acos(const __complex__ long double& __z) + { return __builtin_cacosl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z.__rep()); } +#else + /// acos(__z) [8.1.2]. + // Effects: Behaves the same as C99 function cacos, defined + // in subclause 7.3.5.1. + template<typename _Tp> + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z); } +#endif + + template<typename _Tp> + inline std::complex<_Tp> + __complex_asin(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t(-__z.imag(), __z.real()); + __t = std::asinh(__t); + return std::complex<_Tp>(__t.imag(), -__t.real()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asin(__complex__ float __z) + { return __builtin_casinf(__z); } + + inline __complex__ double + __complex_asin(__complex__ double __z) + { return __builtin_casin(__z); } + + inline __complex__ long double + __complex_asin(const __complex__ long double& __z) + { return __builtin_casinl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z.__rep()); } +#else + /// asin(__z) [8.1.3]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.5.2. + template<typename _Tp> + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_atan(const std::complex<_Tp>& __z) + { + const _Tp __r2 = __z.real() * __z.real(); + const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag(); + + _Tp __num = __z.imag() + _Tp(1.0); + _Tp __den = __z.imag() - _Tp(1.0); + + __num = __r2 + __num * __num; + __den = __r2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x), + _Tp(0.25) * log(__num / __den)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atan(__complex__ float __z) + { return __builtin_catanf(__z); } + + inline __complex__ double + __complex_atan(__complex__ double __z) + { return __builtin_catan(__z); } + + inline __complex__ long double + __complex_atan(const __complex__ long double& __z) + { return __builtin_catanl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z.__rep()); } +#else + /// atan(__z) [8.1.4]. + // Effects: Behaves the same as C99 function catan, defined + // in subclause 7.3.5.3. + template<typename _Tp> + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_acosh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) - _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acosh(__complex__ float __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ double + __complex_acosh(__complex__ double __z) + { return __builtin_cacosh(__z); } + + inline __complex__ long double + __complex_acosh(const __complex__ long double& __z) + { return __builtin_cacoshl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z.__rep()); } +#else + /// acosh(__z) [8.1.5]. + // Effects: Behaves the same as C99 function cacosh, defined + // in subclause 7.3.6.1. + template<typename _Tp> + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_asinh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) + _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asinh(__complex__ float __z) + { return __builtin_casinhf(__z); } + + inline __complex__ double + __complex_asinh(__complex__ double __z) + { return __builtin_casinh(__z); } + + inline __complex__ long double + __complex_asinh(const __complex__ long double& __z) + { return __builtin_casinhl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z.__rep()); } +#else + /// asinh(__z) [8.1.6]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.6.2. + template<typename _Tp> + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_atanh(const std::complex<_Tp>& __z) + { + const _Tp __i2 = __z.imag() * __z.imag(); + const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real(); + + _Tp __num = _Tp(1.0) + __z.real(); + _Tp __den = _Tp(1.0) - __z.real(); + + __num = __i2 + __num * __num; + __den = __i2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)), + _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atanh(__complex__ float __z) + { return __builtin_catanhf(__z); } + + inline __complex__ double + __complex_atanh(__complex__ double __z) + { return __builtin_catanh(__z); } + + inline __complex__ long double + __complex_atanh(const __complex__ long double& __z) + { return __builtin_catanhl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z.__rep()); } +#else + /// atanh(__z) [8.1.7]. + // Effects: Behaves the same as C99 function catanh, defined + // in subclause 7.3.6.3. + template<typename _Tp> + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z); } +#endif + + template<typename _Tp> + inline _Tp + /// fabs(__z) [8.1.8]. + // Effects: Behaves the same as C99 function cabs, defined + // in subclause 7.3.8.1. + fabs(const std::complex<_Tp>& __z) + { return std::abs(__z); } + + /// Additional overloads [8.1.9]. + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + arg(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; +#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) + return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L) + : __type(); +#else + return std::arg(std::complex<__type>(__x)); +#endif + } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + imag(_Tp) + { return _Tp(); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + norm(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __type(__x) * __type(__x); + } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + real(_Tp __x) + { return __x; } + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const std::complex<_Tp>& __x, const _Up& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), __type(__y)); + } + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const _Tp& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), std::complex<__type>(__y)); + } + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), + std::complex<__type>(__y)); + } + + // Forward declarations. // DR 781. template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&); @@ -1594,6 +1892,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_END_NAMESPACE -#endif +#endif // __GXX_EXPERIMENTAL_CXX0X__ -#endif /* _GLIBCXX_COMPLEX */ +#endif /* _GLIBCXX_COMPLEX */ diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index c5ce207a905..71d2133a6e8 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -40,8 +40,8 @@ #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup condition_variables Condition Variables * @ingroup concurrency @@ -254,7 +254,7 @@ namespace std }; // @} group condition_variables -} +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index cf178e336e7..0c37ccc0e9f 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -58,8 +58,8 @@ #include <bits/functexcept.h> #include <bits/functional_hash.h> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + _GLIBCXX_HAS_NESTED_TYPE(result_type) /// If we have found a result_type, extract it. @@ -2244,7 +2244,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) inline void swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) { __x.swap(__y); } -} + +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index aff0a33db30..0c367955914 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -45,8 +45,8 @@ #include <atomic> #include <bits/functexcept.h> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup futures Futures * @ingroup concurrency @@ -1364,7 +1364,7 @@ namespace std // && _GLIBCXX_ATOMIC_BUILTINS_4 // @} group futures -} +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index 42e948a30d0..bfc038de326 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -69,9 +69,6 @@ #include <bits/stl_raw_storage_iter.h> #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif # include <exception> // std::exception # include <typeinfo> // std::type_info in get_deleter # include <iosfwd> // std::basic_ostream @@ -86,19 +83,6 @@ # include <backward/auto_ptr.h> # endif # include <bits/unique_ptr.h> -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/boost_sp_counted_base.h> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/boost_sp_counted_base.h> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif # include <bits/shared_ptr.h> #else # include <backward/auto_ptr.h> diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index 8a2780247dc..6d86cde8c5d 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -48,8 +48,8 @@ #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup mutexes Mutexes * @ingroup concurrency @@ -739,7 +739,7 @@ namespace std } // @} group mutexes -} +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index 3688ea46d7c..b424ef341a4 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -40,8 +40,8 @@ #ifdef _GLIBCXX_USE_C99_STDINT_TR1 -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup ratio Rational Arithmetic * @ingroup utilities @@ -339,7 +339,7 @@ namespace std typedef ratio< 1000000000000000000, 1> exa; // @} group ratio -} +_GLIBCXX_END_NAMESPACE #endif //_GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread index 4a3818e7278..944d0a8a5b2 100644 --- a/libstdc++-v3/include/std/thread +++ b/libstdc++-v3/include/std/thread @@ -46,8 +46,8 @@ #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** * @defgroup threads Threads * @ingroup concurrency @@ -283,7 +283,7 @@ namespace std } // @} group threads -} +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index d0260deef9a..302d0f50895 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -37,8 +37,8 @@ #include <utility> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // Adds a const reference to a non-reference type. template<typename _Tp> struct __add_c_ref @@ -791,7 +791,8 @@ namespace std __do_cons(tuple<_Args...>&& __tuple, const _Index_tuple<_Indexes...>&) { return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); } -} + +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index a5a62d609eb..fe84a6f92ac 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -35,32 +35,463 @@ # include <bits/c++0x_warning.h> #else -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -#endif - #include <bits/c++config.h> -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/type_traits> -#else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/type_traits> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -#endif +_GLIBCXX_BEGIN_NAMESPACE(std) -namespace std -{ /** * @addtogroup metaprogramming * @{ */ + struct __sfinae_types + { + typedef char __one; + typedef struct { char __arr[2]; } __two; + }; + +#define _DEFINE_SPEC_0_HELPER \ + template<> + +#define _DEFINE_SPEC_1_HELPER \ + template<typename _Tp> + +#define _DEFINE_SPEC_2_HELPER \ + template<typename _Tp, typename _Cp> + +#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \ + _DEFINE_SPEC_##_Order##_HELPER \ + struct _Trait<_Type> \ + : public integral_constant<bool, _Value> { }; + + // helper classes. + + /// integral_constant + template<typename _Tp, _Tp __v> + struct integral_constant + { + static constexpr _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + constexpr operator value_type() { return value; } + }; + + /// typedef for true_type + typedef integral_constant<bool, true> true_type; + + /// typedef for false_type + typedef integral_constant<bool, false> false_type; + + template<typename _Tp, _Tp __v> + constexpr _Tp integral_constant<_Tp, __v>::value; + + /// remove_cv + template<typename> + struct remove_cv; + + template<typename> + struct __is_void_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_void_helper, void, true) + + // primary type categories. + + /// is_void + template<typename _Tp> + struct is_void + : public integral_constant<bool, (__is_void_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_integral_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_integral_helper, bool, true) + _DEFINE_SPEC(0, __is_integral_helper, char, true) + _DEFINE_SPEC(0, __is_integral_helper, signed char, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true) +#ifdef _GLIBCXX_USE_WCHAR_T + _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true) +#endif + _DEFINE_SPEC(0, __is_integral_helper, char16_t, true) + _DEFINE_SPEC(0, __is_integral_helper, char32_t, true) + _DEFINE_SPEC(0, __is_integral_helper, short, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true) + _DEFINE_SPEC(0, __is_integral_helper, int, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned int, true) + _DEFINE_SPEC(0, __is_integral_helper, long, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned long, true) + _DEFINE_SPEC(0, __is_integral_helper, long long, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true) + + /// is_integral + template<typename _Tp> + struct is_integral + : public integral_constant<bool, (__is_integral_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_floating_point_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_floating_point_helper, float, true) + _DEFINE_SPEC(0, __is_floating_point_helper, double, true) + _DEFINE_SPEC(0, __is_floating_point_helper, long double, true) + + /// is_floating_point + template<typename _Tp> + struct is_floating_point + : public integral_constant<bool, (__is_floating_point_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + /// is_array + template<typename> + struct is_array + : public false_type { }; + + template<typename _Tp, std::size_t _Size> + struct is_array<_Tp[_Size]> + : public true_type { }; + + template<typename _Tp> + struct is_array<_Tp[]> + : public true_type { }; + + template<typename> + struct __is_pointer_helper + : public false_type { }; + _DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true) + + /// is_pointer + template<typename _Tp> + struct is_pointer + : public integral_constant<bool, (__is_pointer_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + /// is_reference + template<typename _Tp> + struct is_reference; + + /// is_function + template<typename _Tp> + struct is_function; + + template<typename> + struct __is_member_object_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*, + !is_function<_Tp>::value) + + /// is_member_object_pointer + template<typename _Tp> + struct is_member_object_pointer + : public integral_constant<bool, (__is_member_object_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_member_function_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*, + is_function<_Tp>::value) + + /// is_member_function_pointer + template<typename _Tp> + struct is_member_function_pointer + : public integral_constant<bool, (__is_member_function_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + /// is_enum + template<typename _Tp> + struct is_enum + : public integral_constant<bool, __is_enum(_Tp)> + { }; + + /// is_union + template<typename _Tp> + struct is_union + : public integral_constant<bool, __is_union(_Tp)> + { }; + + /// is_class + template<typename _Tp> + struct is_class + : public integral_constant<bool, __is_class(_Tp)> + { }; + + /// is_function + template<typename> + struct is_function + : public false_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...)> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......)> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) const> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) const> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) const volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) const volatile> + : public true_type { }; + + // composite type traits. + + /// is_arithmetic + template<typename _Tp> + struct is_arithmetic + : public integral_constant<bool, (is_integral<_Tp>::value + || is_floating_point<_Tp>::value)> + { }; + + /// is_fundamental + template<typename _Tp> + struct is_fundamental + : public integral_constant<bool, (is_arithmetic<_Tp>::value + || is_void<_Tp>::value)> + { }; + + /// is_object + template<typename _Tp> + struct is_object + : public integral_constant<bool, !(is_function<_Tp>::value + || is_reference<_Tp>::value + || is_void<_Tp>::value)> + { }; + + /// is_member_pointer + template<typename _Tp> + struct is_member_pointer; + + /// is_scalar + template<typename _Tp> + struct is_scalar + : public integral_constant<bool, (is_arithmetic<_Tp>::value + || is_enum<_Tp>::value + || is_pointer<_Tp>::value + || is_member_pointer<_Tp>::value)> + { }; + + /// is_compound + template<typename _Tp> + struct is_compound + : public integral_constant<bool, !is_fundamental<_Tp>::value> { }; + + /// is_member_pointer + template<typename _Tp> + struct __is_member_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true) + + template<typename _Tp> + struct is_member_pointer + : public integral_constant<bool, (__is_member_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + // type properties. + /// is_const + template<typename> + struct is_const + : public false_type { }; + + template<typename _Tp> + struct is_const<_Tp const> + : public true_type { }; + + /// is_volatile + template<typename> + struct is_volatile + : public false_type { }; + + template<typename _Tp> + struct is_volatile<_Tp volatile> + : public true_type { }; + + /// is_empty + template<typename _Tp> + struct is_empty + : public integral_constant<bool, __is_empty(_Tp)> + { }; + + /// is_polymorphic + template<typename _Tp> + struct is_polymorphic + : public integral_constant<bool, __is_polymorphic(_Tp)> + { }; + + /// is_abstract + template<typename _Tp> + struct is_abstract + : public integral_constant<bool, __is_abstract(_Tp)> + { }; + + /// has_virtual_destructor + template<typename _Tp> + struct has_virtual_destructor + : public integral_constant<bool, __has_virtual_destructor(_Tp)> + { }; + + /// alignment_of + template<typename _Tp> + struct alignment_of + : public integral_constant<std::size_t, __alignof__(_Tp)> { }; + + /// rank + template<typename> + struct rank + : public integral_constant<std::size_t, 0> { }; + + template<typename _Tp, std::size_t _Size> + struct rank<_Tp[_Size]> + : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; + + template<typename _Tp> + struct rank<_Tp[]> + : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; + + /// extent + template<typename, unsigned _Uint = 0> + struct extent + : public integral_constant<std::size_t, 0> { }; + + template<typename _Tp, unsigned _Uint, std::size_t _Size> + struct extent<_Tp[_Size], _Uint> + : public integral_constant<std::size_t, + _Uint == 0 ? _Size : extent<_Tp, + _Uint - 1>::value> + { }; + + template<typename _Tp, unsigned _Uint> + struct extent<_Tp[], _Uint> + : public integral_constant<std::size_t, + _Uint == 0 ? 0 : extent<_Tp, + _Uint - 1>::value> + { }; + + // relationships between types [4.6]. + + /// is_same + template<typename, typename> + struct is_same + : public false_type { }; + + template<typename _Tp> + struct is_same<_Tp, _Tp> + : public true_type { }; + + // const-volatile modifications [4.7.1]. + + /// remove_const + template<typename _Tp> + struct remove_const + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_const<_Tp const> + { typedef _Tp type; }; + + /// remove_volatile + template<typename _Tp> + struct remove_volatile + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_volatile<_Tp volatile> + { typedef _Tp type; }; + + /// remove_cv + template<typename _Tp> + struct remove_cv + { + typedef typename + remove_const<typename remove_volatile<_Tp>::type>::type type; + }; + + /// add_const + template<typename _Tp> + struct add_const + { typedef _Tp const type; }; + + /// add_volatile + template<typename _Tp> + struct add_volatile + { typedef _Tp volatile type; }; + + /// add_cv + template<typename _Tp> + struct add_cv + { + typedef typename + add_const<typename add_volatile<_Tp>::type>::type type; + }; + + // array modifications. + + /// remove_extent + template<typename _Tp> + struct remove_extent + { typedef _Tp type; }; + + template<typename _Tp, std::size_t _Size> + struct remove_extent<_Tp[_Size]> + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_extent<_Tp[]> + { typedef _Tp type; }; + + /// remove_all_extents + template<typename _Tp> + struct remove_all_extents + { typedef _Tp type; }; + + template<typename _Tp, std::size_t _Size> + struct remove_all_extents<_Tp[_Size]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + template<typename _Tp> + struct remove_all_extents<_Tp[]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + // pointer modifications. + + template<typename _Tp, typename> + struct __remove_pointer_helper + { typedef _Tp type; }; + + template<typename _Tp, typename _Up> + struct __remove_pointer_helper<_Tp, _Up*> + { typedef _Up type; }; + + /// remove_pointer + template<typename _Tp> + struct remove_pointer + : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> + { }; + + template<typename> + struct remove_reference; + + /// add_pointer + template<typename _Tp> + struct add_pointer + { typedef typename remove_reference<_Tp>::type* type; }; // Primary classification traits. @@ -731,8 +1162,13 @@ namespace std <typename remove_cv<_Tp>::type>::value> \ { }; +#undef _DEFINE_SPEC_0_HELPER +#undef _DEFINE_SPEC_1_HELPER +#undef _DEFINE_SPEC_2_HELPER +#undef _DEFINE_SPEC + // @} group metaprogramming -} +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/typeindex b/libstdc++-v3/include/std/typeindex index 44836f67ea3..d40306421d4 100644 --- a/libstdc++-v3/include/std/typeindex +++ b/libstdc++-v3/include/std/typeindex @@ -37,8 +37,8 @@ #include <typeinfo> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + /** @brief The class type_index provides a simple wrapper for type_info which can be used as an index type in associative containers (23.6) @@ -98,7 +98,8 @@ namespace std operator()(const type_index& __ti) const { return __ti.hash_code(); } }; -} + +_GLIBCXX_END_NAMESPACE #endif // __GXX_EXPERIMENTAL_CXX0X__ diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index c3826eaca6b..e54a5868c90 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -1,6 +1,6 @@ // <utility> -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -71,24 +71,73 @@ #include <bits/stl_pair.h> #ifdef __GXX_EXPERIMENTAL_CXX0X__ -# if defined(_GLIBCXX_INCLUDE_AS_TR1) -# error C++0x header cannot be included from TR1 header -# endif -# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# include <tr1_impl/utility> -# else -# define _GLIBCXX_INCLUDE_AS_CXX0X -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 -# define _GLIBCXX_END_NAMESPACE_TR1 -# define _GLIBCXX_TR1 -# include <tr1_impl/utility> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_CXX0X -# endif -# include <bits/move.h> -# include <initializer_list> +#include <bits/move.h> +#include <initializer_list> + +_GLIBCXX_BEGIN_NAMESPACE(std) + + template<class _Tp> + class tuple_size; + + template<std::size_t _Int, class _Tp> + class tuple_element; + + // Various functions which give std::pair a tuple-like interface. + template<class _Tp1, class _Tp2> + struct tuple_size<std::pair<_Tp1, _Tp2> > + { static const std::size_t value = 2; }; + + template<class _Tp1, class _Tp2> + const std::size_t + tuple_size<std::pair<_Tp1, _Tp2> >::value; + + template<class _Tp1, class _Tp2> + struct tuple_element<0, std::pair<_Tp1, _Tp2> > + { typedef _Tp1 type; }; + + template<class _Tp1, class _Tp2> + struct tuple_element<1, std::pair<_Tp1, _Tp2> > + { typedef _Tp2 type; }; + + template<std::size_t _Int> + struct __pair_get; + + template<> + struct __pair_get<0> + { + template<typename _Tp1, typename _Tp2> + static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair) + { return __pair.first; } + + template<typename _Tp1, typename _Tp2> + static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair) + { return __pair.first; } + }; + + template<> + struct __pair_get<1> + { + template<typename _Tp1, typename _Tp2> + static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair) + { return __pair.second; } + + template<typename _Tp1, typename _Tp2> + static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair) + { return __pair.second; } + }; + + template<std::size_t _Int, class _Tp1, class _Tp2> + inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& + get(std::pair<_Tp1, _Tp2>& __in) + { return __pair_get<_Int>::__get(__in); } + + template<std::size_t _Int, class _Tp1, class _Tp2> + inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& + get(const std::pair<_Tp1, _Tp2>& __in) + { return __pair_get<_Int>::__const_get(__in); } + +_GLIBCXX_END_NAMESPACE + #endif #endif /* _GLIBCXX_UTILITY */ diff --git a/libstdc++-v3/include/tr1/array b/libstdc++-v3/include/tr1/array index 17cf5d290d2..3a1ff4caa8c 100644 --- a/libstdc++-v3/include/tr1/array +++ b/libstdc++-v3/include/tr1/array @@ -1,6 +1,7 @@ // class template array -*- C++ -*- -// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,24 +32,217 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <bits/stl_algobase.h> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/array> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/array> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +namespace std +{ +namespace tr1 +{ + /** + * @brief A standard container for storing a fixed size sequence of elements. + * + * @ingroup sequences + * + * Meets the requirements of a <a href="tables.html#65">container</a>, a + * <a href="tables.html#66">reversible container</a>, and a + * <a href="tables.html#67">sequence</a>. + * + * Sets support random access iterators. + * + * @param Tp Type of element. Required to be a complete type. + * @param N Number of elements. + */ + template<typename _Tp, std::size_t _Nm> + struct array + { + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + + // Support for zero-sized arrays mandatory. + value_type _M_instance[_Nm ? _Nm : 1]; + + // No explicit construct/copy/destroy for aggregate type. + + void + assign(const value_type& __u) + { std::fill_n(begin(), size(), __u); } + + void + swap(array& __other) + { std::swap_ranges(begin(), end(), __other.begin()); } + + // Iterators. + iterator + begin() + { return iterator(std::__addressof(_M_instance[0])); } + + const_iterator + begin() const + { return const_iterator(std::__addressof(_M_instance[0])); } + + iterator + end() + { return iterator(std::__addressof(_M_instance[_Nm])); } + + const_iterator + end() const + { return const_iterator(std::__addressof(_M_instance[_Nm])); } + + 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()); } + + // Capacity. + size_type + size() const { return _Nm; } + + size_type + max_size() const { return _Nm; } + + bool + empty() const { return size() == 0; } + + // Element access. + reference + operator[](size_type __n) + { return _M_instance[__n]; } + + const_reference + operator[](size_type __n) const + { return _M_instance[__n]; } + + reference + at(size_type __n) + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + const_reference + at(size_type __n) const + { + if (__n >= _Nm) + std::__throw_out_of_range(__N("array::at")); + return _M_instance[__n]; + } + + reference + front() + { return *begin(); } + + const_reference + front() const + { return *begin(); } + + reference + back() + { return _Nm ? *(end() - 1) : *end(); } + + const_reference + back() const + { return _Nm ? *(end() - 1) : *end(); } + + _Tp* + data() + { return std::__addressof(_M_instance[0]); } + + const _Tp* + data() const + { return std::__addressof(_M_instance[0]); } + }; + + // Array comparisons. + template<typename _Tp, std::size_t _Nm> + inline bool + operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return std::equal(__one.begin(), __one.end(), __two.begin()); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + return std::lexicographical_compare(__a.begin(), __a.end(), + __b.begin(), __b.end()); + } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template<typename _Tp, std::size_t _Nm> + inline bool + operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one < __two); } + + // Specialized algorithms [6.2.2.2]. + template<typename _Tp, std::size_t _Nm> + inline void + swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) + { __one.swap(__two); } + + // Tuple interface to class template array [6.2.2.5]. + + /// tuple_size + template<typename _Tp> + class tuple_size; + + /// tuple_element + template<int _Int, typename _Tp> + class tuple_element; + + template<typename _Tp, std::size_t _Nm> + struct tuple_size<array<_Tp, _Nm> > + { static const int value = _Nm; }; + + template<typename _Tp, std::size_t _Nm> + const int + tuple_size<array<_Tp, _Nm> >::value; + + template<int _Int, typename _Tp, std::size_t _Nm> + struct tuple_element<_Int, array<_Tp, _Nm> > + { typedef _Tp type; }; + + template<int _Int, typename _Tp, std::size_t _Nm> + inline _Tp& + get(array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } + + template<int _Int, typename _Tp, std::size_t _Nm> + inline const _Tp& + get(const array<_Tp, _Nm>& __arr) + { return __arr[_Int]; } +} +} #endif // _GLIBCXX_TR1_ARRAY diff --git a/libstdc++-v3/include/tr1/cctype b/libstdc++-v3/include/tr1/cctype index 93e864eb890..ecdb0833fc6 100644 --- a/libstdc++-v3/include/tr1/cctype +++ b/libstdc++-v3/include/tr1/cctype @@ -32,18 +32,18 @@ #include <bits/c++config.h> #include <cctype> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cctype> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cctype> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +#ifdef _GLIBCXX_USE_C99_CTYPE_TR1 + +#undef isblank + +namespace std +{ +namespace tr1 +{ + using ::isblank; +} +} + #endif #endif // _GLIBCXX_TR1_CCTYPE diff --git a/libstdc++-v3/include/tr1/cfenv b/libstdc++-v3/include/tr1/cfenv index e4c4facaa41..14db2ca3f75 100644 --- a/libstdc++-v3/include/tr1/cfenv +++ b/libstdc++-v3/include/tr1/cfenv @@ -1,6 +1,6 @@ // TR1 cfenv -*- C++ -*- -// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,22 +32,50 @@ #pragma GCC system_header #include <bits/c++config.h> + #if _GLIBCXX_HAVE_FENV_H # include <fenv.h> #endif -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cfenv> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cfenv> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +#ifdef _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +namespace std +{ +namespace tr1 +{ + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; +} +} + +#endif // _GLIBCXX_USE_C99_FENV_TR1 #endif // _GLIBCXX_TR1_CFENV diff --git a/libstdc++-v3/include/tr1/cinttypes b/libstdc++-v3/include/tr1/cinttypes index 71fd545d29d..e0cd1718e6d 100644 --- a/libstdc++-v3/include/tr1/cinttypes +++ b/libstdc++-v3/include/tr1/cinttypes @@ -1,6 +1,6 @@ // TR1 cinttypes -*- C++ -*- -// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -46,18 +46,39 @@ # endif #endif -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cinttypes> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cinttypes> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1 + +namespace std +{ +namespace tr1 +{ + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + + // May collide with _Longlong abs(_Longlong), and is not described + // anywhere outside the synopsis. Likely, a defect. + // + // intmax_t abs(intmax_t) + + using ::imaxdiv; + + // Likewise, with lldiv_t div(_Longlong, _Longlong). + // + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + using ::wcstoimax; + using ::wcstoumax; #endif +} +} + +#endif // _GLIBCXX_USE_C99_INTTYPES_TR1 #endif // _GLIBCXX_TR1_CINTTYPES diff --git a/libstdc++-v3/include/tr1/cmath b/libstdc++-v3/include/tr1/cmath index a9fbf2b6bb6..4c6e4c1ece7 100644 --- a/libstdc++-v3/include/tr1/cmath +++ b/libstdc++-v3/include/tr1/cmath @@ -37,20 +37,973 @@ #include <cmath> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cmath> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cmath> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +#undef acosh +#undef acoshf +#undef acoshl +#undef asinh +#undef asinhf +#undef asinhl +#undef atanh +#undef atanhf +#undef atanhl +#undef cbrt +#undef cbrtf +#undef cbrtl +#undef copysign +#undef copysignf +#undef copysignl +#undef erf +#undef erff +#undef erfl +#undef erfc +#undef erfcf +#undef erfcl +#undef exp2 +#undef exp2f +#undef exp2l +#undef expm1 +#undef expm1f +#undef expm1l +#undef fdim +#undef fdimf +#undef fdiml +#undef fma +#undef fmaf +#undef fmal +#undef fmax +#undef fmaxf +#undef fmaxl +#undef fmin +#undef fminf +#undef fminl +#undef hypot +#undef hypotf +#undef hypotl +#undef ilogb +#undef ilogbf +#undef ilogbl +#undef lgamma +#undef lgammaf +#undef lgammal +#undef llrint +#undef llrintf +#undef llrintl +#undef llround +#undef llroundf +#undef llroundl +#undef log1p +#undef log1pf +#undef log1pl +#undef log2 +#undef log2f +#undef log2l +#undef logb +#undef logbf +#undef logbl +#undef lrint +#undef lrintf +#undef lrintl +#undef lround +#undef lroundf +#undef lroundl +#undef nan +#undef nanf +#undef nanl +#undef nearbyint +#undef nearbyintf +#undef nearbyintl +#undef nextafter +#undef nextafterf +#undef nextafterl +#undef nexttoward +#undef nexttowardf +#undef nexttowardl +#undef remainder +#undef remainderf +#undef remainderl +#undef remquo +#undef remquof +#undef remquol +#undef rint +#undef rintf +#undef rintl +#undef round +#undef roundf +#undef roundl +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef scalbn +#undef scalbnf +#undef scalbnl +#undef tgamma +#undef tgammaf +#undef tgammal +#undef trunc +#undef truncf +#undef truncl + +#endif + +namespace std +{ +namespace tr1 +{ +#if _GLIBCXX_USE_C99_MATH_TR1 + + // types + using ::double_t; + using ::float_t; + + // functions + using ::acosh; + using ::acoshf; + using ::acoshl; + + using ::asinh; + using ::asinhf; + using ::asinhl; + + using ::atanh; + using ::atanhf; + using ::atanhl; + + using ::cbrt; + using ::cbrtf; + using ::cbrtl; + + using ::copysign; + using ::copysignf; + using ::copysignl; + + using ::erf; + using ::erff; + using ::erfl; + + using ::erfc; + using ::erfcf; + using ::erfcl; + + using ::exp2; + using ::exp2f; + using ::exp2l; + + using ::expm1; + using ::expm1f; + using ::expm1l; + + using ::fdim; + using ::fdimf; + using ::fdiml; + + using ::fma; + using ::fmaf; + using ::fmal; + + using ::fmax; + using ::fmaxf; + using ::fmaxl; + + using ::fmin; + using ::fminf; + using ::fminl; + + using ::hypot; + using ::hypotf; + using ::hypotl; + + using ::ilogb; + using ::ilogbf; + using ::ilogbl; + + using ::lgamma; + using ::lgammaf; + using ::lgammal; + + using ::llrint; + using ::llrintf; + using ::llrintl; + + using ::llround; + using ::llroundf; + using ::llroundl; + + using ::log1p; + using ::log1pf; + using ::log1pl; + + using ::log2; + using ::log2f; + using ::log2l; + + using ::logb; + using ::logbf; + using ::logbl; + + using ::lrint; + using ::lrintf; + using ::lrintl; + + using ::lround; + using ::lroundf; + using ::lroundl; + + using ::nan; + using ::nanf; + using ::nanl; + + using ::nearbyint; + using ::nearbyintf; + using ::nearbyintl; + + using ::nextafter; + using ::nextafterf; + using ::nextafterl; + + using ::nexttoward; + using ::nexttowardf; + using ::nexttowardl; + + using ::remainder; + using ::remainderf; + using ::remainderl; + + using ::remquo; + using ::remquof; + using ::remquol; + + using ::rint; + using ::rintf; + using ::rintl; + + using ::round; + using ::roundf; + using ::roundl; + + using ::scalbln; + using ::scalblnf; + using ::scalblnl; + + using ::scalbn; + using ::scalbnf; + using ::scalbnl; + + using ::tgamma; + using ::tgammaf; + using ::tgammal; + + using ::trunc; + using ::truncf; + using ::truncl; + +#endif + +#if _GLIBCXX_USE_C99_MATH +#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + + /// Function template definitions [8.16.3]. + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + fpclassify(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isfinite(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isfinite(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isinf(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isinf(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnan(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnan(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnormal(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnormal(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + signbit(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_signbit(__type(__f)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreater(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreaterequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreaterequal(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isless(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isless(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessequal(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessgreater(__type(__f1), __type(__f2)); + } + + template<typename _Tp> + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isunordered(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isunordered(__type(__f1), __type(__f2)); + } + +#endif #endif +#if _GLIBCXX_USE_C99_MATH_TR1 + + /// Additional overloads [8.16.4]. + using std::acos; + + inline float + acosh(float __x) + { return __builtin_acoshf(__x); } + + inline long double + acosh(long double __x) + { return __builtin_acoshl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + acosh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return acosh(__type(__x)); + } + + using std::asin; + + inline float + asinh(float __x) + { return __builtin_asinhf(__x); } + + inline long double + asinh(long double __x) + { return __builtin_asinhl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + asinh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return asinh(__type(__x)); + } + + using std::atan; + using std::atan2; + + inline float + atanh(float __x) + { return __builtin_atanhf(__x); } + + inline long double + atanh(long double __x) + { return __builtin_atanhl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + atanh(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return atanh(__type(__x)); + } + + inline float + cbrt(float __x) + { return __builtin_cbrtf(__x); } + + inline long double + cbrt(long double __x) + { return __builtin_cbrtl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + cbrt(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return cbrt(__type(__x)); + } + + using std::ceil; + + inline float + copysign(float __x, float __y) + { return __builtin_copysignf(__x, __y); } + + inline long double + copysign(long double __x, long double __y) + { return __builtin_copysignl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + copysign(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return copysign(__type(__x), __type(__y)); + } + + using std::cos; + using std::cosh; + + inline float + erf(float __x) + { return __builtin_erff(__x); } + + inline long double + erf(long double __x) + { return __builtin_erfl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + erf(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erf(__type(__x)); + } + + inline float + erfc(float __x) + { return __builtin_erfcf(__x); } + + inline long double + erfc(long double __x) + { return __builtin_erfcl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + erfc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return erfc(__type(__x)); + } + + using std::exp; + + inline float + exp2(float __x) + { return __builtin_exp2f(__x); } + + inline long double + exp2(long double __x) + { return __builtin_exp2l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + exp2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return exp2(__type(__x)); + } + + inline float + expm1(float __x) + { return __builtin_expm1f(__x); } + + inline long double + expm1(long double __x) + { return __builtin_expm1l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + expm1(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return expm1(__type(__x)); + } + + using std::fabs; + + inline float + fdim(float __x, float __y) + { return __builtin_fdimf(__x, __y); } + + inline long double + fdim(long double __x, long double __y) + { return __builtin_fdiml(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fdim(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fdim(__type(__x), __type(__y)); + } + + using std::floor; + + inline float + fma(float __x, float __y, float __z) + { return __builtin_fmaf(__x, __y, __z); } + + inline long double + fma(long double __x, long double __y, long double __z) + { return __builtin_fmal(__x, __y, __z); } + + template<typename _Tp, typename _Up, typename _Vp> + inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + fma(_Tp __x, _Up __y, _Vp __z) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; + return fma(__type(__x), __type(__y), __type(__z)); + } + + inline float + fmax(float __x, float __y) + { return __builtin_fmaxf(__x, __y); } + + inline long double + fmax(long double __x, long double __y) + { return __builtin_fmaxl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmax(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmax(__type(__x), __type(__y)); + } + + inline float + fmin(float __x, float __y) + { return __builtin_fminf(__x, __y); } + + inline long double + fmin(long double __x, long double __y) + { return __builtin_fminl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmin(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmin(__type(__x), __type(__y)); + } + + using std::fmod; + using std::frexp; + + inline float + hypot(float __x, float __y) + { return __builtin_hypotf(__x, __y); } + + inline long double + hypot(long double __x, long double __y) + { return __builtin_hypotl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + hypot(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return hypot(__type(__x), __type(__y)); + } + + inline int + ilogb(float __x) + { return __builtin_ilogbf(__x); } + + inline int + ilogb(long double __x) + { return __builtin_ilogbl(__x); } + + template<typename _Tp> + inline int + ilogb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return ilogb(__type(__x)); + } + + using std::ldexp; + + inline float + lgamma(float __x) + { return __builtin_lgammaf(__x); } + + inline long double + lgamma(long double __x) + { return __builtin_lgammal(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + lgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lgamma(__type(__x)); + } + + inline long long + llrint(float __x) + { return __builtin_llrintf(__x); } + + inline long long + llrint(long double __x) + { return __builtin_llrintl(__x); } + + template<typename _Tp> + inline long long + llrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llrint(__type(__x)); + } + + inline long long + llround(float __x) + { return __builtin_llroundf(__x); } + + inline long long + llround(long double __x) + { return __builtin_llroundl(__x); } + + template<typename _Tp> + inline long long + llround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return llround(__type(__x)); + } + + using std::log; + using std::log10; + + inline float + log1p(float __x) + { return __builtin_log1pf(__x); } + + inline long double + log1p(long double __x) + { return __builtin_log1pl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + log1p(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log1p(__type(__x)); + } + + // DR 568. + inline float + log2(float __x) + { return __builtin_log2f(__x); } + + inline long double + log2(long double __x) + { return __builtin_log2l(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + log2(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return log2(__type(__x)); + } + + inline float + logb(float __x) + { return __builtin_logbf(__x); } + + inline long double + logb(long double __x) + { return __builtin_logbl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + logb(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return logb(__type(__x)); + } + + inline long + lrint(float __x) + { return __builtin_lrintf(__x); } + + inline long + lrint(long double __x) + { return __builtin_lrintl(__x); } + + template<typename _Tp> + inline long + lrint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lrint(__type(__x)); + } + + inline long + lround(float __x) + { return __builtin_lroundf(__x); } + + inline long + lround(long double __x) + { return __builtin_lroundl(__x); } + + template<typename _Tp> + inline long + lround(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return lround(__type(__x)); + } + + inline float + nearbyint(float __x) + { return __builtin_nearbyintf(__x); } + + inline long double + nearbyint(long double __x) + { return __builtin_nearbyintl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + nearbyint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nearbyint(__type(__x)); + } + + inline float + nextafter(float __x, float __y) + { return __builtin_nextafterf(__x, __y); } + + inline long double + nextafter(long double __x, long double __y) + { return __builtin_nextafterl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + nextafter(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return nextafter(__type(__x), __type(__y)); + } + + inline float + nexttoward(float __x, long double __y) + { return __builtin_nexttowardf(__x, __y); } + + inline long double + nexttoward(long double __x, long double __y) + { return __builtin_nexttowardl(__x, __y); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + nexttoward(_Tp __x, long double __y) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return nexttoward(__type(__x), __y); + } + + // DR 550. What should the return type of pow(float,int) be? + // NB: C++0x and TR1 != C++03. + // using std::pow; + + inline float + remainder(float __x, float __y) + { return __builtin_remainderf(__x, __y); } + + inline long double + remainder(long double __x, long double __y) + { return __builtin_remainderl(__x, __y); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remainder(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remainder(__type(__x), __type(__y)); + } + + inline float + remquo(float __x, float __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + inline long double + remquo(long double __x, long double __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } + + template<typename _Tp, typename _Up> + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remquo(_Tp __x, _Up __y, int* __pquo) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remquo(__type(__x), __type(__y), __pquo); + } + + inline float + rint(float __x) + { return __builtin_rintf(__x); } + + inline long double + rint(long double __x) + { return __builtin_rintl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + rint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return rint(__type(__x)); + } + + inline float + round(float __x) + { return __builtin_roundf(__x); } + + inline long double + round(long double __x) + { return __builtin_roundl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + round(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return round(__type(__x)); + } + + inline float + scalbln(float __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + inline long double + scalbln(long double __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbln(_Tp __x, long __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbln(__type(__x), __ex); + } + + inline float + scalbn(float __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + inline long double + scalbn(long double __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + scalbn(_Tp __x, int __ex) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return scalbn(__type(__x), __ex); + } + + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; + + inline float + tgamma(float __x) + { return __builtin_tgammaf(__x); } + + inline long double + tgamma(long double __x) + { return __builtin_tgammal(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + tgamma(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return tgamma(__type(__x)); + } + + inline float + trunc(float __x) + { return __builtin_truncf(__x); } + + inline long double + trunc(long double __x) + { return __builtin_truncl(__x); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + trunc(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return trunc(__type(__x)); + } + +#endif +} +} + namespace std { namespace tr1 diff --git a/libstdc++-v3/include/tr1/complex b/libstdc++-v3/include/tr1/complex index 063112b440b..8cec0b11d8e 100644 --- a/libstdc++-v3/include/tr1/complex +++ b/libstdc++-v3/include/tr1/complex @@ -31,30 +31,334 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <complex> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/complex> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/complex> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif - namespace std { namespace tr1 { + /** + * @addtogroup complex_numbers + * @{ + */ + + // Forward declarations. + template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&); + + template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&); + template<typename _Tp> std::complex<_Tp> fabs(const std::complex<_Tp>&); + + template<typename _Tp> + inline std::complex<_Tp> + __complex_acos(const std::complex<_Tp>& __z) + { + const std::complex<_Tp> __t = std::tr1::asin(__z); + const _Tp __pi_2 = 1.5707963267948966192313216916397514L; + return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acos(__complex__ float __z) + { return __builtin_cacosf(__z); } + + inline __complex__ double + __complex_acos(__complex__ double __z) + { return __builtin_cacos(__z); } + + inline __complex__ long double + __complex_acos(const __complex__ long double& __z) + { return __builtin_cacosl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z.__rep()); } +#else + /// acos(__z) [8.1.2]. + // Effects: Behaves the same as C99 function cacos, defined + // in subclause 7.3.5.1. + template<typename _Tp> + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z); } +#endif + + template<typename _Tp> + inline std::complex<_Tp> + __complex_asin(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t(-__z.imag(), __z.real()); + __t = std::tr1::asinh(__t); + return std::complex<_Tp>(__t.imag(), -__t.real()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asin(__complex__ float __z) + { return __builtin_casinf(__z); } + + inline __complex__ double + __complex_asin(__complex__ double __z) + { return __builtin_casin(__z); } + + inline __complex__ long double + __complex_asin(const __complex__ long double& __z) + { return __builtin_casinl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z.__rep()); } +#else + /// asin(__z) [8.1.3]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.5.2. + template<typename _Tp> + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_atan(const std::complex<_Tp>& __z) + { + const _Tp __r2 = __z.real() * __z.real(); + const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag(); + + _Tp __num = __z.imag() + _Tp(1.0); + _Tp __den = __z.imag() - _Tp(1.0); + + __num = __r2 + __num * __num; + __den = __r2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x), + _Tp(0.25) * log(__num / __den)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atan(__complex__ float __z) + { return __builtin_catanf(__z); } + + inline __complex__ double + __complex_atan(__complex__ double __z) + { return __builtin_catan(__z); } + + inline __complex__ long double + __complex_atan(const __complex__ long double& __z) + { return __builtin_catanl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z.__rep()); } +#else + /// atan(__z) [8.1.4]. + // Effects: Behaves the same as C99 function catan, defined + // in subclause 7.3.5.3. + template<typename _Tp> + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_acosh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) - _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acosh(__complex__ float __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ double + __complex_acosh(__complex__ double __z) + { return __builtin_cacosh(__z); } + + inline __complex__ long double + __complex_acosh(const __complex__ long double& __z) + { return __builtin_cacoshl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z.__rep()); } +#else + /// acosh(__z) [8.1.5]. + // Effects: Behaves the same as C99 function cacosh, defined + // in subclause 7.3.6.1. + template<typename _Tp> + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_asinh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) + _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asinh(__complex__ float __z) + { return __builtin_casinhf(__z); } + + inline __complex__ double + __complex_asinh(__complex__ double __z) + { return __builtin_casinh(__z); } + + inline __complex__ long double + __complex_asinh(const __complex__ long double& __z) + { return __builtin_casinhl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z.__rep()); } +#else + /// asinh(__z) [8.1.6]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.6.2. + template<typename _Tp> + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z); } +#endif + + template<typename _Tp> + std::complex<_Tp> + __complex_atanh(const std::complex<_Tp>& __z) + { + const _Tp __i2 = __z.imag() * __z.imag(); + const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real(); + + _Tp __num = _Tp(1.0) + __z.real(); + _Tp __den = _Tp(1.0) - __z.real(); + + __num = __i2 + __num * __num; + __den = __i2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)), + _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atanh(__complex__ float __z) + { return __builtin_catanhf(__z); } + + inline __complex__ double + __complex_atanh(__complex__ double __z) + { return __builtin_catanh(__z); } + + inline __complex__ long double + __complex_atanh(const __complex__ long double& __z) + { return __builtin_catanhl(__z); } + + template<typename _Tp> + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z.__rep()); } +#else + /// atanh(__z) [8.1.7]. + // Effects: Behaves the same as C99 function catanh, defined + // in subclause 7.3.6.3. + template<typename _Tp> + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z); } +#endif + + template<typename _Tp> + inline std::complex<_Tp> + /// fabs(__z) [8.1.8]. + // Effects: Behaves the same as C99 function cabs, defined + // in subclause 7.3.8.1. + fabs(const std::complex<_Tp>& __z) + { return std::abs(__z); } + + /// Additional overloads [8.1.9]. +#ifndef __GXX_EXPERIMENTAL_CXX0X__ + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + arg(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; +#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) + return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L) + : __type(); +#else + return std::arg(std::complex<__type>(__x)); +#endif + } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + imag(_Tp) + { return _Tp(); } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + norm(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __type(__x) * __type(__x); + } + + template<typename _Tp> + inline typename __gnu_cxx::__promote<_Tp>::__type + real(_Tp __x) + { return __x; } + +#endif + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const std::complex<_Tp>& __x, const _Up& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), __type(__y)); + } + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const _Tp& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), std::complex<__type>(__y)); + } + + template<typename _Tp, typename _Up> + inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> + pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), + std::complex<__type>(__y)); + } + using std::arg; template<typename _Tp> @@ -95,6 +399,8 @@ namespace tr1 inline std::complex<_Tp> pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) { return std::pow(__x, __y); } + +// @} group complex_numbers } } diff --git a/libstdc++-v3/include/tr1/cstdint b/libstdc++-v3/include/tr1/cstdint index 1e6cc3714a9..c143bd279f4 100644 --- a/libstdc++-v3/include/tr1/cstdint +++ b/libstdc++-v3/include/tr1/cstdint @@ -31,10 +31,6 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <bits/c++config.h> // For 8.22.1/1 (see C99, Notes 219, 220, 222) @@ -58,19 +54,51 @@ # endif # endif -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cstdint> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cstdint> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + +namespace std +{ +namespace tr1 +{ + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; +} +} + +#endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_TR1_CSTDINT diff --git a/libstdc++-v3/include/tr1/cstdio b/libstdc++-v3/include/tr1/cstdio index cfcf31a3fda..bd52aa2292d 100644 --- a/libstdc++-v3/include/tr1/cstdio +++ b/libstdc++-v3/include/tr1/cstdio @@ -31,24 +31,23 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <cstdio> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cstdio> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cstdio> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +#if _GLIBCXX_USE_C99 + +namespace std +{ +namespace tr1 +{ + using std::snprintf; + using std::vsnprintf; + + using std::vfscanf; + using std::vscanf; + using std::vsscanf; +} +} + #endif #endif // _GLIBCXX_TR1_CSTDIO diff --git a/libstdc++-v3/include/tr1/cstdlib b/libstdc++-v3/include/tr1/cstdlib index c9fab202dcd..a4b8eb1c0d6 100644 --- a/libstdc++-v3/include/tr1/cstdlib +++ b/libstdc++-v3/include/tr1/cstdlib @@ -1,6 +1,6 @@ // TR1 cstdlib -*- C++ -*- -// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,24 +31,42 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header +#include <cstdlib> + +#if _GLIBCXX_HOSTED + +#if _GLIBCXX_USE_C99 + +namespace std +{ +namespace tr1 +{ +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + // types + using std::lldiv_t; + + // functions + using std::llabs; + using std::lldiv; #endif -#include <cstdlib> + using std::atoll; + using std::strtoll; + using std::strtoull; + + using std::strtof; + using std::strtold; -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cstdlib> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cstdlib> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 + // overloads + using std::abs; +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using std::div; #endif +} +} + +#endif // _GLIBCXX_USE_C99 + +#endif // _GLIBCXX_HOSTED #endif // _GLIBCXX_TR1_CSTDLIB diff --git a/libstdc++-v3/include/tr1/cwchar b/libstdc++-v3/include/tr1/cwchar index a27ebc3b4ac..c14111b0cf6 100644 --- a/libstdc++-v3/include/tr1/cwchar +++ b/libstdc++-v3/include/tr1/cwchar @@ -1,6 +1,6 @@ // TR1 cwchar -*- C++ -*- -// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,24 +31,35 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <cwchar> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cwchar> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cwchar> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +#ifdef _GLIBCXX_USE_WCHAR_T + +namespace std +{ +namespace tr1 +{ +#if _GLIBCXX_HAVE_WCSTOF + using std::wcstof; +#endif +#if _GLIBCXX_HAVE_VFWSCANF + using std::vfwscanf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using std::vswscanf; #endif +#if _GLIBCXX_HAVE_VWSCANF + using std::vwscanf; +#endif + +#if _GLIBCXX_USE_C99 + using std::wcstold; + using std::wcstoll; + using std::wcstoull; +#endif +} +} + +#endif // _GLIBCXX_USE_WCHAR_T #endif // _GLIBCXX_TR1_CWCHAR diff --git a/libstdc++-v3/include/tr1/cwctype b/libstdc++-v3/include/tr1/cwctype index 77cbb14a177..71da0bede00 100644 --- a/libstdc++-v3/include/tr1/cwctype +++ b/libstdc++-v3/include/tr1/cwctype @@ -31,24 +31,20 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <cwctype> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/cwctype> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/cwctype> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +#ifdef _GLIBCXX_USE_WCHAR_T + +namespace std +{ +namespace tr1 +{ +#if _GLIBCXX_HAVE_ISWBLANK + using std::iswblank; +#endif +} +} + +#endif // _GLIBCXX_USE_WCHAR_T #endif // _GLIBCXX_TR1_CWCTYPE diff --git a/libstdc++-v3/include/tr1/memory b/libstdc++-v3/include/tr1/memory index 8b021a1b102..eaf4932e5b5 100644 --- a/libstdc++-v3/include/tr1/memory +++ b/libstdc++-v3/include/tr1/memory @@ -1,6 +1,7 @@ // <tr1/memory> -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -47,21 +48,6 @@ #include <bits/stl_function.h> // std::less #include <debug/debug.h> #include <tr1/type_traits> - -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/boost_sp_counted_base.h> -# include <tr1/shared_ptr.h> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/boost_sp_counted_base.h> -# include <tr1/shared_ptr.h> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +#include <tr1/shared_ptr.h> #endif // _GLIBCXX_TR1_MEMORY diff --git a/libstdc++-v3/include/tr1/regex b/libstdc++-v3/include/tr1/regex index b7e2cdfc808..d69844c2cd9 100644 --- a/libstdc++-v3/include/tr1/regex +++ b/libstdc++-v3/include/tr1/regex @@ -33,10 +33,6 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <algorithm> #include <bitset> #include <iterator> @@ -47,18 +43,2682 @@ #include <utility> #include <sstream> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/regex> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/regex> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 +namespace std +{ +namespace tr1 +{ +/** + * @defgroup tr1_regex Regular Expressions + * A facility for performing regular expression pattern matching. + */ + //@{ + +/** @namespace std::regex_constants + * @brief ISO C++ 0x entities sub namespace for regex. + */ +namespace regex_constants +{ + /** + * @name 5.1 Regular Expression Syntax Options + */ + //@{ + enum __syntax_option + { + _S_icase, + _S_nosubs, + _S_optimize, + _S_collate, + _S_ECMAScript, + _S_basic, + _S_extended, + _S_awk, + _S_grep, + _S_egrep, + _S_syntax_last + }; + + /** + * @brief This is a bitmask type indicating how to interpret the regex. + * + * The @c syntax_option_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + * + * A valid value of type syntax_option_type shall have exactly one of the + * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep + * %set. + */ + typedef unsigned int syntax_option_type; + + /** + * Specifies that the matching of regular expressions against a character + * sequence shall be performed without regard to case. + */ + static const syntax_option_type icase = 1 << _S_icase; + + /** + * Specifies that when a regular expression is matched against a character + * container sequence, no sub-expression matches are to be stored in the + * supplied match_results structure. + */ + static const syntax_option_type nosubs = 1 << _S_nosubs; + + /** + * Specifies that the regular expression engine should pay more attention to + * the speed with which regular expressions are matched, and less to the + * speed with which regular expression objects are constructed. Otherwise + * it has no detectable effect on the program output. + */ + static const syntax_option_type optimize = 1 << _S_optimize; + + /** + * Specifies that character ranges of the form [a-b] should be locale + * sensitive. + */ + static const syntax_option_type collate = 1 << _S_collate; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript + * Language Specification, Standard Ecma-262, third edition, 1999], as + * modified in tr1 section [7.13]. This grammar is similar to that defined + * in the PERL scripting language but extended with elements found in the + * POSIX regular expression grammar. + */ + static const syntax_option_type ECMAScript = 1 << _S_ECMAScript; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- + * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + static const syntax_option_type basic = 1 << _S_basic; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and Headers, + * Section 9, Regular Expressions. + */ + static const syntax_option_type extended = 1 << _S_extended; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type extended, except that C-style escape + * sequences are supported. These sequences are: + * \\\\, \\a, \\b, \\f, + * \\n, \\r, \\t , \\v, + * \\', ', and \\ddd + * (where ddd is one, two, or three octal digits). + */ + static const syntax_option_type awk = 1 << _S_awk; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type basic, except that newlines are treated + * as whitespace. + */ + static const syntax_option_type grep = 1 << _S_grep; + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep when given the -E option in + * IEEE Std 1003.1-2001. This option is identical to syntax_option_type + * extended, except that newlines are treated as whitespace. + */ + static const syntax_option_type egrep = 1 << _S_egrep; + + //@} + + /** + * @name 5.2 Matching Rules + * + * Matching a regular expression against a sequence of characters [first, + * last) proceeds according to the rules of the grammar specified for the + * regular expression object, modified according to the effects listed + * below for any bitmask elements set. + * + */ + //@{ + + enum __match_flag + { + _S_not_bol, + _S_not_eol, + _S_not_bow, + _S_not_eow, + _S_any, + _S_not_null, + _S_continuous, + _S_prev_avail, + _S_sed, + _S_no_copy, + _S_first_only, + _S_match_flag_last + }; + + /** + * @brief This is a bitmask type indicating regex matching rules. + * + * The @c match_flag_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + */ + typedef std::bitset<_S_match_flag_last> match_flag_type; + + /** + * The default matching rules. + */ + static const match_flag_type match_default = 0; + + /** + * The first character in the sequence [first, last) is treated as though it + * is not at the beginning of a line, so the character (^) in the regular + * expression shall not match [first, first). + */ + static const match_flag_type match_not_bol = 1 << _S_not_bol; + + /** + * The last character in the sequence [first, last) is treated as though it + * is not at the end of a line, so the character ($) in the regular + * expression shall not match [last, last). + */ + static const match_flag_type match_not_eol = 1 << _S_not_eol; + + /** + * The expression \\b is not matched against the sub-sequence + * [first,first). + */ + static const match_flag_type match_not_bow = 1 << _S_not_bow; + + /** + * The expression \\b should not be matched against the sub-sequence + * [last,last). + */ + static const match_flag_type match_not_eow = 1 << _S_not_eow; + + /** + * If more than one match is possible then any match is an acceptable + * result. + */ + static const match_flag_type match_any = 1 << _S_any; + + /** + * The expression does not match an empty sequence. + */ + static const match_flag_type match_not_null = 1 << _S_not_null; + + /** + * The expression only matches a sub-sequence that begins at first . + */ + static const match_flag_type match_continuous = 1 << _S_continuous; + + /** + * --first is a valid iterator position. When this flag is set then the + * flags match_not_bol and match_not_bow are ignored by the regular + * expression algorithms 7.11 and iterators 7.12. + */ + static const match_flag_type match_prev_avail = 1 << _S_prev_avail; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the ECMAScript replace + * function in ECMA- 262 [Ecma International, ECMAScript Language + * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 + * String.prototype.replace. In addition, during search and replace + * operations all non-overlapping occurrences of the regular expression + * are located and replaced, and sections of the input that did not match + * the expression are copied unchanged to the output string. + * + * Format strings (from ECMA-262 [15.5.4.11]): + * @li $$ The dollar-sign itself ($) + * @li $& The matched substring. + * @li $` The portion of @a string that precedes the matched substring. + * This would be match_results::prefix(). + * @li $' The portion of @a string that follows the matched substring. + * This would be match_results::suffix(). + * @li $n The nth capture, where n is in [1,9] and $n is not followed by a + * decimal digit. If n <= match_results::size() and the nth capture + * is undefined, use the empty string instead. If n > + * match_results::size(), the result is implementation-defined. + * @li $nn The nnth capture, where nn is a two-digit decimal number on + * [01, 99]. If nn <= match_results::size() and the nth capture is + * undefined, use the empty string instead. If + * nn > match_results::size(), the result is implementation-defined. + */ + static const match_flag_type format_default = 0; + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the POSIX sed utility + * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable + * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + static const match_flag_type format_sed = 1 << _S_sed; + + /** + * During a search and replace operation, sections of the character + * container sequence being searched that do not match the regular + * expression shall not be copied to the output string. + */ + static const match_flag_type format_no_copy = 1 << _S_no_copy; + + /** + * When specified during a search and replace operation, only the first + * occurrence of the regular expression shall be replaced. + */ + static const match_flag_type format_first_only = 1 << _S_first_only; + + //@} + + /** + * @name 5.3 Error Types + */ + //@{ + + enum error_type + { + _S_error_collate, + _S_error_ctype, + _S_error_escape, + _S_error_backref, + _S_error_brack, + _S_error_paren, + _S_error_brace, + _S_error_badbrace, + _S_error_range, + _S_error_space, + _S_error_badrepeat, + _S_error_complexity, + _S_error_stack, + _S_error_last + }; + + /** The expression contained an invalid collating element name. */ + static const error_type error_collate(_S_error_collate); + + /** The expression contained an invalid character class name. */ + static const error_type error_ctype(_S_error_ctype); + + /** + * The expression contained an invalid escaped character, or a trailing + * escape. + */ + static const error_type error_escape(_S_error_escape); + + /** The expression contained an invalid back reference. */ + static const error_type error_backref(_S_error_backref); + + /** The expression contained mismatched [ and ]. */ + static const error_type error_brack(_S_error_brack); + + /** The expression contained mismatched ( and ). */ + static const error_type error_paren(_S_error_paren); + + /** The expression contained mismatched { and } */ + static const error_type error_brace(_S_error_brace); + + /** The expression contained an invalid range in a {} expression. */ + static const error_type error_badbrace(_S_error_badbrace); + + /** + * The expression contained an invalid character range, + * such as [b-a] in most encodings. + */ + static const error_type error_range(_S_error_range); + + /** + * There was insufficient memory to convert the expression into a + * finite state machine. + */ + static const error_type error_space(_S_error_space); + + /** + * One of <em>*?+{</em> was not preceded by a valid regular expression. + */ + static const error_type error_badrepeat(_S_error_badrepeat); + + /** + * The complexity of an attempted match against a regular expression + * exceeded a pre-set level. + */ + static const error_type error_complexity(_S_error_complexity); + + /** + * There was insufficient memory to determine whether the + * regular expression could match the specified character sequence. + */ + static const error_type error_stack(_S_error_stack); + + //@} +} + + + // [7.8] Class regex_error + /** + * @brief A regular expression exception class. + * @ingroup exceptions + * + * The regular expression library throws objects of this class on error. + */ + class regex_error + : public std::runtime_error + { + public: + /** + * @brief Constructs a regex_error object. + * + * @param ecode the regex error code. + */ + explicit + regex_error(regex_constants::error_type __ecode) + : std::runtime_error("regex_error"), _M_code(__ecode) + { } + + /** + * @brief Gets the regex error code. + * + * @returns the regex error code. + */ + regex_constants::error_type + code() const + { return _M_code; } + + protected: + regex_constants::error_type _M_code; + }; + + // [7.7] Class regex_traits + /** + * @brief Describes aspects of a regular expression. + * + * A regular expression traits class that satisfies the requirements of tr1 + * section [7.2]. + * + * The class %regex is parameterized around a set of related types and + * functions used to complete the definition of its semantics. This class + * satisfies the requirements of such a traits class. + */ + template<typename _Ch_type> + struct regex_traits + { + public: + typedef _Ch_type char_type; + typedef std::basic_string<char_type> string_type; + typedef std::locale locale_type; + typedef std::ctype_base::mask char_class_type; + + public: + /** + * @brief Constructs a default traits object. + */ + regex_traits() + { } + + /** + * @brief Gives the length of a C-style string starting at @p __p. + * + * @param __p a pointer to the start of a character sequence. + * + * @returns the number of characters between @p *__p and the first + * default-initialized value of type @p char_type. In other words, uses + * the C-string algorithm for determining the length of a sequence of + * characters. + */ + static std::size_t + length(const char_type* __p) + { return string_type::traits_type::length(__p); } + + /** + * @brief Performs the identity translation. + * + * @param c A character to the locale-specific character set. + * + * @returns c. + */ + char_type + translate(char_type __c) const + { return __c; } + + /** + * @brief Translates a character into a case-insensitive equivalent. + * + * @param c A character to the locale-specific character set. + * + * @returns the locale-specific lower-case equivalent of c. + * @throws std::bad_cast if the imbued locale does not support the ctype + * facet. + */ + char_type + translate_nocase(char_type __c) const + { + using std::ctype; + using std::use_facet; + return use_facet<ctype<char_type> >(_M_locale).tolower(__c); + } + + /** + * @brief Gets a sort key for a character sequence. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * Returns a sort key for the character sequence designated by the + * iterator range [F1, F2) such that if the character sequence [G1, G2) + * sorts before the character sequence [H1, H2) then + * v.transform(G1, G2) < v.transform(H1, H2). + * + * What this really does is provide a more efficient way to compare a + * string to multiple other strings in locales with fancy collation + * rules and equivalence classes. + * + * @returns a locale-specific sort key equivalent to the input range. + * + * @throws std::bad_cast if the current locale does not have a collate + * facet. + */ + template<typename _Fwd_iter> + string_type + transform(_Fwd_iter __first, _Fwd_iter __last) const + { + using std::collate; + using std::use_facet; + const collate<_Ch_type>& __c(use_facet< + collate<_Ch_type> >(_M_locale)); + string_type __s(__first, __last); + return __c.transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Dunno. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * Effects: if typeid(use_facet<collate<_Ch_type> >) == + * typeid(collate_byname<_Ch_type>) and the form of the sort key + * returned by collate_byname<_Ch_type>::transform(first, last) is known + * and can be converted into a primary sort key then returns that key, + * otherwise returns an empty string. WTF?? + * + * @todo Implement this function. + */ + template<typename _Fwd_iter> + string_type + transform_primary(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Gets a collation element by name. + * + * @param first beginning of the collation element name. + * @param last one-past-the-end of the collation element name. + * + * @returns a sequence of one or more characters that represents the + * collating element consisting of the character sequence designated by + * the iterator range [first, last). Returns an empty string if the + * character sequence is not a valid collating element. + * + * @todo Implement this function. + */ + template<typename _Fwd_iter> + string_type + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Maps one or more characters to a named character + * classification. + * + * @param first beginning of the character sequence. + * @param last one-past-the-end of the character sequence. + * + * @returns an unspecified value that represents the character + * classification named by the character sequence designated by the + * iterator range [first, last). The value returned shall be independent + * of the case of the characters in the character sequence. If the name + * is not recognized then returns a value that compares equal to 0. + * + * At least the following names (or their wide-character equivalent) are + * supported. + * - d + * - w + * - s + * - alnum + * - alpha + * - blank + * - cntrl + * - digit + * - graph + * - lower + * - print + * - punct + * - space + * - upper + * - xdigit + * + * @todo Implement this function. + */ + template<typename _Fwd_iter> + char_class_type + lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Determines if @p c is a member of an identified class. + * + * @param c a character. + * @param f a class type (as returned from lookup_classname). + * + * @returns true if the character @p c is a member of the classification + * represented by @p f, false otherwise. + * + * @throws std::bad_cast if the current locale does not have a ctype + * facet. + */ + bool + isctype(_Ch_type __c, char_class_type __f) const; + + /** + * @brief Converts a digit to an int. + * + * @param ch a character representing a digit. + * @param radix the radix if the numeric conversion (limited to 8, 10, + * or 16). + * + * @returns the value represented by the digit ch in base radix if the + * character ch is a valid digit in base radix; otherwise returns -1. + */ + int + value(_Ch_type __ch, int __radix) const; + + /** + * @brief Imbues the regex_traits object with a copy of a new locale. + * + * @param loc A locale. + * + * @returns a copy of the previous locale in use by the regex_traits + * object. + * + * @note Calling imbue with a different locale than the one currently in + * use invalidates all cached data held by *this. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(_M_locale, __loc); + return __loc; + } + + /** + * @brief Gets a copy of the current locale in use by the regex_traits + * object. + */ + locale_type + getloc() const + { return _M_locale; } + + protected: + locale_type _M_locale; + }; + + template<typename _Ch_type> + bool regex_traits<_Ch_type>:: + isctype(_Ch_type __c, char_class_type __f) const + { + using std::ctype; + using std::use_facet; + const ctype<_Ch_type>& __ctype(use_facet< + ctype<_Ch_type> >(_M_locale)); + + if (__ctype.is(__c, __f)) + return true; + + // special case of underscore in [[:w:]] + if (__c == __ctype.widen('_')) + { + const char* const __wb[] = "w"; + char_class_type __wt = this->lookup_classname(__wb, + __wb + sizeof(__wb)); + if (__f | __wt) + return true; + } + + // special case of [[:space:]] in [[:blank:]] + if (__c == __ctype.isspace(__c)) + { + const char* const __bb[] = "blank"; + char_class_type __bt = this->lookup_classname(__bb, + __bb + sizeof(__bb)); + if (__f | __bt) + return true; + } + + return false; + } + + template<typename _Ch_type> + int regex_traits<_Ch_type>:: + value(_Ch_type __ch, int __radix) const + { + std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); + int __v; + if (__radix == 8) + __is >> std::oct; + else if (__radix == 16) + __is >> std::hex; + __is >> __v; + return __is.fail() ? -1 : __v; + } + + // [7.8] Class basic_regex + /** + * Objects of specializations of this class represent regular expressions + * constructed from sequences of character type @p _Ch_type. + * + * Storage for the regular expression is allocated and deallocated as + * necessary by the member functions of this class. + */ + template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> > + class basic_regex + { + public: + // types: + typedef _Ch_type value_type; + typedef regex_constants::syntax_option_type flag_type; + typedef typename _Rx_traits::locale_type locale_type; + typedef typename _Rx_traits::string_type string_type; + + /** + * @name Constants + * tr1 [7.8.1] std [28.8.1] + */ + //@{ + static const regex_constants::syntax_option_type icase + = regex_constants::icase; + static const regex_constants::syntax_option_type nosubs + = regex_constants::nosubs; + static const regex_constants::syntax_option_type optimize + = regex_constants::optimize; + static const regex_constants::syntax_option_type collate + = regex_constants::collate; + static const regex_constants::syntax_option_type ECMAScript + = regex_constants::ECMAScript; + static const regex_constants::syntax_option_type basic + = regex_constants::basic; + static const regex_constants::syntax_option_type extended + = regex_constants::extended; + static const regex_constants::syntax_option_type awk + = regex_constants::awk; + static const regex_constants::syntax_option_type grep + = regex_constants::grep; + static const regex_constants::syntax_option_type egrep + = regex_constants::egrep; + //@} + + // [7.8.2] construct/copy/destroy + /** + * Constructs a basic regular expression that does not match any + * character sequence. + */ + basic_regex() + : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the + * flags in @p f. + * + * @param p A pointer to the start of a C-style null-terminated string + * containing a regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p p is not a valid regular expression. + */ + explicit + basic_regex(const _Ch_type* __p, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__p), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + len) interpreted according to the flags in @p f. + * + * @param p A pointer to the start of a string containing a regular + * expression. + * @param len The length of the string containing the regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p p is not a valid regular expression. + */ + basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f) + : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Copy-constructs a basic regular expression. + * + * @param rhs A @p regex object. + */ + basic_regex(const basic_regex& __rhs) + : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern), + _M_mark_count(__rhs._M_mark_count) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the string + * @p s interpreted according to the flags in @p f. + * + * @param s A string containing a regular expression. + * @param f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p s is not a valid regular expression. + */ + template<typename _Ch_traits, typename _Ch_alloc> + explicit + basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0) + { _M_compile(); } + + /** + * @brief Constructs a basic regular expression from the range + * [first, last) interpreted according to the flags in @p f. + * + * @param first The start of a range containing a valid regular + * expression. + * @param last The end of a range containing a valid regular + * expression. + * @param f The format flags of the regular expression. + * + * @throws regex_error if @p [first, last) is not a valid regular + * expression. + */ + template<typename _InputIterator> + basic_regex(_InputIterator __first, _InputIterator __last, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0) + { _M_compile(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Constructs a basic regular expression from an initializer list. + * + * @param l The initializer list. + * @param f The format flags of the regular expression. + * + * @throws regex_error if @p l is not a valid regular expression. + */ + basic_regex(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0) + { _M_compile(); } +#endif + + /** + * @brief Destroys a basic regular expression. + */ + ~basic_regex() + { } + + /** + * @brief Assigns one regular expression to another. + */ + basic_regex& + operator=(const basic_regex& __rhs) + { return this->assign(__rhs); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a C-style null-terminated string. + * + * @param A pointer to the start of a null-terminated C-style string + * containing a regular expression. + */ + basic_regex& + operator=(const _Ch_type* __p) + { return this->assign(__p, flags()); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a string. + * + * @param A pointer to a string containing a regular expression. + */ + template<typename _Ch_typeraits, typename _Allocator> + basic_regex& + operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s) + { return this->assign(__s, flags()); } + + // [7.8.3] assign + /** + * @brief the real assignment operator. + * + * @param that Another regular expression object. + */ + basic_regex& + assign(const basic_regex& __that) + { + basic_regex __tmp(__that); + this->swap(__tmp); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style null-terminated string containing a regular expression + * pattern. + * + * @param p A pointer to a C-style null-terminated string containing + * a regular expression pattern. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, + flag_type __flags = regex_constants::ECMAScript) + { return this->assign(string_type(__p), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style string containing a regular expression pattern. + * + * @param p A pointer to a C-style string containing a + * regular expression pattern. + * @param len The length of the regular expression pattern string. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, std::size_t __len, flag_type __flags) + { return this->assign(string_type(__p, __len), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * string containing a regular expression pattern. + * + * @param s A string containing a regular expression pattern. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * *this remains unchanged. + */ + template<typename _Ch_typeraits, typename _Allocator> + basic_regex& + assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s, + flag_type __f = regex_constants::ECMAScript) + { + basic_regex __tmp(__s, __f); + this->swap(__tmp); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param first The start of a range containing a valid regular + * expression. + * @param last The end of a range containing a valid regular + * expression. + * @param flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular expression + * pattern interpreted according to @p flags. If regex_error is thrown, + * the object remains unchanged. + */ + template<typename _InputIterator> + basic_regex& + assign(_InputIterator __first, _InputIterator __last, + flag_type __flags = regex_constants::ECMAScript) + { return this->assign(string_type(__first, __last), __flags); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param l An initializer list representing a regular expression. + * @param flags Syntax option flags. + * + * @throws regex_error if @p l does not contain a valid regular + * expression pattern interpreted according to @p flags. If regex_error + * is thrown, the object remains unchanged. + */ + basic_regex& + assign(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + { return this->assign(__l.begin(), __l.end(), __f); } +#endif + + // [7.8.4] const operations + /** + * @brief Gets the number of marked subexpressions within the regular + * expression. + */ + unsigned int + mark_count() const + { return _M_mark_count; } + + /** + * @brief Gets the flags used to construct the regular expression + * or in the last call to assign(). + */ + flag_type + flags() const + { return _M_flags; } + + // [7.8.5] locale + /** + * @brief Imbues the regular expression object with the given locale. + * + * @param loc A locale. + */ + locale_type + imbue(locale_type __loc) + { return _M_traits.imbue(__loc); } + + /** + * @brief Gets the locale currently imbued in the regular expression + * object. + */ + locale_type + getloc() const + { return _M_traits.getloc(); } + + // [7.8.6] swap + /** + * @brief Swaps the contents of two regular expression objects. + * + * @param rhs Another regular expression object. + */ + void + swap(basic_regex& __rhs) + { + std::swap(_M_flags, __rhs._M_flags); + std::swap(_M_pattern, __rhs._M_pattern); + std::swap(_M_mark_count, __rhs._M_mark_count); + std::swap(_M_traits, __rhs._M_traits); + } + + private: + /** + * @brief Compiles a regular expression pattern into a NFA. + * @todo Implement this function. + */ + void _M_compile(); + + protected: + flag_type _M_flags; + string_type _M_pattern; + unsigned int _M_mark_count; + _Rx_traits _M_traits; + }; + + /** @brief Standard regular expressions. */ + typedef basic_regex<char> regex; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Standard wide-character regular expressions. */ + typedef basic_regex<wchar_t> wregex; +#endif + + + // [7.8.6] basic_regex swap + /** + * @brief Swaps the contents of two regular expression objects. + * @param lhs First regular expression. + * @param rhs Second regular expression. + */ + template<typename _Ch_type, typename _Rx_traits> + inline void + swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, + basic_regex<_Ch_type, _Rx_traits>& __rhs) + { __lhs.swap(__rhs); } + + + // [7.9] Class template sub_match + /** + * A sequence of characters matched by a particular marked sub-expression. + * + * An object of this class is essentially a pair of iterators marking a + * matched subexpression within a regular expression pattern match. Such + * objects can be converted to and compared with std::basic_string objects + * of a similar base character type as the pattern matched by the regular + * expression. + * + * The iterators that make up the pair are the usual half-open interval + * referencing the actual original pattern matched. + */ + template<typename _BiIter> + class sub_match : public std::pair<_BiIter, _BiIter> + { + public: + typedef typename iterator_traits<_BiIter>::value_type value_type; + typedef typename iterator_traits<_BiIter>::difference_type + difference_type; + typedef _BiIter iterator; + + public: + bool matched; + + /** + * Gets the length of the matching sequence. + */ + difference_type + length() const + { return this->matched ? std::distance(this->first, this->second) : 0; } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + * + * This is the implicit conversion operator. It is identical to the + * str() member function except that it will want to pop up in + * unexpected places and cause a great deal of confusion and cursing + * from the unwary. + */ + operator basic_string<value_type>() const + { + return this->matched + ? std::basic_string<value_type>(this->first, this->second) + : std::basic_string<value_type>(); + } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + */ + basic_string<value_type> + str() const + { + return this->matched + ? std::basic_string<value_type>(this->first, this->second) + : std::basic_string<value_type>(); + } + + /** + * @brief Compares this and another matched sequence. + * + * @param s Another matched sequence to compare to this one. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const sub_match& __s) const + { return this->str().compare(__s.str()); } + + /** + * @brief Compares this sub_match to a string. + * + * @param s A string to compare to this sub_match. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const basic_string<value_type>& __s) const + { return this->str().compare(__s); } + + /** + * @brief Compares this sub_match to a C-style string. + * + * @param s A C-style string to compare to this sub_match. + * + * @retval <0 this matched sequence will collate before @p s. + * @retval =0 this matched sequence is equivalent to @p s. + * @retval <0 this matched sequence will collate after @p s. + */ + int + compare(const value_type* __s) const + { return this->str().compare(__s); } + }; + + + /** @brief Standard regex submatch over a C-style null-terminated string. */ + typedef sub_match<const char*> csub_match; + /** @brief Standard regex submatch over a standard string. */ + typedef sub_match<string::const_iterator> ssub_match; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Regex submatch over a C-style null-terminated wide string. */ + typedef sub_match<const wchar_t*> wcsub_match; + /** @brief Regex submatch over a standard wide string. */ + typedef sub_match<wstring::const_iterator> wssub_match; +#endif + + // [7.9.2] sub_match non-member operators + + /** + * @brief Tests the equivalence of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator==(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) == 0; } + + /** + * @brief Tests the inequivalence of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator!=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) != 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator<(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator<=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator>=(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param lhs First regular expression submatch. + * @param rhs Second regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _BiIter> + inline bool + operator>(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator==(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator!=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator<(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator>(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator>=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator<=(const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + const basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Tests the equivalence of a C string and a regular expression + * submatch. + * @param lhs A C string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of an iterator value and a regular + * expression submatch. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A pointer to a string? + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A pointer to a string. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A string. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs == __rhs.str(); } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs != __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs < __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs > __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs >= __rhs.str(); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param lhs A string. + * @param rhs A regular expression submatch. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __lhs <= __rhs.str(); } + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs is equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() == __rhs; } + + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() != __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs precedes @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() < __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs succeeds @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() > __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs does not precede @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() >= __rhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param lhs A regular expression submatch. + * @param rhs A const string reference. + * @returns true if @a lhs does not succeed @a rhs, false otherwise. + */ + template<typename _Bi_iter> + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs.str() <= __rhs; } + + /** + * @brief Inserts a matched string into an output stream. + * + * @param os The output stream. + * @param m A submatch string. + * + * @returns the output stream with the submatch string inserted. + */ + template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter> + inline + basic_ostream<_Ch_type, _Ch_traits>& + operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, + const sub_match<_Bi_iter>& __m) + { return __os << __m.str(); } + + // [7.10] Class template match_results + /** + * @brief The results of a match or search operation. + * + * A collection of character sequences representing the result of a regular + * expression match. Storage for the collection is allocated and freed as + * necessary by the member functions of class template match_results. + * + * This class satisfies the Sequence requirements, with the exception that + * only the operations defined for a const-qualified Sequence are supported. + * + * The sub_match object stored at index 0 represents sub-expression 0, i.e. + * the whole match. In this case the sub_match member matched is always true. + * The sub_match object stored at index n denotes what matched the marked + * sub-expression n within the matched expression. If the sub-expression n + * participated in a regular expression match then the sub_match member + * matched evaluates to true, and members first and second denote the range + * of characters [first, second) which formed that match. Otherwise matched + * is false, and members first and second point to the end of the sequence + * that was searched. + * + * @nosubgrouping + */ + template<typename _Bi_iter, + typename _Allocator = allocator<sub_match<_Bi_iter> > > + class match_results + : private std::vector<std::tr1::sub_match<_Bi_iter>, _Allocator> + { + private: + typedef std::vector<std::tr1::sub_match<_Bi_iter>, _Allocator> + _Base_type; + + public: + /** + * @name 10.? Public Types + */ + //@{ + typedef sub_match<_Bi_iter> value_type; + typedef typename _Allocator::const_reference const_reference; + typedef const_reference reference; + typedef typename _Base_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename iterator_traits<_Bi_iter>::difference_type + difference_type; + typedef typename _Allocator::size_type size_type; + typedef _Allocator allocator_type; + typedef typename iterator_traits<_Bi_iter>::value_type char_type; + typedef basic_string<char_type> string_type; + //@} + + public: + /** + * @name 10.1 Construction, Copying, and Destruction + */ + //@{ + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + explicit + match_results(const _Allocator& __a = _Allocator()) + : _Base_type(__a), _M_matched(false) + { } + + /** + * @brief Copy constructs a %match_results. + */ + match_results(const match_results& __rhs) + : _Base_type(__rhs), _M_matched(__rhs._M_matched), + _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix) + { } + + /** + * @brief Assigns rhs to *this. + */ + match_results& + operator=(const match_results& __rhs) + { + match_results __tmp(__rhs); + this->swap(__tmp); + return *this; + } + + /** + * @brief Destroys a %match_results object. + */ + ~match_results() + { } + + //@} + + /** + * @name 10.2 Size + */ + //@{ + + /** + * @brief Gets the number of matches and submatches. + * + * The number of matches for a given regular expression will be either 0 + * if there was no match or mark_count() + 1 if a match was successful. + * Some matches may be empty. + * + * @returns the number of matches found. + */ + size_type + size() const + { return _M_matched ? _Base_type::size() + 1 : 0; } + + //size_type + //max_size() const; + using _Base_type::max_size; + + /** + * @brief Indicates if the %match_results contains no results. + * @retval true The %match_results object is empty. + * @retval false The %match_results object is not empty. + */ + bool + empty() const + { return size() == 0; } + + //@} + + /** + * @name 10.3 Element Access + */ + //@{ + + /** + * @brief Gets the length of the indicated submatch. + * @param sub indicates the submatch. + * + * This function returns the length of the indicated submatch, or the + * length of the entire match if @p sub is zero (the default). + */ + difference_type + length(size_type __sub = 0) const + { return _M_matched ? this->str(__sub).length() : 0; } + + /** + * @brief Gets the offset of the beginning of the indicated submatch. + * @param sub indicates the submatch. + * + * This function returns the offset from the beginning of the target + * sequence to the beginning of the submatch, unless the value of @p sub + * is zero (the default), in which case this function returns the offset + * from the beginning of the target sequence to the beginning of the + * match. + */ + difference_type + position(size_type __sub = 0) const + { + return _M_matched ? std::distance(this->prefix().first, + (*this)[__sub].first) : 0; + } + + /** + * @brief Gets the match or submatch converted to a string type. + * @param sub indicates the submatch. + * + * This function gets the submatch (or match, if @p sub is zero) extracted + * from the target range and converted to the associated string type. + */ + string_type + str(size_type __sub = 0) const + { return _M_matched ? (*this)[__sub].str() : string_type(); } + + /** + * @brief Gets a %sub_match reference for the match or submatch. + * @param sub indicates the submatch. + * + * This function gets a reference to the indicated submatch, or the entire + * match if @p sub is zero. + * + * If @p sub >= size() then this function returns a %sub_match with a + * special value indicating no submatch. + */ + const_reference + operator[](size_type __sub) const + { return _Base_type::operator[](__sub); } + + /** + * @brief Gets a %sub_match representing the match prefix. + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the start of the target range and the + * start of the match. + */ + const_reference + prefix() const + { return _M_prefix; } + + /** + * @brief Gets a %sub_match representing the match suffix. + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the end of the match and the end of + * the target range. + */ + const_reference + suffix() const + { return _M_suffix; } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + begin() const + { return _Base_type::begin(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + cbegin() const + { return _Base_type::begin(); } +#endif + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + end() const + { return _Base_type::end(); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + cend() const + { return _Base_type::end(); } +#endif + + //@} + + /** + * @name 10.4 Formatting + * + * These functions perform formatted substitution of the matched character + * sequences into their target. The format specifiers and escape sequences + * accepted by these functions are determined by their @p flags parameter + * as documented above. + */ + //@{ + + /** + * @todo Implement this function. + */ + template<typename _Out_iter> + _Out_iter + format(_Out_iter __out, const string_type& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::format_default) const; + + /** + * @todo Implement this function. + */ + string_type + format(const string_type& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::format_default) const; + + //@} + + /** + * @name 10.5 Allocator + */ + //@{ + + /** + * @brief Gets a copy of the allocator. + */ + //allocator_type + //get_allocator() const; + using _Base_type::get_allocator; + + //@} + + /** + * @name 10.6 Swap + */ + //@{ + + /** + * @brief Swaps the contents of two match_results. + */ + void + swap(match_results& __that) + { + _Base_type::swap(__that); + std::swap(_M_matched, __that._M_matched); + std::swap(_M_prefix, __that._M_prefix); + std::swap(_M_suffix, __that._M_suffix); + } + //@} + + private: + bool _M_matched; + value_type _M_prefix; + value_type _M_suffix; + }; + + typedef match_results<const char*> cmatch; + typedef match_results<string::const_iterator> smatch; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef match_results<const wchar_t*> wcmatch; + typedef match_results<wstring::const_iterator> wsmatch; +#endif + + // match_results comparisons + /** + * @brief Compares two match_results for equality. + * @returns true if the two objects refer to the same match, + * false otherwise. + * @todo Implement this function. + */ + template<typename _Bi_iter, typename _Allocator> + inline bool + operator==(const match_results<_Bi_iter, _Allocator>& __m1, + const match_results<_Bi_iter, _Allocator>& __m2); + + /** + * @brief Compares two match_results for inequality. + * @returns true if the two objects do not refer to the same match, + * false otherwise. + */ + template<typename _Bi_iter, class _Allocator> + inline bool + operator!=(const match_results<_Bi_iter, _Allocator>& __m1, + const match_results<_Bi_iter, _Allocator>& __m2) + { return !(__m1 == __m2); } + + // [7.10.6] match_results swap + /** + * @brief Swaps two match results. + * @param lhs A match result. + * @param rhs A match result. + * + * The contents of the two match_results objects are swapped. + */ + template<typename _Bi_iter, typename _Allocator> + inline void + swap(match_results<_Bi_iter, _Allocator>& __lhs, + match_results<_Bi_iter, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + + // [7.11.2] Function template regex_match + /** + * @name Matching, Searching, and Replacing + */ + //@{ + + /** + * @brief Determines if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param first Beginning of the character sequence to match. + * @param last One-past-the-end of the character sequence to match. + * @param m The match results. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template<typename _Bi_iter, typename _Allocator, + typename _Ch_type, typename _Rx_traits> + bool + regex_match(_Bi_iter __first, _Bi_iter __last, + match_results<_Bi_iter, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param first Beginning of the character sequence to match. + * @param last One-past-the-end of the character sequence to match. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> + bool + regex_match(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_match(__first, __last, __what, __re, __flags); + } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param s The C-style null-terminated string to match. + * @param m The match results. + * @param re The regular expression. + * @param f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_type, typename _Allocator, typename _Rx_traits> + inline bool + regex_match(const _Ch_type* __s, + match_results<const _Ch_type*, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a string. + * + * @param s The string to match. + * @param m The match results. + * @param re The regular expression. + * @param flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_traits, typename _Ch_alloc, + typename _Allocator, typename _Ch_type, typename _Rx_traits> + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results<typename basic_string<_Ch_type, + _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param s The C-style null-terminated string to match. + * @param re The regular expression. + * @param f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_type, class _Rx_traits> + inline bool + regex_match(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a string. + * + * @param s [IN] The string to match. + * @param re [IN] The regular expression. + * @param flags [IN] Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_traits, typename _Str_allocator, + typename _Ch_type, typename _Rx_traits> + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __re, __flags); } + + // [7.11.3] Function template regex_search + /** + * Searches for a regular expression within a range. + * @param first [IN] The start of the string to search. + * @param last [IN] One-past-the-end of the string to search. + * @param m [OUT] The match results. + * @param re [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template<typename _Bi_iter, typename _Allocator, + typename _Ch_type, typename _Rx_traits> + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + match_results<_Bi_iter, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * Searches for a regular expression within a range. + * @param first [IN] The start of the string to search. + * @param last [IN] One-past-the-end of the string to search. + * @param re [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_search(__first, __last, __what, __re, __flags); + } + + /** + * @brief Searches for a regular expression within a C-string. + * @param s [IN] A C-string to search for the regex. + * @param m [OUT] The set of regex matches. + * @param e [IN] The regex to search for in @p s. + * @param f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_type, class _Allocator, class _Rx_traits> + inline bool + regex_search(const _Ch_type* __s, + match_results<const _Ch_type*, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } + + /** + * @brief Searches for a regular expression within a C-string. + * @param s [IN] The C-string to search. + * @param e [IN] The regular expression to search for. + * @param f [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_type, typename _Rx_traits> + inline bool + regex_search(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } + + /** + * @brief Searches for a regular expression within a string. + * @param s [IN] The string to search. + * @param e [IN] The regular expression to search for. + * @param flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * @doctodo + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_traits, typename _String_allocator, + typename _Ch_type, typename _Rx_traits> + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, + _String_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __e, __flags); } + + /** + * @brief Searches for a regular expression within a string. + * @param s [IN] A C++ string to search for the regex. + * @param m [OUT] The set of regex matches. + * @param e [IN] The regex to search for in @p s. + * @param f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template<typename _Ch_traits, typename _Ch_alloc, + typename _Allocator, typename _Ch_type, + typename _Rx_traits> + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results<typename basic_string<_Ch_type, + _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } + + // tr1 [7.11.4] std [28.11.4] Function template regex_replace + /** + * @doctodo + * @param out + * @param first + * @param last + * @param e + * @param fmt + * @param flags + * + * @returns out + * @throws an exception of type regex_error. + * + * @todo Implement this function. + */ + template<typename _Out_iter, typename _Bi_iter, + typename _Rx_traits, typename _Ch_type> + inline _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * @doctodo + * @param s + * @param e + * @param fmt + * @param flags + * + * @returns a copy of string @p s with replacements. + * + * @throws an exception of type regex_error. + */ + template<typename _Rx_traits, typename _Ch_type> + inline basic_string<_Ch_type> + regex_replace(const basic_string<_Ch_type>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + std::string __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + //@} + + // tr1 [7.12.1] std [28.12] Class template regex_iterator + /** + * An iterator adaptor that will provide repeated calls of regex_search over + * a range until no more matches remain. + */ + template<typename _Bi_iter, + typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef match_results<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Provides a singular iterator, useful for indicating + * one-past-the-end of a range. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(); + + /** + * Constructs a %regex_iterator... + * @param a [IN] The start of a text range to search. + * @param b [IN] One-past-the-end of the text range to search. + * @param re [IN] The regular expression to match. + * @param m [IN] Policy flags for match rules. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Copy constructs a %regex_iterator. + * @todo Implement this function. + * @doctodo + */ + regex_iterator(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator& + operator=(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + bool + operator==(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + bool + operator!=(const regex_iterator& __rhs); + + /** + * @todo Implement this function. + * @doctodo + */ + const value_type& + operator*(); + + /** + * @todo Implement this function. + * @doctodo + */ + const value_type* + operator->(); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator& + operator++(); + + /** + * @todo Implement this function. + * @doctodo + */ + regex_iterator + operator++(int); + + private: + // these members are shown for exposition only: + _Bi_iter begin; + _Bi_iter end; + const regex_type* pregex; + regex_constants::match_flag_type flags; + match_results<_Bi_iter> match; + }; + + typedef regex_iterator<const char*> cregex_iterator; + typedef regex_iterator<string::const_iterator> sregex_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef regex_iterator<const wchar_t*> wcregex_iterator; + typedef regex_iterator<wstring::const_iterator> wsregex_iterator; +#endif + + // [7.12.2] Class template regex_token_iterator + /** + * Iterates over submatches in a range (or @a splits a text string). + * + * The purpose of this iterator is to enumerate all, or all specified, + * matches of a regular expression within a text range. The dereferenced + * value of an iterator of this class is a std::tr1::sub_match object. + */ + template<typename _Bi_iter, + typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_token_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef sub_match<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Default constructs a %regex_token_iterator. + * @todo Implement this function. + * + * A default-constructed %regex_token_iterator is a singular iterator + * that will compare equal to the one-past-the-end value for any + * iterator of the same type. + */ + regex_token_iterator(); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatch [IN] Which submatch to return. There are some + * special values for this parameter: + * - -1 each enumerated subexpression does NOT + * match the regular expression (aka field + * splitting) + * - 0 the entire string matching the + * subexpression is returned for each match + * within the text. + * - >0 enumerates only the indicated + * subexpression from a match within the text. + * @param m [IN] Policy flags for match rules. + * + * @todo Implement this function. + * @doctodo + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + int __submatch = 0, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param m [IN] Policy flags for match rules. + * + * @todo Implement this function. + * @doctodo + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const std::vector<int>& __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * Constructs a %regex_token_iterator... + * @param a [IN] The start of the text to search. + * @param b [IN] One-past-the-end of the text to search. + * @param re [IN] The regular expression to search for. + * @param submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param m [IN] Policy flags for match rules. + + * @todo Implement this function. + * @doctodo + */ + template<std::size_t _Nm> + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const int (&__submatches)[_Nm], + regex_constants::match_flag_type __m + = regex_constants::match_default); + + /** + * @brief Copy constructs a %regex_token_iterator. + * @param rhs [IN] A %regex_token_iterator to copy. + * @todo Implement this function. + */ + regex_token_iterator(const regex_token_iterator& __rhs); + + /** + * @brief Assigns a %regex_token_iterator to another. + * @param rhs [IN] A %regex_token_iterator to copy. + * @todo Implement this function. + */ + regex_token_iterator& + operator=(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for equality. + * @todo Implement this function. + */ + bool + operator==(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for inequality. + * @todo Implement this function. + */ + bool + operator!=(const regex_token_iterator& __rhs); + + /** + * @brief Dereferences a %regex_token_iterator. + * @todo Implement this function. + */ + const value_type& + operator*(); + + /** + * @brief Selects a %regex_token_iterator member. + * @todo Implement this function. + */ + const value_type* + operator->(); + + /** + * @brief Increments a %regex_token_iterator. + * @todo Implement this function. + */ + regex_token_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_token_iterator. + * @todo Implement this function. + */ + regex_token_iterator + operator++(int); + + private: // data members for exposition only: + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator; + + position_iterator __position; + const value_type* __result; + value_type __suffix; + std::size_t __n; + std::vector<int> __subs; + }; + + /** @brief Token iterator for C-style NULL-terminated strings. */ + typedef regex_token_iterator<const char*> cregex_token_iterator; + /** @brief Token iterator for standard strings. */ + typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Token iterator for C-style NULL-terminated wide strings. */ + typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; + /** @brief Token iterator for standard wide-character strings. */ + typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; #endif + + //@} +} +} #endif // _GLIBCXX_TR1_REGEX diff --git a/libstdc++-v3/include/tr1/shared_ptr.h b/libstdc++-v3/include/tr1/shared_ptr.h index f504e083c52..947ee7f32c1 100644 --- a/libstdc++-v3/include/tr1/shared_ptr.h +++ b/libstdc++-v3/include/tr1/shared_ptr.h @@ -49,14 +49,205 @@ #ifndef _TR1_SHARED_PTR_H #define _TR1_SHARED_PTR_H 1 -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - namespace std { namespace tr1 { + /** + * @brief Exception possibly thrown by @c shared_ptr. + * @ingroup exceptions + */ + class bad_weak_ptr : public std::exception + { + public: + virtual char const* + what() const throw() + { return "tr1::bad_weak_ptr"; } + }; + + // Substitute for bad_weak_ptr object in the case of -fno-exceptions. + inline void + __throw_bad_weak_ptr() + { +#if __EXCEPTIONS + throw bad_weak_ptr(); +#else + __builtin_abort(); +#endif + } + + using __gnu_cxx::_Lock_policy; + using __gnu_cxx::__default_lock_policy; + using __gnu_cxx::_S_single; + using __gnu_cxx::_S_mutex; + using __gnu_cxx::_S_atomic; + + // Empty helper class except when the template argument is _S_mutex. + template<_Lock_policy _Lp> + class _Mutex_base + { + protected: + // The atomic policy uses fully-fenced builtins, single doesn't care. + enum { _S_need_barriers = 0 }; + }; + + template<> + class _Mutex_base<_S_mutex> + : public __gnu_cxx::__mutex + { + protected: + // This policy is used when atomic builtins are not available. + // The replacement atomic operations might not have the necessary + // memory barriers. + enum { _S_need_barriers = 1 }; + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class _Sp_counted_base + : public _Mutex_base<_Lp> + { + public: + _Sp_counted_base() + : _M_use_count(1), _M_weak_count(1) { } + + virtual + ~_Sp_counted_base() // nothrow + { } + + // Called when _M_use_count drops to zero, to release the resources + // managed by *this. + virtual void + _M_dispose() = 0; // nothrow + + // Called when _M_weak_count drops to zero. + virtual void + _M_destroy() // nothrow + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) = 0; + + void + _M_add_ref_copy() + { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } + + void + _M_add_ref_lock(); + + void + _M_release() // nothrow + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); + _M_dispose(); + // There must be a memory barrier between dispose() and destroy() + // to ensure that the effects of dispose() are observed in the + // thread that runs destroy(). + // See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html + if (_Mutex_base<_Lp>::_S_need_barriers) + { + _GLIBCXX_READ_MEM_BARRIER; + _GLIBCXX_WRITE_MEM_BARRIER; + } + + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, + -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + _M_destroy(); + } + } + } + + void + _M_weak_add_ref() // nothrow + { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } + + void + _M_weak_release() // nothrow + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + if (_Mutex_base<_Lp>::_S_need_barriers) + { + // See _M_release(), + // destroy() must observe results of dispose() + _GLIBCXX_READ_MEM_BARRIER; + _GLIBCXX_WRITE_MEM_BARRIER; + } + _M_destroy(); + } + } + + long + _M_get_use_count() const // nothrow + { + // No memory barrier is used here so there is no synchronization + // with other threads. + return const_cast<const volatile _Atomic_word&>(_M_use_count); + } + + private: + _Sp_counted_base(_Sp_counted_base const&); + _Sp_counted_base& operator=(_Sp_counted_base const&); + + _Atomic_word _M_use_count; // #shared + _Atomic_word _M_weak_count; // #weak + (#shared != 0) + }; + + template<> + inline void + _Sp_counted_base<_S_single>:: + _M_add_ref_lock() + { + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + __throw_bad_weak_ptr(); + } + } + + template<> + inline void + _Sp_counted_base<_S_mutex>:: + _M_add_ref_lock() + { + __gnu_cxx::__scoped_lock sentry(*this); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + __throw_bad_weak_ptr(); + } + } + + template<> + inline void + _Sp_counted_base<_S_atomic>:: + _M_add_ref_lock() + { + // Perform lock-free add-if-not-zero operation. + _Atomic_word __count; + do + { + __count = _M_use_count; + if (__count == 0) + __throw_bad_weak_ptr(); + + // Replace the current counter value with the old value + 1, as + // long as it's not changed meanwhile. + } + while (!__sync_bool_compare_and_swap(&_M_use_count, __count, + __count + 1)); + } + template<typename _Ptr, typename _Deleter, _Lock_policy _Lp> class _Sp_counted_base_impl : public _Sp_counted_base<_Lp> diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index 33083ff9c73..88aae7ad8b1 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -32,35 +32,467 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <bits/c++config.h> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/type_traits> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/type_traits> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif - namespace std { namespace tr1 { -#define _DEFINE_SPEC(_Trait, _Type) \ - template<> \ - struct _Trait<_Type> \ + /** + * @defgroup metaprogramming Type Traits + * @ingroup utilities + * + * Compile time type transformation and information. + * @{ + */ + + struct __sfinae_types + { + typedef char __one; + typedef struct { char __arr[2]; } __two; + }; + +#define _DEFINE_SPEC_0_HELPER \ + template<> + +#define _DEFINE_SPEC_1_HELPER \ + template<typename _Tp> + +#define _DEFINE_SPEC_2_HELPER \ + template<typename _Tp, typename _Cp> + +#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \ + _DEFINE_SPEC_##_Order##_HELPER \ + struct _Trait<_Type> \ + : public integral_constant<bool, _Value> { }; + + // helper classes [4.3]. + + /// integral_constant + template<typename _Tp, _Tp __v> + struct integral_constant + { + static const _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + }; + + /// typedef for true_type + typedef integral_constant<bool, true> true_type; + + /// typedef for false_type + typedef integral_constant<bool, false> false_type; + + template<typename _Tp, _Tp __v> + const _Tp integral_constant<_Tp, __v>::value; + + /// remove_cv + template<typename> + struct remove_cv; + + template<typename> + struct __is_void_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_void_helper, void, true) + + // primary type categories [4.5.1]. + + /// is_void + template<typename _Tp> + struct is_void + : public integral_constant<bool, (__is_void_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_integral_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_integral_helper, bool, true) + _DEFINE_SPEC(0, __is_integral_helper, char, true) + _DEFINE_SPEC(0, __is_integral_helper, signed char, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true) +#ifdef _GLIBCXX_USE_WCHAR_T + _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true) +#endif + _DEFINE_SPEC(0, __is_integral_helper, short, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true) + _DEFINE_SPEC(0, __is_integral_helper, int, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned int, true) + _DEFINE_SPEC(0, __is_integral_helper, long, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned long, true) + _DEFINE_SPEC(0, __is_integral_helper, long long, true) + _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true) + + /// is_integral + template<typename _Tp> + struct is_integral + : public integral_constant<bool, (__is_integral_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_floating_point_helper + : public false_type { }; + _DEFINE_SPEC(0, __is_floating_point_helper, float, true) + _DEFINE_SPEC(0, __is_floating_point_helper, double, true) + _DEFINE_SPEC(0, __is_floating_point_helper, long double, true) + + /// is_floating_point + template<typename _Tp> + struct is_floating_point + : public integral_constant<bool, (__is_floating_point_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + /// is_array + template<typename> + struct is_array + : public false_type { }; + + template<typename _Tp, std::size_t _Size> + struct is_array<_Tp[_Size]> + : public true_type { }; + + template<typename _Tp> + struct is_array<_Tp[]> + : public true_type { }; + + template<typename> + struct __is_pointer_helper + : public false_type { }; + _DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true) + + /// is_pointer + template<typename _Tp> + struct is_pointer + : public integral_constant<bool, (__is_pointer_helper<typename + remove_cv<_Tp>::type>::value)> + { }; + + /// is_reference + template<typename _Tp> + struct is_reference; + + /// is_function + template<typename _Tp> + struct is_function; + + template<typename> + struct __is_member_object_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*, + !is_function<_Tp>::value) + + /// is_member_object_pointer + template<typename _Tp> + struct is_member_object_pointer + : public integral_constant<bool, (__is_member_object_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + template<typename> + struct __is_member_function_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*, + is_function<_Tp>::value) + + /// is_member_function_pointer + template<typename _Tp> + struct is_member_function_pointer + : public integral_constant<bool, (__is_member_function_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + /// is_enum + template<typename _Tp> + struct is_enum + : public integral_constant<bool, __is_enum(_Tp)> + { }; + + /// is_union + template<typename _Tp> + struct is_union + : public integral_constant<bool, __is_union(_Tp)> + { }; + + /// is_class + template<typename _Tp> + struct is_class + : public integral_constant<bool, __is_class(_Tp)> + { }; + + /// is_function + template<typename> + struct is_function + : public false_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...)> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......)> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) const> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) const> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes...) const volatile> + : public true_type { }; + template<typename _Res, typename... _ArgTypes> + struct is_function<_Res(_ArgTypes......) const volatile> + : public true_type { }; + + // composite type traits [4.5.2]. + + /// is_arithmetic + template<typename _Tp> + struct is_arithmetic + : public integral_constant<bool, (is_integral<_Tp>::value + || is_floating_point<_Tp>::value)> + { }; + + /// is_fundamental + template<typename _Tp> + struct is_fundamental + : public integral_constant<bool, (is_arithmetic<_Tp>::value + || is_void<_Tp>::value)> + { }; + + /// is_object + template<typename _Tp> + struct is_object + : public integral_constant<bool, !(is_function<_Tp>::value + || is_reference<_Tp>::value + || is_void<_Tp>::value)> + { }; + + /// is_member_pointer + template<typename _Tp> + struct is_member_pointer; + + /// is_scalar + template<typename _Tp> + struct is_scalar + : public integral_constant<bool, (is_arithmetic<_Tp>::value + || is_enum<_Tp>::value + || is_pointer<_Tp>::value + || is_member_pointer<_Tp>::value)> + { }; + + /// is_compound + template<typename _Tp> + struct is_compound + : public integral_constant<bool, !is_fundamental<_Tp>::value> { }; + + /// is_member_pointer + template<typename _Tp> + struct __is_member_pointer_helper + : public false_type { }; + _DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true) + + template<typename _Tp> + struct is_member_pointer + : public integral_constant<bool, (__is_member_pointer_helper< + typename remove_cv<_Tp>::type>::value)> + { }; + + // type properties [4.5.3]. + /// is_const + template<typename> + struct is_const + : public false_type { }; + + template<typename _Tp> + struct is_const<_Tp const> + : public true_type { }; + + /// is_volatile + template<typename> + struct is_volatile + : public false_type { }; + + template<typename _Tp> + struct is_volatile<_Tp volatile> + : public true_type { }; + + /// is_empty + template<typename _Tp> + struct is_empty + : public integral_constant<bool, __is_empty(_Tp)> + { }; + + /// is_polymorphic + template<typename _Tp> + struct is_polymorphic + : public integral_constant<bool, __is_polymorphic(_Tp)> + { }; + + /// is_abstract + template<typename _Tp> + struct is_abstract + : public integral_constant<bool, __is_abstract(_Tp)> + { }; + + /// has_virtual_destructor + template<typename _Tp> + struct has_virtual_destructor + : public integral_constant<bool, __has_virtual_destructor(_Tp)> + { }; + + /// alignment_of + template<typename _Tp> + struct alignment_of + : public integral_constant<std::size_t, __alignof__(_Tp)> { }; + + /// rank + template<typename> + struct rank + : public integral_constant<std::size_t, 0> { }; + + template<typename _Tp, std::size_t _Size> + struct rank<_Tp[_Size]> + : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; + + template<typename _Tp> + struct rank<_Tp[]> + : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; + + /// extent + template<typename, unsigned _Uint = 0> + struct extent + : public integral_constant<std::size_t, 0> { }; + + template<typename _Tp, unsigned _Uint, std::size_t _Size> + struct extent<_Tp[_Size], _Uint> + : public integral_constant<std::size_t, + _Uint == 0 ? _Size : extent<_Tp, + _Uint - 1>::value> + { }; + + template<typename _Tp, unsigned _Uint> + struct extent<_Tp[], _Uint> + : public integral_constant<std::size_t, + _Uint == 0 ? 0 : extent<_Tp, + _Uint - 1>::value> + { }; + + // relationships between types [4.6]. + + /// is_same + template<typename, typename> + struct is_same + : public false_type { }; + + template<typename _Tp> + struct is_same<_Tp, _Tp> : public true_type { }; + // const-volatile modifications [4.7.1]. + + /// remove_const + template<typename _Tp> + struct remove_const + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_const<_Tp const> + { typedef _Tp type; }; + + /// remove_volatile + template<typename _Tp> + struct remove_volatile + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_volatile<_Tp volatile> + { typedef _Tp type; }; + + /// remove_cv + template<typename _Tp> + struct remove_cv + { + typedef typename + remove_const<typename remove_volatile<_Tp>::type>::type type; + }; + + /// add_const + template<typename _Tp> + struct add_const + { typedef _Tp const type; }; + + /// add_volatile + template<typename _Tp> + struct add_volatile + { typedef _Tp volatile type; }; + + /// add_cv + template<typename _Tp> + struct add_cv + { + typedef typename + add_const<typename add_volatile<_Tp>::type>::type type; + }; + + // array modifications [4.7.3]. + + /// remove_extent + template<typename _Tp> + struct remove_extent + { typedef _Tp type; }; + + template<typename _Tp, std::size_t _Size> + struct remove_extent<_Tp[_Size]> + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_extent<_Tp[]> + { typedef _Tp type; }; + + /// remove_all_extents + template<typename _Tp> + struct remove_all_extents + { typedef _Tp type; }; + + template<typename _Tp, std::size_t _Size> + struct remove_all_extents<_Tp[_Size]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + template<typename _Tp> + struct remove_all_extents<_Tp[]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + // pointer modifications [4.7.4]. + + template<typename _Tp, typename> + struct __remove_pointer_helper + { typedef _Tp type; }; + + template<typename _Tp, typename _Up> + struct __remove_pointer_helper<_Tp, _Up*> + { typedef _Up type; }; + + /// remove_pointer + template<typename _Tp> + struct remove_pointer + : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> + { }; + + template<typename> + struct remove_reference; + + /// add_pointer + template<typename _Tp> + struct add_pointer + { typedef typename remove_reference<_Tp>::type* type; }; + template<typename> struct is_reference : public false_type { }; @@ -112,11 +544,11 @@ namespace tr1 template<typename> struct __is_signed_helper : public false_type { }; - _DEFINE_SPEC(__is_signed_helper, signed char) - _DEFINE_SPEC(__is_signed_helper, short) - _DEFINE_SPEC(__is_signed_helper, int) - _DEFINE_SPEC(__is_signed_helper, long) - _DEFINE_SPEC(__is_signed_helper, long long) + _DEFINE_SPEC(0, __is_signed_helper, signed char, true) + _DEFINE_SPEC(0, __is_signed_helper, short, true) + _DEFINE_SPEC(0, __is_signed_helper, int, true) + _DEFINE_SPEC(0, __is_signed_helper, long, true) + _DEFINE_SPEC(0, __is_signed_helper, long long, true) template<typename _Tp> struct is_signed @@ -127,11 +559,11 @@ namespace tr1 template<typename> struct __is_unsigned_helper : public false_type { }; - _DEFINE_SPEC(__is_unsigned_helper, unsigned char) - _DEFINE_SPEC(__is_unsigned_helper, unsigned short) - _DEFINE_SPEC(__is_unsigned_helper, unsigned int) - _DEFINE_SPEC(__is_unsigned_helper, unsigned long) - _DEFINE_SPEC(__is_unsigned_helper, unsigned long long) + _DEFINE_SPEC(0, __is_unsigned_helper, unsigned char, true) + _DEFINE_SPEC(0, __is_unsigned_helper, unsigned short, true) + _DEFINE_SPEC(0, __is_unsigned_helper, unsigned int, true) + _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long, true) + _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long long, true) template<typename _Tp> struct is_unsigned @@ -243,6 +675,9 @@ namespace tr1 }; }; +#undef _DEFINE_SPEC_0_HELPER +#undef _DEFINE_SPEC_1_HELPER +#undef _DEFINE_SPEC_2_HELPER #undef _DEFINE_SPEC } } diff --git a/libstdc++-v3/include/tr1/utility b/libstdc++-v3/include/tr1/utility index 0aac2b2824f..04ff67a3f8f 100644 --- a/libstdc++-v3/include/tr1/utility +++ b/libstdc++-v3/include/tr1/utility @@ -1,6 +1,7 @@ // TR1 utility -*- C++ -*- -// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006, 2007, 2008. 2009, 2010 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,26 +32,74 @@ #pragma GCC system_header -#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) -# error TR1 header cannot be included from C++0x header -#endif - #include <bits/c++config.h> #include <bits/stl_relops.h> #include <bits/stl_pair.h> -#if defined(_GLIBCXX_INCLUDE_AS_TR1) -# include <tr1_impl/utility> -#else -# define _GLIBCXX_INCLUDE_AS_TR1 -# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { -# define _GLIBCXX_END_NAMESPACE_TR1 } -# define _GLIBCXX_TR1 tr1:: -# include <tr1_impl/utility> -# undef _GLIBCXX_TR1 -# undef _GLIBCXX_END_NAMESPACE_TR1 -# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 -# undef _GLIBCXX_INCLUDE_AS_TR1 -#endif +namespace std +{ +namespace tr1 +{ + template<class _Tp> + class tuple_size; + + template<int _Int, class _Tp> + class tuple_element; + + // Various functions which give std::pair a tuple-like interface. + template<class _Tp1, class _Tp2> + struct tuple_size<std::pair<_Tp1, _Tp2> > + { static const int value = 2; }; + + template<class _Tp1, class _Tp2> + const int + tuple_size<std::pair<_Tp1, _Tp2> >::value; + + template<class _Tp1, class _Tp2> + struct tuple_element<0, std::pair<_Tp1, _Tp2> > + { typedef _Tp1 type; }; + + template<class _Tp1, class _Tp2> + struct tuple_element<1, std::pair<_Tp1, _Tp2> > + { typedef _Tp2 type; }; + + template<int _Int> + struct __pair_get; + + template<> + struct __pair_get<0> + { + template<typename _Tp1, typename _Tp2> + static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair) + { return __pair.first; } + + template<typename _Tp1, typename _Tp2> + static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair) + { return __pair.first; } + }; + + template<> + struct __pair_get<1> + { + template<typename _Tp1, typename _Tp2> + static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair) + { return __pair.second; } + + template<typename _Tp1, typename _Tp2> + static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair) + { return __pair.second; } + }; + + template<int _Int, class _Tp1, class _Tp2> + inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& + get(std::pair<_Tp1, _Tp2>& __in) + { return __pair_get<_Int>::__get(__in); } + + template<int _Int, class _Tp1, class _Tp2> + inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& + get(const std::pair<_Tp1, _Tp2>& __in) + { return __pair_get<_Int>::__const_get(__in); } +} +} #endif // _GLIBCXX_TR1_UTILITY diff --git a/libstdc++-v3/include/tr1_impl/array b/libstdc++-v3/include/tr1_impl/array deleted file mode 100644 index a4c20edf726..00000000000 --- a/libstdc++-v3/include/tr1_impl/array +++ /dev/null @@ -1,291 +0,0 @@ -// class template array -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/array - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - /** - * @brief A standard container for storing a fixed size sequence of elements. - * - * @ingroup sequences - * - * Meets the requirements of a <a href="tables.html#65">container</a>, a - * <a href="tables.html#66">reversible container</a>, and a - * <a href="tables.html#67">sequence</a>. - * - * Sets support random access iterators. - * - * @param Tp Type of element. Required to be a complete type. - * @param N Number of elements. - */ - template<typename _Tp, std::size_t _Nm> - struct array - { - typedef _Tp value_type; -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - typedef _Tp* pointer; - typedef const _Tp* const_pointer; -#endif - typedef value_type& reference; - typedef const value_type& const_reference; - typedef value_type* iterator; - typedef const value_type* const_iterator; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - // Support for zero-sized arrays mandatory. - value_type _M_instance[_Nm ? _Nm : 1]; - - // No explicit construct/copy/destroy for aggregate type. - - void -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - // DR 776. - fill(const value_type& __u) -#else - assign(const value_type& __u) -#endif - { std::fill_n(begin(), size(), __u); } - - void - swap(array& __other) - { std::swap_ranges(begin(), end(), __other.begin()); } - - // Iterators. - iterator - begin() - { return iterator(std::__addressof(_M_instance[0])); } - - const_iterator - begin() const - { return const_iterator(std::__addressof(_M_instance[0])); } - - iterator - end() - { return iterator(std::__addressof(_M_instance[_Nm])); } - - const_iterator - end() const - { return const_iterator(std::__addressof(_M_instance[_Nm])); } - - 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()); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - const_iterator - cbegin() const - { return const_iterator(std::__addressof(_M_instance[0])); } - - const_iterator - cend() const - { return const_iterator(std::__addressof(_M_instance[_Nm])); } - - const_reverse_iterator - crbegin() const - { return const_reverse_iterator(end()); } - - const_reverse_iterator - crend() const - { return const_reverse_iterator(begin()); } -#endif - - // Capacity. - _GLIBCXX_CONSTEXPR size_type - size() const { return _Nm; } - - _GLIBCXX_CONSTEXPR size_type - max_size() const { return _Nm; } - - _GLIBCXX_CONSTEXPR bool - empty() const { return size() == 0; } - - // Element access. - reference - operator[](size_type __n) - { return _M_instance[__n]; } - - const_reference - operator[](size_type __n) const - { return _M_instance[__n]; } - - reference - at(size_type __n) - { - if (__n >= _Nm) - std::__throw_out_of_range(__N("array::at")); - return _M_instance[__n]; - } - - const_reference - at(size_type __n) const - { - if (__n >= _Nm) - std::__throw_out_of_range(__N("array::at")); - return _M_instance[__n]; - } - - reference - front() - { return *begin(); } - - const_reference - front() const - { return *begin(); } - - reference - back() - { return _Nm ? *(end() - 1) : *end(); } - - const_reference - back() const - { return _Nm ? *(end() - 1) : *end(); } - - _Tp* - data() - { return std::__addressof(_M_instance[0]); } - - const _Tp* - data() const - { return std::__addressof(_M_instance[0]); } - }; - - // Array comparisons. - template<typename _Tp, std::size_t _Nm> - inline bool - operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) - { return std::equal(__one.begin(), __one.end(), __two.begin()); } - - template<typename _Tp, std::size_t _Nm> - inline bool - operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) - { return !(__one == __two); } - - template<typename _Tp, std::size_t _Nm> - inline bool - operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) - { - return std::lexicographical_compare(__a.begin(), __a.end(), - __b.begin(), __b.end()); - } - - template<typename _Tp, std::size_t _Nm> - inline bool - operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) - { return __two < __one; } - - template<typename _Tp, std::size_t _Nm> - inline bool - operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) - { return !(__one > __two); } - - template<typename _Tp, std::size_t _Nm> - inline bool - operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) - { return !(__one < __two); } - - // Specialized algorithms [6.2.2.2]. - template<typename _Tp, std::size_t _Nm> - inline void - swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) - { __one.swap(__two); } - - // Tuple interface to class template array [6.2.2.5]. - - /// tuple_size - template<typename _Tp> - class tuple_size; - - /// tuple_element -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, typename _Tp> -#else - template<int _Int, typename _Tp> -#endif - class tuple_element; - - template<typename _Tp, std::size_t _Nm> - struct tuple_size<array<_Tp, _Nm> > -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - { static const std::size_t value = _Nm; }; -#else - { static const int value = _Nm; }; -#endif - - template<typename _Tp, std::size_t _Nm> -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - const std::size_t -#else - const int -#endif - tuple_size<array<_Tp, _Nm> >::value; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, typename _Tp, std::size_t _Nm> -#else - template<int _Int, typename _Tp, std::size_t _Nm> -#endif - struct tuple_element<_Int, array<_Tp, _Nm> > - { typedef _Tp type; }; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, typename _Tp, std::size_t _Nm> -#else - template<int _Int, typename _Tp, std::size_t _Nm> -#endif - inline _Tp& - get(array<_Tp, _Nm>& __arr) - { return __arr[_Int]; } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, typename _Tp, std::size_t _Nm> -#else - template<int _Int, typename _Tp, std::size_t _Nm> -#endif - inline const _Tp& - get(const array<_Tp, _Nm>& __arr) - { return __arr[_Int]; } - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/boost_sp_counted_base.h b/libstdc++-v3/include/tr1_impl/boost_sp_counted_base.h deleted file mode 100644 index 11a2d052dfc..00000000000 --- a/libstdc++-v3/include/tr1_impl/boost_sp_counted_base.h +++ /dev/null @@ -1,254 +0,0 @@ -// <tr1_impl/boost_sp_counted_base.h> -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -// shared_count.hpp -// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. - -// shared_ptr.hpp -// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. -// Copyright (C) 2001, 2002, 2003 Peter Dimov - -// weak_ptr.hpp -// Copyright (C) 2001, 2002, 2003 Peter Dimov - -// enable_shared_from_this.hpp -// Copyright (C) 2002 Peter Dimov - -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// GCC Note: based on version 1.32.0 of the Boost library. - -/** @file tr1_impl/boost_sp_counted_base.h - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - /** - * @brief Exception possibly thrown by @c shared_ptr. - * @ingroup exceptions - */ - class bad_weak_ptr : public std::exception - { - public: - virtual char const* - what() const throw() -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - { return "std::bad_weak_ptr"; } -#else - { return "tr1::bad_weak_ptr"; } -#endif - }; - - // Substitute for bad_weak_ptr object in the case of -fno-exceptions. - inline void - __throw_bad_weak_ptr() - { -#if __EXCEPTIONS - throw bad_weak_ptr(); -#else - __builtin_abort(); -#endif - } - - using __gnu_cxx::_Lock_policy; - using __gnu_cxx::__default_lock_policy; - using __gnu_cxx::_S_single; - using __gnu_cxx::_S_mutex; - using __gnu_cxx::_S_atomic; - - // Empty helper class except when the template argument is _S_mutex. - template<_Lock_policy _Lp> - class _Mutex_base - { - protected: - // The atomic policy uses fully-fenced builtins, single doesn't care. - enum { _S_need_barriers = 0 }; - }; - - template<> - class _Mutex_base<_S_mutex> - : public __gnu_cxx::__mutex - { - protected: - // This policy is used when atomic builtins are not available. - // The replacement atomic operations might not have the necessary - // memory barriers. - enum { _S_need_barriers = 1 }; - }; - - template<_Lock_policy _Lp = __default_lock_policy> - class _Sp_counted_base - : public _Mutex_base<_Lp> - { - public: - _Sp_counted_base() - : _M_use_count(1), _M_weak_count(1) { } - - virtual - ~_Sp_counted_base() // nothrow - { } - - // Called when _M_use_count drops to zero, to release the resources - // managed by *this. - virtual void - _M_dispose() = 0; // nothrow - - // Called when _M_weak_count drops to zero. - virtual void - _M_destroy() // nothrow - { delete this; } - - virtual void* - _M_get_deleter(const std::type_info&) = 0; - - void - _M_add_ref_copy() - { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } - - void - _M_add_ref_lock(); - - void - _M_release() // nothrow - { - // Be race-detector-friendly. For more info see bits/c++config. - _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); - if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) - { - _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); - _M_dispose(); - // There must be a memory barrier between dispose() and destroy() - // to ensure that the effects of dispose() are observed in the - // thread that runs destroy(). - // See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html - if (_Mutex_base<_Lp>::_S_need_barriers) - { - _GLIBCXX_READ_MEM_BARRIER; - _GLIBCXX_WRITE_MEM_BARRIER; - } - - // Be race-detector-friendly. For more info see bits/c++config. - _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); - if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, - -1) == 1) - { - _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); - _M_destroy(); - } - } - } - - void - _M_weak_add_ref() // nothrow - { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } - - void - _M_weak_release() // nothrow - { - // Be race-detector-friendly. For more info see bits/c++config. - _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); - if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) - { - _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); - if (_Mutex_base<_Lp>::_S_need_barriers) - { - // See _M_release(), - // destroy() must observe results of dispose() - _GLIBCXX_READ_MEM_BARRIER; - _GLIBCXX_WRITE_MEM_BARRIER; - } - _M_destroy(); - } - } - - long - _M_get_use_count() const // nothrow - { - // No memory barrier is used here so there is no synchronization - // with other threads. - return const_cast<const volatile _Atomic_word&>(_M_use_count); - } - - private: - _Sp_counted_base(_Sp_counted_base const&); - _Sp_counted_base& operator=(_Sp_counted_base const&); - - _Atomic_word _M_use_count; // #shared - _Atomic_word _M_weak_count; // #weak + (#shared != 0) - }; - - template<> - inline void - _Sp_counted_base<_S_single>:: - _M_add_ref_lock() - { - if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) - { - _M_use_count = 0; - __throw_bad_weak_ptr(); - } - } - - template<> - inline void - _Sp_counted_base<_S_mutex>:: - _M_add_ref_lock() - { - __gnu_cxx::__scoped_lock sentry(*this); - if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) - { - _M_use_count = 0; - __throw_bad_weak_ptr(); - } - } - - template<> - inline void - _Sp_counted_base<_S_atomic>:: - _M_add_ref_lock() - { - // Perform lock-free add-if-not-zero operation. - _Atomic_word __count; - do - { - __count = _M_use_count; - if (__count == 0) - __throw_bad_weak_ptr(); - - // Replace the current counter value with the old value + 1, as - // long as it's not changed meanwhile. - } - while (!__sync_bool_compare_and_swap(&_M_use_count, __count, - __count + 1)); - } - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/cctype b/libstdc++-v3/include/tr1_impl/cctype deleted file mode 100644 index c76d38c8782..00000000000 --- a/libstdc++-v3/include/tr1_impl/cctype +++ /dev/null @@ -1,43 +0,0 @@ -// TR1 cctype -*- C++ -*- - -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cctype - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_C99_CTYPE_TR1 - -#undef isblank - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - using ::isblank; - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cfenv b/libstdc++-v3/include/tr1_impl/cfenv deleted file mode 100644 index 3078c7de64a..00000000000 --- a/libstdc++-v3/include/tr1_impl/cfenv +++ /dev/null @@ -1,70 +0,0 @@ -// TR1 cfenv -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cfenv - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_C99_FENV_TR1 - -#undef feclearexcept -#undef fegetexceptflag -#undef feraiseexcept -#undef fesetexceptflag -#undef fetestexcept -#undef fegetround -#undef fesetround -#undef fegetenv -#undef feholdexcept -#undef fesetenv -#undef feupdateenv - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - // types - using ::fenv_t; - using ::fexcept_t; - - // functions - using ::feclearexcept; - using ::fegetexceptflag; - using ::feraiseexcept; - using ::fesetexceptflag; - using ::fetestexcept; - - using ::fegetround; - using ::fesetround; - - using ::fegetenv; - using ::feholdexcept; - using ::fesetenv; - using ::feupdateenv; - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cinttypes b/libstdc++-v3/include/tr1_impl/cinttypes deleted file mode 100644 index 4a0f9f19dec..00000000000 --- a/libstdc++-v3/include/tr1_impl/cinttypes +++ /dev/null @@ -1,64 +0,0 @@ -// TR1 cinttypes -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cinttypes - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_C99_INTTYPES_TR1 - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - // types - using ::imaxdiv_t; - - // functions - using ::imaxabs; - - // May collide with _Longlong abs(_Longlong), and is not described - // anywhere outside the synopsis. Likely, a defect. - // - // intmax_t abs(intmax_t) - - using ::imaxdiv; - - // Likewise, with lldiv_t div(_Longlong, _Longlong). - // - // imaxdiv_t div(intmax_t, intmax_t) - - using ::strtoimax; - using ::strtoumax; - -#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 - using ::wcstoimax; - using ::wcstoumax; -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cmath b/libstdc++-v3/include/tr1_impl/cmath deleted file mode 100644 index cf460dd7c95..00000000000 --- a/libstdc++-v3/include/tr1_impl/cmath +++ /dev/null @@ -1,996 +0,0 @@ -// TR1 cmath -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cmath - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_C99_MATH_TR1 - -#undef acosh -#undef acoshf -#undef acoshl -#undef asinh -#undef asinhf -#undef asinhl -#undef atanh -#undef atanhf -#undef atanhl -#undef cbrt -#undef cbrtf -#undef cbrtl -#undef copysign -#undef copysignf -#undef copysignl -#undef erf -#undef erff -#undef erfl -#undef erfc -#undef erfcf -#undef erfcl -#undef exp2 -#undef exp2f -#undef exp2l -#undef expm1 -#undef expm1f -#undef expm1l -#undef fdim -#undef fdimf -#undef fdiml -#undef fma -#undef fmaf -#undef fmal -#undef fmax -#undef fmaxf -#undef fmaxl -#undef fmin -#undef fminf -#undef fminl -#undef hypot -#undef hypotf -#undef hypotl -#undef ilogb -#undef ilogbf -#undef ilogbl -#undef lgamma -#undef lgammaf -#undef lgammal -#undef llrint -#undef llrintf -#undef llrintl -#undef llround -#undef llroundf -#undef llroundl -#undef log1p -#undef log1pf -#undef log1pl -#undef log2 -#undef log2f -#undef log2l -#undef logb -#undef logbf -#undef logbl -#undef lrint -#undef lrintf -#undef lrintl -#undef lround -#undef lroundf -#undef lroundl -#undef nan -#undef nanf -#undef nanl -#undef nearbyint -#undef nearbyintf -#undef nearbyintl -#undef nextafter -#undef nextafterf -#undef nextafterl -#undef nexttoward -#undef nexttowardf -#undef nexttowardl -#undef remainder -#undef remainderf -#undef remainderl -#undef remquo -#undef remquof -#undef remquol -#undef rint -#undef rintf -#undef rintl -#undef round -#undef roundf -#undef roundl -#undef scalbln -#undef scalblnf -#undef scalblnl -#undef scalbn -#undef scalbnf -#undef scalbnl -#undef tgamma -#undef tgammaf -#undef tgammal -#undef trunc -#undef truncf -#undef truncl - -#endif - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -#if _GLIBCXX_USE_C99_MATH_TR1 - - // types - using ::double_t; - using ::float_t; - - // functions - using ::acosh; - using ::acoshf; - using ::acoshl; - - using ::asinh; - using ::asinhf; - using ::asinhl; - - using ::atanh; - using ::atanhf; - using ::atanhl; - - using ::cbrt; - using ::cbrtf; - using ::cbrtl; - - using ::copysign; - using ::copysignf; - using ::copysignl; - - using ::erf; - using ::erff; - using ::erfl; - - using ::erfc; - using ::erfcf; - using ::erfcl; - - using ::exp2; - using ::exp2f; - using ::exp2l; - - using ::expm1; - using ::expm1f; - using ::expm1l; - - using ::fdim; - using ::fdimf; - using ::fdiml; - - using ::fma; - using ::fmaf; - using ::fmal; - - using ::fmax; - using ::fmaxf; - using ::fmaxl; - - using ::fmin; - using ::fminf; - using ::fminl; - - using ::hypot; - using ::hypotf; - using ::hypotl; - - using ::ilogb; - using ::ilogbf; - using ::ilogbl; - - using ::lgamma; - using ::lgammaf; - using ::lgammal; - - using ::llrint; - using ::llrintf; - using ::llrintl; - - using ::llround; - using ::llroundf; - using ::llroundl; - - using ::log1p; - using ::log1pf; - using ::log1pl; - - using ::log2; - using ::log2f; - using ::log2l; - - using ::logb; - using ::logbf; - using ::logbl; - - using ::lrint; - using ::lrintf; - using ::lrintl; - - using ::lround; - using ::lroundf; - using ::lroundl; - - using ::nan; - using ::nanf; - using ::nanl; - - using ::nearbyint; - using ::nearbyintf; - using ::nearbyintl; - - using ::nextafter; - using ::nextafterf; - using ::nextafterl; - - using ::nexttoward; - using ::nexttowardf; - using ::nexttowardl; - - using ::remainder; - using ::remainderf; - using ::remainderl; - - using ::remquo; - using ::remquof; - using ::remquol; - - using ::rint; - using ::rintf; - using ::rintl; - - using ::round; - using ::roundf; - using ::roundl; - - using ::scalbln; - using ::scalblnf; - using ::scalblnl; - - using ::scalbn; - using ::scalbnf; - using ::scalbnl; - - using ::tgamma; - using ::tgammaf; - using ::tgammal; - - using ::trunc; - using ::truncf; - using ::truncl; - -#endif - -#if _GLIBCXX_USE_C99_MATH -#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC - - /// Function template definitions [8.16.3]. - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - fpclassify(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, - FP_SUBNORMAL, FP_ZERO, __type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isfinite(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isfinite(__type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isinf(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isinf(__type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isnan(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isnan(__type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isnormal(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isnormal(__type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - signbit(_Tp __f) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_signbit(__type(__f)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isgreater(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isgreater(__type(__f1), __type(__f2)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isgreaterequal(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isgreaterequal(__type(__f1), __type(__f2)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isless(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isless(__type(__f1), __type(__f2)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - islessequal(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_islessequal(__type(__f1), __type(__f2)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - islessgreater(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_islessgreater(__type(__f1), __type(__f2)); - } - - template<typename _Tp> - inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, - int>::__type - isunordered(_Tp __f1, _Tp __f2) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __builtin_isunordered(__type(__f1), __type(__f2)); - } - -#endif -#endif - -#if _GLIBCXX_USE_C99_MATH_TR1 - - /// Additional overloads [8.16.4]. - using std::acos; - - inline float - acosh(float __x) - { return __builtin_acoshf(__x); } - - inline long double - acosh(long double __x) - { return __builtin_acoshl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - acosh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return acosh(__type(__x)); - } - - using std::asin; - - inline float - asinh(float __x) - { return __builtin_asinhf(__x); } - - inline long double - asinh(long double __x) - { return __builtin_asinhl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - asinh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return asinh(__type(__x)); - } - - using std::atan; - using std::atan2; - - inline float - atanh(float __x) - { return __builtin_atanhf(__x); } - - inline long double - atanh(long double __x) - { return __builtin_atanhl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - atanh(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return atanh(__type(__x)); - } - - inline float - cbrt(float __x) - { return __builtin_cbrtf(__x); } - - inline long double - cbrt(long double __x) - { return __builtin_cbrtl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - cbrt(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return cbrt(__type(__x)); - } - - using std::ceil; - - inline float - copysign(float __x, float __y) - { return __builtin_copysignf(__x, __y); } - - inline long double - copysign(long double __x, long double __y) - { return __builtin_copysignl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - copysign(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return copysign(__type(__x), __type(__y)); - } - - using std::cos; - using std::cosh; - - inline float - erf(float __x) - { return __builtin_erff(__x); } - - inline long double - erf(long double __x) - { return __builtin_erfl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - erf(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erf(__type(__x)); - } - - inline float - erfc(float __x) - { return __builtin_erfcf(__x); } - - inline long double - erfc(long double __x) - { return __builtin_erfcl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - erfc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return erfc(__type(__x)); - } - - using std::exp; - - inline float - exp2(float __x) - { return __builtin_exp2f(__x); } - - inline long double - exp2(long double __x) - { return __builtin_exp2l(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - exp2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return exp2(__type(__x)); - } - - inline float - expm1(float __x) - { return __builtin_expm1f(__x); } - - inline long double - expm1(long double __x) - { return __builtin_expm1l(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - expm1(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return expm1(__type(__x)); - } - - using std::fabs; - - inline float - fdim(float __x, float __y) - { return __builtin_fdimf(__x, __y); } - - inline long double - fdim(long double __x, long double __y) - { return __builtin_fdiml(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - fdim(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return fdim(__type(__x), __type(__y)); - } - - using std::floor; - - inline float - fma(float __x, float __y, float __z) - { return __builtin_fmaf(__x, __y, __z); } - - inline long double - fma(long double __x, long double __y, long double __z) - { return __builtin_fmal(__x, __y, __z); } - - template<typename _Tp, typename _Up, typename _Vp> - inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type - fma(_Tp __x, _Up __y, _Vp __z) - { - typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; - return fma(__type(__x), __type(__y), __type(__z)); - } - - inline float - fmax(float __x, float __y) - { return __builtin_fmaxf(__x, __y); } - - inline long double - fmax(long double __x, long double __y) - { return __builtin_fmaxl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - fmax(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return fmax(__type(__x), __type(__y)); - } - - inline float - fmin(float __x, float __y) - { return __builtin_fminf(__x, __y); } - - inline long double - fmin(long double __x, long double __y) - { return __builtin_fminl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - fmin(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return fmin(__type(__x), __type(__y)); - } - - using std::fmod; - using std::frexp; - - inline float - hypot(float __x, float __y) - { return __builtin_hypotf(__x, __y); } - - inline long double - hypot(long double __x, long double __y) - { return __builtin_hypotl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - hypot(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return hypot(__type(__x), __type(__y)); - } - - inline int - ilogb(float __x) - { return __builtin_ilogbf(__x); } - - inline int - ilogb(long double __x) - { return __builtin_ilogbl(__x); } - - template<typename _Tp> - inline int - ilogb(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return ilogb(__type(__x)); - } - - using std::ldexp; - - inline float - lgamma(float __x) - { return __builtin_lgammaf(__x); } - - inline long double - lgamma(long double __x) - { return __builtin_lgammal(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - lgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lgamma(__type(__x)); - } - - inline long long - llrint(float __x) - { return __builtin_llrintf(__x); } - - inline long long - llrint(long double __x) - { return __builtin_llrintl(__x); } - - template<typename _Tp> - inline long long - llrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llrint(__type(__x)); - } - - inline long long - llround(float __x) - { return __builtin_llroundf(__x); } - - inline long long - llround(long double __x) - { return __builtin_llroundl(__x); } - - template<typename _Tp> - inline long long - llround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return llround(__type(__x)); - } - - using std::log; - using std::log10; - - inline float - log1p(float __x) - { return __builtin_log1pf(__x); } - - inline long double - log1p(long double __x) - { return __builtin_log1pl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - log1p(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log1p(__type(__x)); - } - - // DR 568. - inline float - log2(float __x) - { return __builtin_log2f(__x); } - - inline long double - log2(long double __x) - { return __builtin_log2l(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - log2(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return log2(__type(__x)); - } - - inline float - logb(float __x) - { return __builtin_logbf(__x); } - - inline long double - logb(long double __x) - { return __builtin_logbl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - logb(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return logb(__type(__x)); - } - - inline long - lrint(float __x) - { return __builtin_lrintf(__x); } - - inline long - lrint(long double __x) - { return __builtin_lrintl(__x); } - - template<typename _Tp> - inline long - lrint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lrint(__type(__x)); - } - - inline long - lround(float __x) - { return __builtin_lroundf(__x); } - - inline long - lround(long double __x) - { return __builtin_lroundl(__x); } - - template<typename _Tp> - inline long - lround(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return lround(__type(__x)); - } - - inline float - nearbyint(float __x) - { return __builtin_nearbyintf(__x); } - - inline long double - nearbyint(long double __x) - { return __builtin_nearbyintl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - nearbyint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nearbyint(__type(__x)); - } - - inline float - nextafter(float __x, float __y) - { return __builtin_nextafterf(__x, __y); } - - inline long double - nextafter(long double __x, long double __y) - { return __builtin_nextafterl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - nextafter(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return nextafter(__type(__x), __type(__y)); - } - - inline float - nexttoward(float __x, long double __y) - { return __builtin_nexttowardf(__x, __y); } - - inline long double - nexttoward(long double __x, long double __y) - { return __builtin_nexttowardl(__x, __y); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - nexttoward(_Tp __x, long double __y) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return nexttoward(__type(__x), __y); - } - - // DR 550. What should the return type of pow(float,int) be? - // NB: C++0x and TR1 != C++03. - // using std::pow; - - inline float - remainder(float __x, float __y) - { return __builtin_remainderf(__x, __y); } - - inline long double - remainder(long double __x, long double __y) - { return __builtin_remainderl(__x, __y); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - remainder(_Tp __x, _Up __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return remainder(__type(__x), __type(__y)); - } - - inline float - remquo(float __x, float __y, int* __pquo) - { return __builtin_remquof(__x, __y, __pquo); } - - inline long double - remquo(long double __x, long double __y, int* __pquo) - { return __builtin_remquol(__x, __y, __pquo); } - - template<typename _Tp, typename _Up> - inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type - remquo(_Tp __x, _Up __y, int* __pquo) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return remquo(__type(__x), __type(__y), __pquo); - } - - inline float - rint(float __x) - { return __builtin_rintf(__x); } - - inline long double - rint(long double __x) - { return __builtin_rintl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - rint(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return rint(__type(__x)); - } - - inline float - round(float __x) - { return __builtin_roundf(__x); } - - inline long double - round(long double __x) - { return __builtin_roundl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - round(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return round(__type(__x)); - } - - inline float - scalbln(float __x, long __ex) - { return __builtin_scalblnf(__x, __ex); } - - inline long double - scalbln(long double __x, long __ex) - { return __builtin_scalblnl(__x, __ex); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - scalbln(_Tp __x, long __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbln(__type(__x), __ex); - } - - inline float - scalbn(float __x, int __ex) - { return __builtin_scalbnf(__x, __ex); } - - inline long double - scalbn(long double __x, int __ex) - { return __builtin_scalbnl(__x, __ex); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - scalbn(_Tp __x, int __ex) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return scalbn(__type(__x), __ex); - } - - using std::sin; - using std::sinh; - using std::sqrt; - using std::tan; - using std::tanh; - - inline float - tgamma(float __x) - { return __builtin_tgammaf(__x); } - - inline long double - tgamma(long double __x) - { return __builtin_tgammal(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - tgamma(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return tgamma(__type(__x)); - } - - inline float - trunc(float __x) - { return __builtin_truncf(__x); } - - inline long double - trunc(long double __x) - { return __builtin_truncl(__x); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - trunc(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return trunc(__type(__x)); - } - -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/complex b/libstdc++-v3/include/tr1_impl/complex deleted file mode 100644 index aae4a1381ad..00000000000 --- a/libstdc++-v3/include/tr1_impl/complex +++ /dev/null @@ -1,370 +0,0 @@ -// TR1 complex -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/complex - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - /** - * @addtogroup complex_numbers - * @{ - */ - - // Forward declarations. - template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&); - template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&); - template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&); - - template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&); - template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&); - template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&); -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - // DR 595. - template<typename _Tp> _Tp fabs(const std::complex<_Tp>&); -#else - template<typename _Tp> std::complex<_Tp> fabs(const std::complex<_Tp>&); -#endif - - template<typename _Tp> - inline std::complex<_Tp> - __complex_acos(const std::complex<_Tp>& __z) - { - const std::complex<_Tp> __t = std::_GLIBCXX_TR1 asin(__z); - const _Tp __pi_2 = 1.5707963267948966192313216916397514L; - return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_acos(__complex__ float __z) - { return __builtin_cacosf(__z); } - - inline __complex__ double - __complex_acos(__complex__ double __z) - { return __builtin_cacos(__z); } - - inline __complex__ long double - __complex_acos(const __complex__ long double& __z) - { return __builtin_cacosl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - acos(const std::complex<_Tp>& __z) - { return __complex_acos(__z.__rep()); } -#else - /// acos(__z) [8.1.2]. - // Effects: Behaves the same as C99 function cacos, defined - // in subclause 7.3.5.1. - template<typename _Tp> - inline std::complex<_Tp> - acos(const std::complex<_Tp>& __z) - { return __complex_acos(__z); } -#endif - - template<typename _Tp> - inline std::complex<_Tp> - __complex_asin(const std::complex<_Tp>& __z) - { - std::complex<_Tp> __t(-__z.imag(), __z.real()); - __t = std::_GLIBCXX_TR1 asinh(__t); - return std::complex<_Tp>(__t.imag(), -__t.real()); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_asin(__complex__ float __z) - { return __builtin_casinf(__z); } - - inline __complex__ double - __complex_asin(__complex__ double __z) - { return __builtin_casin(__z); } - - inline __complex__ long double - __complex_asin(const __complex__ long double& __z) - { return __builtin_casinl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - asin(const std::complex<_Tp>& __z) - { return __complex_asin(__z.__rep()); } -#else - /// asin(__z) [8.1.3]. - // Effects: Behaves the same as C99 function casin, defined - // in subclause 7.3.5.2. - template<typename _Tp> - inline std::complex<_Tp> - asin(const std::complex<_Tp>& __z) - { return __complex_asin(__z); } -#endif - - template<typename _Tp> - std::complex<_Tp> - __complex_atan(const std::complex<_Tp>& __z) - { - const _Tp __r2 = __z.real() * __z.real(); - const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag(); - - _Tp __num = __z.imag() + _Tp(1.0); - _Tp __den = __z.imag() - _Tp(1.0); - - __num = __r2 + __num * __num; - __den = __r2 + __den * __den; - - return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x), - _Tp(0.25) * log(__num / __den)); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_atan(__complex__ float __z) - { return __builtin_catanf(__z); } - - inline __complex__ double - __complex_atan(__complex__ double __z) - { return __builtin_catan(__z); } - - inline __complex__ long double - __complex_atan(const __complex__ long double& __z) - { return __builtin_catanl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - atan(const std::complex<_Tp>& __z) - { return __complex_atan(__z.__rep()); } -#else - /// atan(__z) [8.1.4]. - // Effects: Behaves the same as C99 function catan, defined - // in subclause 7.3.5.3. - template<typename _Tp> - inline std::complex<_Tp> - atan(const std::complex<_Tp>& __z) - { return __complex_atan(__z); } -#endif - - template<typename _Tp> - std::complex<_Tp> - __complex_acosh(const std::complex<_Tp>& __z) - { - std::complex<_Tp> __t((__z.real() - __z.imag()) - * (__z.real() + __z.imag()) - _Tp(1.0), - _Tp(2.0) * __z.real() * __z.imag()); - __t = std::sqrt(__t); - - return std::log(__t + __z); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_acosh(__complex__ float __z) - { return __builtin_cacoshf(__z); } - - inline __complex__ double - __complex_acosh(__complex__ double __z) - { return __builtin_cacosh(__z); } - - inline __complex__ long double - __complex_acosh(const __complex__ long double& __z) - { return __builtin_cacoshl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - acosh(const std::complex<_Tp>& __z) - { return __complex_acosh(__z.__rep()); } -#else - /// acosh(__z) [8.1.5]. - // Effects: Behaves the same as C99 function cacosh, defined - // in subclause 7.3.6.1. - template<typename _Tp> - inline std::complex<_Tp> - acosh(const std::complex<_Tp>& __z) - { return __complex_acosh(__z); } -#endif - - template<typename _Tp> - std::complex<_Tp> - __complex_asinh(const std::complex<_Tp>& __z) - { - std::complex<_Tp> __t((__z.real() - __z.imag()) - * (__z.real() + __z.imag()) + _Tp(1.0), - _Tp(2.0) * __z.real() * __z.imag()); - __t = std::sqrt(__t); - - return std::log(__t + __z); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_asinh(__complex__ float __z) - { return __builtin_casinhf(__z); } - - inline __complex__ double - __complex_asinh(__complex__ double __z) - { return __builtin_casinh(__z); } - - inline __complex__ long double - __complex_asinh(const __complex__ long double& __z) - { return __builtin_casinhl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - asinh(const std::complex<_Tp>& __z) - { return __complex_asinh(__z.__rep()); } -#else - /// asinh(__z) [8.1.6]. - // Effects: Behaves the same as C99 function casin, defined - // in subclause 7.3.6.2. - template<typename _Tp> - inline std::complex<_Tp> - asinh(const std::complex<_Tp>& __z) - { return __complex_asinh(__z); } -#endif - - template<typename _Tp> - std::complex<_Tp> - __complex_atanh(const std::complex<_Tp>& __z) - { - const _Tp __i2 = __z.imag() * __z.imag(); - const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real(); - - _Tp __num = _Tp(1.0) + __z.real(); - _Tp __den = _Tp(1.0) - __z.real(); - - __num = __i2 + __num * __num; - __den = __i2 + __den * __den; - - return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)), - _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); - } - -#if _GLIBCXX_USE_C99_COMPLEX_TR1 - inline __complex__ float - __complex_atanh(__complex__ float __z) - { return __builtin_catanhf(__z); } - - inline __complex__ double - __complex_atanh(__complex__ double __z) - { return __builtin_catanh(__z); } - - inline __complex__ long double - __complex_atanh(const __complex__ long double& __z) - { return __builtin_catanhl(__z); } - - template<typename _Tp> - inline std::complex<_Tp> - atanh(const std::complex<_Tp>& __z) - { return __complex_atanh(__z.__rep()); } -#else - /// atanh(__z) [8.1.7]. - // Effects: Behaves the same as C99 function catanh, defined - // in subclause 7.3.6.3. - template<typename _Tp> - inline std::complex<_Tp> - atanh(const std::complex<_Tp>& __z) - { return __complex_atanh(__z); } -#endif - - template<typename _Tp> -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - inline _Tp -#else - inline std::complex<_Tp> -#endif - /// fabs(__z) [8.1.8]. - // Effects: Behaves the same as C99 function cabs, defined - // in subclause 7.3.8.1. - fabs(const std::complex<_Tp>& __z) - { return std::abs(__z); } - - /// Additional overloads [8.1.9]. -#if (defined(_GLIBCXX_INCLUDE_AS_CXX0X) \ - || (defined(_GLIBCXX_INCLUDE_AS_TR1) \ - && !defined(__GXX_EXPERIMENTAL_CXX0X__))) - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - arg(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; -#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) - return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L) - : __type(); -#else - return std::arg(std::complex<__type>(__x)); -#endif - } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - imag(_Tp) - { return _Tp(); } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - norm(_Tp __x) - { - typedef typename __gnu_cxx::__promote<_Tp>::__type __type; - return __type(__x) * __type(__x); - } - - template<typename _Tp> - inline typename __gnu_cxx::__promote<_Tp>::__type - real(_Tp __x) - { return __x; } - -#endif - - template<typename _Tp, typename _Up> - inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> - pow(const std::complex<_Tp>& __x, const _Up& __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return std::pow(std::complex<__type>(__x), __type(__y)); - } - - template<typename _Tp, typename _Up> - inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> - pow(const _Tp& __x, const std::complex<_Up>& __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return std::pow(__type(__x), std::complex<__type>(__y)); - } - - template<typename _Tp, typename _Up> - inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> - pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y) - { - typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; - return std::pow(std::complex<__type>(__x), - std::complex<__type>(__y)); - } - - // @} group complex_numbers - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/cstdint b/libstdc++-v3/include/tr1_impl/cstdint deleted file mode 100644 index d1403887a71..00000000000 --- a/libstdc++-v3/include/tr1_impl/cstdint +++ /dev/null @@ -1,75 +0,0 @@ -// TR1 cstdint -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cstdint - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_C99_STDINT_TR1 - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - using ::int8_t; - using ::int16_t; - using ::int32_t; - using ::int64_t; - - using ::int_fast8_t; - using ::int_fast16_t; - using ::int_fast32_t; - using ::int_fast64_t; - - using ::int_least8_t; - using ::int_least16_t; - using ::int_least32_t; - using ::int_least64_t; - - using ::intmax_t; - using ::intptr_t; - - using ::uint8_t; - using ::uint16_t; - using ::uint32_t; - using ::uint64_t; - - using ::uint_fast8_t; - using ::uint_fast16_t; - using ::uint_fast32_t; - using ::uint_fast64_t; - - using ::uint_least8_t; - using ::uint_least16_t; - using ::uint_least32_t; - using ::uint_least64_t; - - using ::uintmax_t; - using ::uintptr_t; - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cstdio b/libstdc++-v3/include/tr1_impl/cstdio deleted file mode 100644 index 8b100ccebc6..00000000000 --- a/libstdc++-v3/include/tr1_impl/cstdio +++ /dev/null @@ -1,44 +0,0 @@ -// TR1 cstdio -*- C++ -*- - -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cstdio - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -#if _GLIBCXX_USE_C99 - using std::snprintf; - using std::vsnprintf; - - using std::vfscanf; - using std::vscanf; - using std::vsscanf; -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/cstdlib b/libstdc++-v3/include/tr1_impl/cstdlib deleted file mode 100644 index e9a590f0b58..00000000000 --- a/libstdc++-v3/include/tr1_impl/cstdlib +++ /dev/null @@ -1,65 +0,0 @@ -// TR1 cstdlib -*- C++ -*- - -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cstdlib - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_HOSTED - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -#if _GLIBCXX_USE_C99 - -#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC - // types - using std::lldiv_t; - - // functions - using std::llabs; - using std::lldiv; -#endif - - using std::atoll; - using std::strtoll; - using std::strtoull; - - using std::strtof; - using std::strtold; - - // overloads - using std::abs; -#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC - using std::div; -#endif - -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cwchar b/libstdc++-v3/include/tr1_impl/cwchar deleted file mode 100644 index 2a9004d40d4..00000000000 --- a/libstdc++-v3/include/tr1_impl/cwchar +++ /dev/null @@ -1,58 +0,0 @@ -// TR1 cwchar -*- C++ -*- - -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cwchar - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_WCHAR_T - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -#if _GLIBCXX_HAVE_WCSTOF - using std::wcstof; -#endif -#if _GLIBCXX_HAVE_VFWSCANF - using std::vfwscanf; -#endif -#if _GLIBCXX_HAVE_VSWSCANF - using std::vswscanf; -#endif -#if _GLIBCXX_HAVE_VWSCANF - using std::vwscanf; -#endif - -#if _GLIBCXX_USE_C99 - using std::wcstold; - using std::wcstoll; - using std::wcstoull; -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/cwctype b/libstdc++-v3/include/tr1_impl/cwctype deleted file mode 100644 index 3135d364119..00000000000 --- a/libstdc++-v3/include/tr1_impl/cwctype +++ /dev/null @@ -1,43 +0,0 @@ -// TR1 cwctype -*- C++ -*- - -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/cwctype - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -#if _GLIBCXX_USE_WCHAR_T - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -#if _GLIBCXX_HAVE_ISWBLANK - using std::iswblank; -#endif - -_GLIBCXX_END_NAMESPACE_TR1 -} - -#endif diff --git a/libstdc++-v3/include/tr1_impl/regex b/libstdc++-v3/include/tr1_impl/regex deleted file mode 100644 index efe79e95477..00000000000 --- a/libstdc++-v3/include/tr1_impl/regex +++ /dev/null @@ -1,2710 +0,0 @@ -// class template regex -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** - * @file tr1_impl/regex - * @brief The common implementation file for tr1 and std regular expressions. - * - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - -/** - * @defgroup tr1_regex Regular Expressions - * A facility for performing regular expression pattern matching. - */ - //@{ - -/** @namespace std::regex_constants - * @brief ISO C++ 0x entities sub namespace for regex. - */ -namespace regex_constants -{ - /** - * @name 5.1 Regular Expression Syntax Options - */ - //@{ - enum __syntax_option - { - _S_icase, - _S_nosubs, - _S_optimize, - _S_collate, - _S_ECMAScript, - _S_basic, - _S_extended, - _S_awk, - _S_grep, - _S_egrep, - _S_syntax_last - }; - - /** - * @brief This is a bitmask type indicating how to interpret the regex. - * - * The @c syntax_option_type is implementation defined but it is valid to - * perform bitwise operations on these values and expect the right thing to - * happen. - * - * A valid value of type syntax_option_type shall have exactly one of the - * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep - * %set. - */ - typedef unsigned int syntax_option_type; - - /** - * Specifies that the matching of regular expressions against a character - * sequence shall be performed without regard to case. - */ - static const syntax_option_type icase = 1 << _S_icase; - - /** - * Specifies that when a regular expression is matched against a character - * container sequence, no sub-expression matches are to be stored in the - * supplied match_results structure. - */ - static const syntax_option_type nosubs = 1 << _S_nosubs; - - /** - * Specifies that the regular expression engine should pay more attention to - * the speed with which regular expressions are matched, and less to the - * speed with which regular expression objects are constructed. Otherwise - * it has no detectable effect on the program output. - */ - static const syntax_option_type optimize = 1 << _S_optimize; - - /** - * Specifies that character ranges of the form [a-b] should be locale - * sensitive. - */ - static const syntax_option_type collate = 1 << _S_collate; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript - * Language Specification, Standard Ecma-262, third edition, 1999], as - * modified in tr1 section [7.13]. This grammar is similar to that defined - * in the PERL scripting language but extended with elements found in the - * POSIX regular expression grammar. - */ - static const syntax_option_type ECMAScript = 1 << _S_ECMAScript; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, - * Portable Operating System Interface (POSIX), Base Definitions and - * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- - * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. - */ - static const syntax_option_type basic = 1 << _S_basic; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, - * Portable Operating System Interface (POSIX), Base Definitions and Headers, - * Section 9, Regular Expressions. - */ - static const syntax_option_type extended = 1 << _S_extended; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is - * identical to syntax_option_type extended, except that C-style escape - * sequences are supported. These sequences are: - * \\\\, \\a, \\b, \\f, - * \\n, \\r, \\t , \\v, - * \\', ', and \\ddd - * (where ddd is one, two, or three octal digits). - */ - static const syntax_option_type awk = 1 << _S_awk; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is - * identical to syntax_option_type basic, except that newlines are treated - * as whitespace. - */ - static const syntax_option_type grep = 1 << _S_grep; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility grep when given the -E option in - * IEEE Std 1003.1-2001. This option is identical to syntax_option_type - * extended, except that newlines are treated as whitespace. - */ - static const syntax_option_type egrep = 1 << _S_egrep; - - //@} - - /** - * @name 5.2 Matching Rules - * - * Matching a regular expression against a sequence of characters [first, - * last) proceeds according to the rules of the grammar specified for the - * regular expression object, modified according to the effects listed - * below for any bitmask elements set. - * - */ - //@{ - - enum __match_flag - { - _S_not_bol, - _S_not_eol, - _S_not_bow, - _S_not_eow, - _S_any, - _S_not_null, - _S_continuous, - _S_prev_avail, - _S_sed, - _S_no_copy, - _S_first_only, - _S_match_flag_last - }; - - /** - * @brief This is a bitmask type indicating regex matching rules. - * - * The @c match_flag_type is implementation defined but it is valid to - * perform bitwise operations on these values and expect the right thing to - * happen. - */ - typedef std::bitset<_S_match_flag_last> match_flag_type; - - /** - * The default matching rules. - */ - static const match_flag_type match_default = 0; - - /** - * The first character in the sequence [first, last) is treated as though it - * is not at the beginning of a line, so the character (^) in the regular - * expression shall not match [first, first). - */ - static const match_flag_type match_not_bol = 1 << _S_not_bol; - - /** - * The last character in the sequence [first, last) is treated as though it - * is not at the end of a line, so the character ($) in the regular - * expression shall not match [last, last). - */ - static const match_flag_type match_not_eol = 1 << _S_not_eol; - - /** - * The expression \\b is not matched against the sub-sequence - * [first,first). - */ - static const match_flag_type match_not_bow = 1 << _S_not_bow; - - /** - * The expression \\b should not be matched against the sub-sequence - * [last,last). - */ - static const match_flag_type match_not_eow = 1 << _S_not_eow; - - /** - * If more than one match is possible then any match is an acceptable - * result. - */ - static const match_flag_type match_any = 1 << _S_any; - - /** - * The expression does not match an empty sequence. - */ - static const match_flag_type match_not_null = 1 << _S_not_null; - - /** - * The expression only matches a sub-sequence that begins at first . - */ - static const match_flag_type match_continuous = 1 << _S_continuous; - - /** - * --first is a valid iterator position. When this flag is set then the - * flags match_not_bol and match_not_bow are ignored by the regular - * expression algorithms 7.11 and iterators 7.12. - */ - static const match_flag_type match_prev_avail = 1 << _S_prev_avail; - - /** - * When a regular expression match is to be replaced by a new string, the - * new string is constructed using the rules used by the ECMAScript replace - * function in ECMA- 262 [Ecma International, ECMAScript Language - * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 - * String.prototype.replace. In addition, during search and replace - * operations all non-overlapping occurrences of the regular expression - * are located and replaced, and sections of the input that did not match - * the expression are copied unchanged to the output string. - * - * Format strings (from ECMA-262 [15.5.4.11]): - * @li $$ The dollar-sign itself ($) - * @li $& The matched substring. - * @li $` The portion of @a string that precedes the matched substring. - * This would be match_results::prefix(). - * @li $' The portion of @a string that follows the matched substring. - * This would be match_results::suffix(). - * @li $n The nth capture, where n is in [1,9] and $n is not followed by a - * decimal digit. If n <= match_results::size() and the nth capture - * is undefined, use the empty string instead. If n > - * match_results::size(), the result is implementation-defined. - * @li $nn The nnth capture, where nn is a two-digit decimal number on - * [01, 99]. If nn <= match_results::size() and the nth capture is - * undefined, use the empty string instead. If - * nn > match_results::size(), the result is implementation-defined. - */ - static const match_flag_type format_default = 0; - - /** - * When a regular expression match is to be replaced by a new string, the - * new string is constructed using the rules used by the POSIX sed utility - * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable - * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. - */ - static const match_flag_type format_sed = 1 << _S_sed; - - /** - * During a search and replace operation, sections of the character - * container sequence being searched that do not match the regular - * expression shall not be copied to the output string. - */ - static const match_flag_type format_no_copy = 1 << _S_no_copy; - - /** - * When specified during a search and replace operation, only the first - * occurrence of the regular expression shall be replaced. - */ - static const match_flag_type format_first_only = 1 << _S_first_only; - - //@} - - /** - * @name 5.3 Error Types - */ - //@{ - - enum error_type - { - _S_error_collate, - _S_error_ctype, - _S_error_escape, - _S_error_backref, - _S_error_brack, - _S_error_paren, - _S_error_brace, - _S_error_badbrace, - _S_error_range, - _S_error_space, - _S_error_badrepeat, - _S_error_complexity, - _S_error_stack, - _S_error_last - }; - - /** The expression contained an invalid collating element name. */ - static const error_type error_collate(_S_error_collate); - - /** The expression contained an invalid character class name. */ - static const error_type error_ctype(_S_error_ctype); - - /** - * The expression contained an invalid escaped character, or a trailing - * escape. - */ - static const error_type error_escape(_S_error_escape); - - /** The expression contained an invalid back reference. */ - static const error_type error_backref(_S_error_backref); - - /** The expression contained mismatched [ and ]. */ - static const error_type error_brack(_S_error_brack); - - /** The expression contained mismatched ( and ). */ - static const error_type error_paren(_S_error_paren); - - /** The expression contained mismatched { and } */ - static const error_type error_brace(_S_error_brace); - - /** The expression contained an invalid range in a {} expression. */ - static const error_type error_badbrace(_S_error_badbrace); - - /** - * The expression contained an invalid character range, - * such as [b-a] in most encodings. - */ - static const error_type error_range(_S_error_range); - - /** - * There was insufficient memory to convert the expression into a - * finite state machine. - */ - static const error_type error_space(_S_error_space); - - /** - * One of <em>*?+{</em> was not preceded by a valid regular expression. - */ - static const error_type error_badrepeat(_S_error_badrepeat); - - /** - * The complexity of an attempted match against a regular expression - * exceeded a pre-set level. - */ - static const error_type error_complexity(_S_error_complexity); - - /** - * There was insufficient memory to determine whether the - * regular expression could match the specified character sequence. - */ - static const error_type error_stack(_S_error_stack); - - //@} -} - - - // [7.8] Class regex_error - /** - * @brief A regular expression exception class. - * @ingroup exceptions - * - * The regular expression library throws objects of this class on error. - */ - class regex_error - : public std::runtime_error - { - public: - /** - * @brief Constructs a regex_error object. - * - * @param ecode the regex error code. - */ - explicit - regex_error(regex_constants::error_type __ecode) - : std::runtime_error("regex_error"), _M_code(__ecode) - { } - - /** - * @brief Gets the regex error code. - * - * @returns the regex error code. - */ - regex_constants::error_type - code() const - { return _M_code; } - - protected: - regex_constants::error_type _M_code; - }; - - // [7.7] Class regex_traits - /** - * @brief Describes aspects of a regular expression. - * - * A regular expression traits class that satisfies the requirements of tr1 - * section [7.2]. - * - * The class %regex is parameterized around a set of related types and - * functions used to complete the definition of its semantics. This class - * satisfies the requirements of such a traits class. - */ - template<typename _Ch_type> - struct regex_traits - { - public: - typedef _Ch_type char_type; - typedef std::basic_string<char_type> string_type; - typedef std::locale locale_type; - typedef std::ctype_base::mask char_class_type; - - public: - /** - * @brief Constructs a default traits object. - */ - regex_traits() - { } - - /** - * @brief Gives the length of a C-style string starting at @p __p. - * - * @param __p a pointer to the start of a character sequence. - * - * @returns the number of characters between @p *__p and the first - * default-initialized value of type @p char_type. In other words, uses - * the C-string algorithm for determining the length of a sequence of - * characters. - */ - static std::size_t - length(const char_type* __p) - { return string_type::traits_type::length(__p); } - - /** - * @brief Performs the identity translation. - * - * @param c A character to the locale-specific character set. - * - * @returns c. - */ - char_type - translate(char_type __c) const - { return __c; } - - /** - * @brief Translates a character into a case-insensitive equivalent. - * - * @param c A character to the locale-specific character set. - * - * @returns the locale-specific lower-case equivalent of c. - * @throws std::bad_cast if the imbued locale does not support the ctype - * facet. - */ - char_type - translate_nocase(char_type __c) const - { - using std::ctype; - using std::use_facet; - return use_facet<ctype<char_type> >(_M_locale).tolower(__c); - } - - /** - * @brief Gets a sort key for a character sequence. - * - * @param first beginning of the character sequence. - * @param last one-past-the-end of the character sequence. - * - * Returns a sort key for the character sequence designated by the - * iterator range [F1, F2) such that if the character sequence [G1, G2) - * sorts before the character sequence [H1, H2) then - * v.transform(G1, G2) < v.transform(H1, H2). - * - * What this really does is provide a more efficient way to compare a - * string to multiple other strings in locales with fancy collation - * rules and equivalence classes. - * - * @returns a locale-specific sort key equivalent to the input range. - * - * @throws std::bad_cast if the current locale does not have a collate - * facet. - */ - template<typename _Fwd_iter> - string_type - transform(_Fwd_iter __first, _Fwd_iter __last) const - { - using std::collate; - using std::use_facet; - const collate<_Ch_type>& __c(use_facet< - collate<_Ch_type> >(_M_locale)); - string_type __s(__first, __last); - return __c.transform(__s.data(), __s.data() + __s.size()); - } - - /** - * @brief Dunno. - * - * @param first beginning of the character sequence. - * @param last one-past-the-end of the character sequence. - * - * Effects: if typeid(use_facet<collate<_Ch_type> >) == - * typeid(collate_byname<_Ch_type>) and the form of the sort key - * returned by collate_byname<_Ch_type>::transform(first, last) is known - * and can be converted into a primary sort key then returns that key, - * otherwise returns an empty string. WTF?? - * - * @todo Implement this function. - */ - template<typename _Fwd_iter> - string_type - transform_primary(_Fwd_iter __first, _Fwd_iter __last) const; - - /** - * @brief Gets a collation element by name. - * - * @param first beginning of the collation element name. - * @param last one-past-the-end of the collation element name. - * - * @returns a sequence of one or more characters that represents the - * collating element consisting of the character sequence designated by - * the iterator range [first, last). Returns an empty string if the - * character sequence is not a valid collating element. - * - * @todo Implement this function. - */ - template<typename _Fwd_iter> - string_type - lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; - - /** - * @brief Maps one or more characters to a named character - * classification. - * - * @param first beginning of the character sequence. - * @param last one-past-the-end of the character sequence. - * - * @returns an unspecified value that represents the character - * classification named by the character sequence designated by the - * iterator range [first, last). The value returned shall be independent - * of the case of the characters in the character sequence. If the name - * is not recognized then returns a value that compares equal to 0. - * - * At least the following names (or their wide-character equivalent) are - * supported. - * - d - * - w - * - s - * - alnum - * - alpha - * - blank - * - cntrl - * - digit - * - graph - * - lower - * - print - * - punct - * - space - * - upper - * - xdigit - * - * @todo Implement this function. - */ - template<typename _Fwd_iter> - char_class_type - lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const; - - /** - * @brief Determines if @p c is a member of an identified class. - * - * @param c a character. - * @param f a class type (as returned from lookup_classname). - * - * @returns true if the character @p c is a member of the classification - * represented by @p f, false otherwise. - * - * @throws std::bad_cast if the current locale does not have a ctype - * facet. - */ - bool - isctype(_Ch_type __c, char_class_type __f) const; - - /** - * @brief Converts a digit to an int. - * - * @param ch a character representing a digit. - * @param radix the radix if the numeric conversion (limited to 8, 10, - * or 16). - * - * @returns the value represented by the digit ch in base radix if the - * character ch is a valid digit in base radix; otherwise returns -1. - */ - int - value(_Ch_type __ch, int __radix) const; - - /** - * @brief Imbues the regex_traits object with a copy of a new locale. - * - * @param loc A locale. - * - * @returns a copy of the previous locale in use by the regex_traits - * object. - * - * @note Calling imbue with a different locale than the one currently in - * use invalidates all cached data held by *this. - */ - locale_type - imbue(locale_type __loc) - { - std::swap(_M_locale, __loc); - return __loc; - } - - /** - * @brief Gets a copy of the current locale in use by the regex_traits - * object. - */ - locale_type - getloc() const - { return _M_locale; } - - protected: - locale_type _M_locale; - }; - - template<typename _Ch_type> - bool regex_traits<_Ch_type>:: - isctype(_Ch_type __c, char_class_type __f) const - { - using std::ctype; - using std::use_facet; - const ctype<_Ch_type>& __ctype(use_facet< - ctype<_Ch_type> >(_M_locale)); - - if (__ctype.is(__c, __f)) - return true; - - // special case of underscore in [[:w:]] - if (__c == __ctype.widen('_')) - { - const char* const __wb[] = "w"; - char_class_type __wt = this->lookup_classname(__wb, - __wb + sizeof(__wb)); - if (__f | __wt) - return true; - } - - // special case of [[:space:]] in [[:blank:]] - if (__c == __ctype.isspace(__c)) - { - const char* const __bb[] = "blank"; - char_class_type __bt = this->lookup_classname(__bb, - __bb + sizeof(__bb)); - if (__f | __bt) - return true; - } - - return false; - } - - template<typename _Ch_type> - int regex_traits<_Ch_type>:: - value(_Ch_type __ch, int __radix) const - { - std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); - int __v; - if (__radix == 8) - __is >> std::oct; - else if (__radix == 16) - __is >> std::hex; - __is >> __v; - return __is.fail() ? -1 : __v; - } - - // [7.8] Class basic_regex - /** - * Objects of specializations of this class represent regular expressions - * constructed from sequences of character type @p _Ch_type. - * - * Storage for the regular expression is allocated and deallocated as - * necessary by the member functions of this class. - */ - template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> > - class basic_regex - { - public: - // types: - typedef _Ch_type value_type; - typedef regex_constants::syntax_option_type flag_type; - typedef typename _Rx_traits::locale_type locale_type; - typedef typename _Rx_traits::string_type string_type; - - /** - * @name Constants - * tr1 [7.8.1] std [28.8.1] - */ - //@{ - static const regex_constants::syntax_option_type icase - = regex_constants::icase; - static const regex_constants::syntax_option_type nosubs - = regex_constants::nosubs; - static const regex_constants::syntax_option_type optimize - = regex_constants::optimize; - static const regex_constants::syntax_option_type collate - = regex_constants::collate; - static const regex_constants::syntax_option_type ECMAScript - = regex_constants::ECMAScript; - static const regex_constants::syntax_option_type basic - = regex_constants::basic; - static const regex_constants::syntax_option_type extended - = regex_constants::extended; - static const regex_constants::syntax_option_type awk - = regex_constants::awk; - static const regex_constants::syntax_option_type grep - = regex_constants::grep; - static const regex_constants::syntax_option_type egrep - = regex_constants::egrep; - //@} - - // [7.8.2] construct/copy/destroy - /** - * Constructs a basic regular expression that does not match any - * character sequence. - */ - basic_regex() - : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0) - { _M_compile(); } - - /** - * @brief Constructs a basic regular expression from the sequence - * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the - * flags in @p f. - * - * @param p A pointer to the start of a C-style null-terminated string - * containing a regular expression. - * @param f Flags indicating the syntax rules and options. - * - * @throws regex_error if @p p is not a valid regular expression. - */ - explicit - basic_regex(const _Ch_type* __p, - flag_type __f = regex_constants::ECMAScript) - : _M_flags(__f), _M_pattern(__p), _M_mark_count(0) - { _M_compile(); } - - /** - * @brief Constructs a basic regular expression from the sequence - * [p, p + len) interpreted according to the flags in @p f. - * - * @param p A pointer to the start of a string containing a regular - * expression. - * @param len The length of the string containing the regular expression. - * @param f Flags indicating the syntax rules and options. - * - * @throws regex_error if @p p is not a valid regular expression. - */ - basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f) - : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0) - { _M_compile(); } - - /** - * @brief Copy-constructs a basic regular expression. - * - * @param rhs A @p regex object. - */ - basic_regex(const basic_regex& __rhs) - : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern), - _M_mark_count(__rhs._M_mark_count) - { _M_compile(); } - - /** - * @brief Constructs a basic regular expression from the string - * @p s interpreted according to the flags in @p f. - * - * @param s A string containing a regular expression. - * @param f Flags indicating the syntax rules and options. - * - * @throws regex_error if @p s is not a valid regular expression. - */ - template<typename _Ch_traits, typename _Ch_alloc> - explicit - basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, - flag_type __f = regex_constants::ECMAScript) - : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0) - { _M_compile(); } - - /** - * @brief Constructs a basic regular expression from the range - * [first, last) interpreted according to the flags in @p f. - * - * @param first The start of a range containing a valid regular - * expression. - * @param last The end of a range containing a valid regular - * expression. - * @param f The format flags of the regular expression. - * - * @throws regex_error if @p [first, last) is not a valid regular - * expression. - */ - template<typename _InputIterator> - basic_regex(_InputIterator __first, _InputIterator __last, - flag_type __f = regex_constants::ECMAScript) - : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0) - { _M_compile(); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - /** - * @brief Constructs a basic regular expression from an initializer list. - * - * @param l The initializer list. - * @param f The format flags of the regular expression. - * - * @throws regex_error if @p l is not a valid regular expression. - */ - basic_regex(initializer_list<_Ch_type> __l, - flag_type __f = regex_constants::ECMAScript) - : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0) - { _M_compile(); } -#endif - - /** - * @brief Destroys a basic regular expression. - */ - ~basic_regex() - { } - - /** - * @brief Assigns one regular expression to another. - */ - basic_regex& - operator=(const basic_regex& __rhs) - { return this->assign(__rhs); } - - /** - * @brief Replaces a regular expression with a new one constructed from - * a C-style null-terminated string. - * - * @param A pointer to the start of a null-terminated C-style string - * containing a regular expression. - */ - basic_regex& - operator=(const _Ch_type* __p) - { return this->assign(__p, flags()); } - - /** - * @brief Replaces a regular expression with a new one constructed from - * a string. - * - * @param A pointer to a string containing a regular expression. - */ - template<typename _Ch_typeraits, typename _Allocator> - basic_regex& - operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s) - { return this->assign(__s, flags()); } - - // [7.8.3] assign - /** - * @brief the real assignment operator. - * - * @param that Another regular expression object. - */ - basic_regex& - assign(const basic_regex& __that) - { - basic_regex __tmp(__that); - this->swap(__tmp); - return *this; - } - - /** - * @brief Assigns a new regular expression to a regex object from a - * C-style null-terminated string containing a regular expression - * pattern. - * - * @param p A pointer to a C-style null-terminated string containing - * a regular expression pattern. - * @param flags Syntax option flags. - * - * @throws regex_error if p does not contain a valid regular expression - * pattern interpreted according to @p flags. If regex_error is thrown, - * *this remains unchanged. - */ - basic_regex& - assign(const _Ch_type* __p, - flag_type __flags = regex_constants::ECMAScript) - { return this->assign(string_type(__p), __flags); } - - /** - * @brief Assigns a new regular expression to a regex object from a - * C-style string containing a regular expression pattern. - * - * @param p A pointer to a C-style string containing a - * regular expression pattern. - * @param len The length of the regular expression pattern string. - * @param flags Syntax option flags. - * - * @throws regex_error if p does not contain a valid regular expression - * pattern interpreted according to @p flags. If regex_error is thrown, - * *this remains unchanged. - */ - basic_regex& - assign(const _Ch_type* __p, std::size_t __len, flag_type __flags) - { return this->assign(string_type(__p, __len), __flags); } - - /** - * @brief Assigns a new regular expression to a regex object from a - * string containing a regular expression pattern. - * - * @param s A string containing a regular expression pattern. - * @param flags Syntax option flags. - * - * @throws regex_error if p does not contain a valid regular expression - * pattern interpreted according to @p flags. If regex_error is thrown, - * *this remains unchanged. - */ - template<typename _Ch_typeraits, typename _Allocator> - basic_regex& - assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s, - flag_type __f = regex_constants::ECMAScript) - { - basic_regex __tmp(__s, __f); - this->swap(__tmp); - return *this; - } - - /** - * @brief Assigns a new regular expression to a regex object. - * - * @param first The start of a range containing a valid regular - * expression. - * @param last The end of a range containing a valid regular - * expression. - * @param flags Syntax option flags. - * - * @throws regex_error if p does not contain a valid regular expression - * pattern interpreted according to @p flags. If regex_error is thrown, - * the object remains unchanged. - */ - template<typename _InputIterator> - basic_regex& - assign(_InputIterator __first, _InputIterator __last, - flag_type __flags = regex_constants::ECMAScript) - { return this->assign(string_type(__first, __last), __flags); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - /** - * @brief Assigns a new regular expression to a regex object. - * - * @param l An initializer list representing a regular expression. - * @param flags Syntax option flags. - * - * @throws regex_error if @p l does not contain a valid regular - * expression pattern interpreted according to @p flags. If regex_error - * is thrown, the object remains unchanged. - */ - basic_regex& - assign(initializer_list<_Ch_type> __l, - flag_type __f = regex_constants::ECMAScript) - { return this->assign(__l.begin(), __l.end(), __f); } -#endif - - // [7.8.4] const operations - /** - * @brief Gets the number of marked subexpressions within the regular - * expression. - */ - unsigned int - mark_count() const - { return _M_mark_count; } - - /** - * @brief Gets the flags used to construct the regular expression - * or in the last call to assign(). - */ - flag_type - flags() const - { return _M_flags; } - - // [7.8.5] locale - /** - * @brief Imbues the regular expression object with the given locale. - * - * @param loc A locale. - */ - locale_type - imbue(locale_type __loc) - { return _M_traits.imbue(__loc); } - - /** - * @brief Gets the locale currently imbued in the regular expression - * object. - */ - locale_type - getloc() const - { return _M_traits.getloc(); } - - // [7.8.6] swap - /** - * @brief Swaps the contents of two regular expression objects. - * - * @param rhs Another regular expression object. - */ - void - swap(basic_regex& __rhs) - { - std::swap(_M_flags, __rhs._M_flags); - std::swap(_M_pattern, __rhs._M_pattern); - std::swap(_M_mark_count, __rhs._M_mark_count); - std::swap(_M_traits, __rhs._M_traits); - } - - private: - /** - * @brief Compiles a regular expression pattern into a NFA. - * @todo Implement this function. - */ - void _M_compile(); - - protected: - flag_type _M_flags; - string_type _M_pattern; - unsigned int _M_mark_count; - _Rx_traits _M_traits; - }; - - /** @brief Standard regular expressions. */ - typedef basic_regex<char> regex; -#ifdef _GLIBCXX_USE_WCHAR_T - /** @brief Standard wide-character regular expressions. */ - typedef basic_regex<wchar_t> wregex; -#endif - - - // [7.8.6] basic_regex swap - /** - * @brief Swaps the contents of two regular expression objects. - * @param lhs First regular expression. - * @param rhs Second regular expression. - */ - template<typename _Ch_type, typename _Rx_traits> - inline void - swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, - basic_regex<_Ch_type, _Rx_traits>& __rhs) - { __lhs.swap(__rhs); } - - - // [7.9] Class template sub_match - /** - * A sequence of characters matched by a particular marked sub-expression. - * - * An object of this class is essentially a pair of iterators marking a - * matched subexpression within a regular expression pattern match. Such - * objects can be converted to and compared with std::basic_string objects - * of a similar base character type as the pattern matched by the regular - * expression. - * - * The iterators that make up the pair are the usual half-open interval - * referencing the actual original pattern matched. - */ - template<typename _BiIter> - class sub_match : public std::pair<_BiIter, _BiIter> - { - public: - typedef typename iterator_traits<_BiIter>::value_type value_type; - typedef typename iterator_traits<_BiIter>::difference_type - difference_type; - typedef _BiIter iterator; - - public: - bool matched; - - /** - * Gets the length of the matching sequence. - */ - difference_type - length() const - { return this->matched ? std::distance(this->first, this->second) : 0; } - - /** - * @brief Gets the matching sequence as a string. - * - * @returns the matching sequence as a string. - * - * This is the implicit conversion operator. It is identical to the - * str() member function except that it will want to pop up in - * unexpected places and cause a great deal of confusion and cursing - * from the unwary. - */ - operator basic_string<value_type>() const - { - return this->matched - ? std::basic_string<value_type>(this->first, this->second) - : std::basic_string<value_type>(); - } - - /** - * @brief Gets the matching sequence as a string. - * - * @returns the matching sequence as a string. - */ - basic_string<value_type> - str() const - { - return this->matched - ? std::basic_string<value_type>(this->first, this->second) - : std::basic_string<value_type>(); - } - - /** - * @brief Compares this and another matched sequence. - * - * @param s Another matched sequence to compare to this one. - * - * @retval <0 this matched sequence will collate before @p s. - * @retval =0 this matched sequence is equivalent to @p s. - * @retval <0 this matched sequence will collate after @p s. - */ - int - compare(const sub_match& __s) const - { return this->str().compare(__s.str()); } - - /** - * @brief Compares this sub_match to a string. - * - * @param s A string to compare to this sub_match. - * - * @retval <0 this matched sequence will collate before @p s. - * @retval =0 this matched sequence is equivalent to @p s. - * @retval <0 this matched sequence will collate after @p s. - */ - int - compare(const basic_string<value_type>& __s) const - { return this->str().compare(__s); } - - /** - * @brief Compares this sub_match to a C-style string. - * - * @param s A C-style string to compare to this sub_match. - * - * @retval <0 this matched sequence will collate before @p s. - * @retval =0 this matched sequence is equivalent to @p s. - * @retval <0 this matched sequence will collate after @p s. - */ - int - compare(const value_type* __s) const - { return this->str().compare(__s); } - }; - - - /** @brief Standard regex submatch over a C-style null-terminated string. */ - typedef sub_match<const char*> csub_match; - /** @brief Standard regex submatch over a standard string. */ - typedef sub_match<string::const_iterator> ssub_match; -#ifdef _GLIBCXX_USE_WCHAR_T - /** @brief Regex submatch over a C-style null-terminated wide string. */ - typedef sub_match<const wchar_t*> wcsub_match; - /** @brief Regex submatch over a standard wide string. */ - typedef sub_match<wstring::const_iterator> wssub_match; -#endif - - // [7.9.2] sub_match non-member operators - - /** - * @brief Tests the equivalence of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator==(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) == 0; } - - /** - * @brief Tests the inequivalence of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator!=(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) != 0; } - - /** - * @brief Tests the ordering of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator<(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) < 0; } - - /** - * @brief Tests the ordering of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator<=(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) <= 0; } - - /** - * @brief Tests the ordering of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator>=(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) >= 0; } - - /** - * @brief Tests the ordering of two regular expression submatches. - * @param lhs First regular expression submatch. - * @param rhs Second regular expression submatch. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _BiIter> - inline bool - operator>(const sub_match<_BiIter>& __lhs, - const sub_match<_BiIter>& __rhs) - { return __lhs.compare(__rhs) > 0; } - - /** - * @brief Tests the equivalence of a string and a regular expression - * submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator==(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs == __rhs.str(); } - - /** - * @brief Tests the inequivalence of a string and a regular expression - * submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator!=(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) - { return __lhs != __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator<(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) - { return __lhs < __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator>(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) - { return __lhs > __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator>=(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) - { return __lhs >= __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator<=(const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) - { return __lhs <= __rhs.str(); } - - /** - * @brief Tests the equivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator==(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() == __rhs; } - - /** - * @brief Tests the inequivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> - inline bool - operator!=(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() != __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> - inline bool - operator<(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() < __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> - inline bool - operator>(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() > __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> - inline bool - operator>=(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() >= __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> - inline bool - operator<=(const sub_match<_Bi_iter>& __lhs, - const basic_string< - typename iterator_traits<_Bi_iter>::value_type, - _Ch_traits, _Ch_alloc>& __rhs) - { return __lhs.str() <= __rhs; } - - /** - * @brief Tests the equivalence of a C string and a regular expression - * submatch. - * @param lhs A C string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs == __rhs.str(); } - - /** - * @brief Tests the inequivalence of an iterator value and a regular - * expression submatch. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs != __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs < __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs > __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs >= __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs <= __rhs.str(); } - - /** - * @brief Tests the equivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A pointer to a string? - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator==(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() == __rhs; } - - /** - * @brief Tests the inequivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A pointer to a string. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator!=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() != __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() < __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() > __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() >= __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A string. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const* __rhs) - { return __lhs.str() <= __rhs; } - - /** - * @brief Tests the equivalence of a string and a regular expression - * submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs == __rhs.str(); } - - /** - * @brief Tests the inequivalence of a string and a regular expression - * submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs != __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs < __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs > __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs >= __rhs.str(); } - - /** - * @brief Tests the ordering of a string and a regular expression submatch. - * @param lhs A string. - * @param rhs A regular expression submatch. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, - const sub_match<_Bi_iter>& __rhs) - { return __lhs <= __rhs.str(); } - - /** - * @brief Tests the equivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs is equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator==(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() == __rhs; } - - /** - * @brief Tests the inequivalence of a regular expression submatch and a - * string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator!=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() != __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs precedes @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() < __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs succeeds @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() > __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs does not precede @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator>=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() >= __rhs; } - - /** - * @brief Tests the ordering of a regular expression submatch and a string. - * @param lhs A regular expression submatch. - * @param rhs A const string reference. - * @returns true if @a lhs does not succeed @a rhs, false otherwise. - */ - template<typename _Bi_iter> - inline bool - operator<=(const sub_match<_Bi_iter>& __lhs, - typename iterator_traits<_Bi_iter>::value_type const& __rhs) - { return __lhs.str() <= __rhs; } - - /** - * @brief Inserts a matched string into an output stream. - * - * @param os The output stream. - * @param m A submatch string. - * - * @returns the output stream with the submatch string inserted. - */ - template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter> - inline - basic_ostream<_Ch_type, _Ch_traits>& - operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, - const sub_match<_Bi_iter>& __m) - { return __os << __m.str(); } - - // [7.10] Class template match_results - /** - * @brief The results of a match or search operation. - * - * A collection of character sequences representing the result of a regular - * expression match. Storage for the collection is allocated and freed as - * necessary by the member functions of class template match_results. - * - * This class satisfies the Sequence requirements, with the exception that - * only the operations defined for a const-qualified Sequence are supported. - * - * The sub_match object stored at index 0 represents sub-expression 0, i.e. - * the whole match. In this case the sub_match member matched is always true. - * The sub_match object stored at index n denotes what matched the marked - * sub-expression n within the matched expression. If the sub-expression n - * participated in a regular expression match then the sub_match member - * matched evaluates to true, and members first and second denote the range - * of characters [first, second) which formed that match. Otherwise matched - * is false, and members first and second point to the end of the sequence - * that was searched. - * - * @nosubgrouping - */ - template<typename _Bi_iter, - typename _Allocator = allocator<sub_match<_Bi_iter> > > - class match_results - : private std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator> - { - private: - typedef std::vector<std::_GLIBCXX_TR1 sub_match<_Bi_iter>, _Allocator> - _Base_type; - - public: - /** - * @name 10.? Public Types - */ - //@{ - typedef sub_match<_Bi_iter> value_type; - typedef typename _Allocator::const_reference const_reference; - typedef const_reference reference; - typedef typename _Base_type::const_iterator const_iterator; - typedef const_iterator iterator; - typedef typename iterator_traits<_Bi_iter>::difference_type - difference_type; - typedef typename _Allocator::size_type size_type; - typedef _Allocator allocator_type; - typedef typename iterator_traits<_Bi_iter>::value_type char_type; - typedef basic_string<char_type> string_type; - //@} - - public: - /** - * @name 10.1 Construction, Copying, and Destruction - */ - //@{ - - /** - * @brief Constructs a default %match_results container. - * @post size() returns 0 and str() returns an empty string. - */ - explicit - match_results(const _Allocator& __a = _Allocator()) - : _Base_type(__a), _M_matched(false) - { } - - /** - * @brief Copy constructs a %match_results. - */ - match_results(const match_results& __rhs) - : _Base_type(__rhs), _M_matched(__rhs._M_matched), - _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix) - { } - - /** - * @brief Assigns rhs to *this. - */ - match_results& - operator=(const match_results& __rhs) - { - match_results __tmp(__rhs); - this->swap(__tmp); - return *this; - } - - /** - * @brief Destroys a %match_results object. - */ - ~match_results() - { } - - //@} - - /** - * @name 10.2 Size - */ - //@{ - - /** - * @brief Gets the number of matches and submatches. - * - * The number of matches for a given regular expression will be either 0 - * if there was no match or mark_count() + 1 if a match was successful. - * Some matches may be empty. - * - * @returns the number of matches found. - */ - size_type - size() const - { return _M_matched ? _Base_type::size() + 1 : 0; } - - //size_type - //max_size() const; - using _Base_type::max_size; - - /** - * @brief Indicates if the %match_results contains no results. - * @retval true The %match_results object is empty. - * @retval false The %match_results object is not empty. - */ - bool - empty() const - { return size() == 0; } - - //@} - - /** - * @name 10.3 Element Access - */ - //@{ - - /** - * @brief Gets the length of the indicated submatch. - * @param sub indicates the submatch. - * - * This function returns the length of the indicated submatch, or the - * length of the entire match if @p sub is zero (the default). - */ - difference_type - length(size_type __sub = 0) const - { return _M_matched ? this->str(__sub).length() : 0; } - - /** - * @brief Gets the offset of the beginning of the indicated submatch. - * @param sub indicates the submatch. - * - * This function returns the offset from the beginning of the target - * sequence to the beginning of the submatch, unless the value of @p sub - * is zero (the default), in which case this function returns the offset - * from the beginning of the target sequence to the beginning of the - * match. - */ - difference_type - position(size_type __sub = 0) const - { - return _M_matched ? std::distance(this->prefix().first, - (*this)[__sub].first) : 0; - } - - /** - * @brief Gets the match or submatch converted to a string type. - * @param sub indicates the submatch. - * - * This function gets the submatch (or match, if @p sub is zero) extracted - * from the target range and converted to the associated string type. - */ - string_type - str(size_type __sub = 0) const - { return _M_matched ? (*this)[__sub].str() : string_type(); } - - /** - * @brief Gets a %sub_match reference for the match or submatch. - * @param sub indicates the submatch. - * - * This function gets a reference to the indicated submatch, or the entire - * match if @p sub is zero. - * - * If @p sub >= size() then this function returns a %sub_match with a - * special value indicating no submatch. - */ - const_reference - operator[](size_type __sub) const - { return _Base_type::operator[](__sub); } - - /** - * @brief Gets a %sub_match representing the match prefix. - * - * This function gets a reference to a %sub_match object representing the - * part of the target range between the start of the target range and the - * start of the match. - */ - const_reference - prefix() const - { return _M_prefix; } - - /** - * @brief Gets a %sub_match representing the match suffix. - * - * This function gets a reference to a %sub_match object representing the - * part of the target range between the end of the match and the end of - * the target range. - */ - const_reference - suffix() const - { return _M_suffix; } - - /** - * @brief Gets an iterator to the start of the %sub_match collection. - */ - const_iterator - begin() const - { return _Base_type::begin(); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - /** - * @brief Gets an iterator to the start of the %sub_match collection. - */ - const_iterator - cbegin() const - { return _Base_type::begin(); } -#endif - - /** - * @brief Gets an iterator to one-past-the-end of the collection. - */ - const_iterator - end() const - { return _Base_type::end(); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - /** - * @brief Gets an iterator to one-past-the-end of the collection. - */ - const_iterator - cend() const - { return _Base_type::end(); } -#endif - - //@} - - /** - * @name 10.4 Formatting - * - * These functions perform formatted substitution of the matched character - * sequences into their target. The format specifiers and escape sequences - * accepted by these functions are determined by their @p flags parameter - * as documented above. - */ - //@{ - - /** - * @todo Implement this function. - */ - template<typename _Out_iter> - _Out_iter - format(_Out_iter __out, const string_type& __fmt, - regex_constants::match_flag_type __flags - = regex_constants::format_default) const; - - /** - * @todo Implement this function. - */ - string_type - format(const string_type& __fmt, - regex_constants::match_flag_type __flags - = regex_constants::format_default) const; - - //@} - - /** - * @name 10.5 Allocator - */ - //@{ - - /** - * @brief Gets a copy of the allocator. - */ - //allocator_type - //get_allocator() const; - using _Base_type::get_allocator; - - //@} - - /** - * @name 10.6 Swap - */ - //@{ - - /** - * @brief Swaps the contents of two match_results. - */ - void - swap(match_results& __that) - { - _Base_type::swap(__that); - std::swap(_M_matched, __that._M_matched); - std::swap(_M_prefix, __that._M_prefix); - std::swap(_M_suffix, __that._M_suffix); - } - //@} - - private: - bool _M_matched; - value_type _M_prefix; - value_type _M_suffix; - }; - - typedef match_results<const char*> cmatch; - typedef match_results<string::const_iterator> smatch; -#ifdef _GLIBCXX_USE_WCHAR_T - typedef match_results<const wchar_t*> wcmatch; - typedef match_results<wstring::const_iterator> wsmatch; -#endif - - // match_results comparisons - /** - * @brief Compares two match_results for equality. - * @returns true if the two objects refer to the same match, - * false otherwise. - * @todo Implement this function. - */ - template<typename _Bi_iter, typename _Allocator> - inline bool - operator==(const match_results<_Bi_iter, _Allocator>& __m1, - const match_results<_Bi_iter, _Allocator>& __m2); - - /** - * @brief Compares two match_results for inequality. - * @returns true if the two objects do not refer to the same match, - * false otherwise. - */ - template<typename _Bi_iter, class _Allocator> - inline bool - operator!=(const match_results<_Bi_iter, _Allocator>& __m1, - const match_results<_Bi_iter, _Allocator>& __m2) - { return !(__m1 == __m2); } - - // [7.10.6] match_results swap - /** - * @brief Swaps two match results. - * @param lhs A match result. - * @param rhs A match result. - * - * The contents of the two match_results objects are swapped. - */ - template<typename _Bi_iter, typename _Allocator> - inline void - swap(match_results<_Bi_iter, _Allocator>& __lhs, - match_results<_Bi_iter, _Allocator>& __rhs) - { __lhs.swap(__rhs); } - - // [7.11.2] Function template regex_match - /** - * @name Matching, Searching, and Replacing - */ - //@{ - - /** - * @brief Determines if there is a match between the regular expression @p e - * and all of the character sequence [first, last). - * - * @param first Beginning of the character sequence to match. - * @param last One-past-the-end of the character sequence to match. - * @param m The match results. - * @param re The regular expression. - * @param flags Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - * - * @todo Implement this function. - */ - template<typename _Bi_iter, typename _Allocator, - typename _Ch_type, typename _Rx_traits> - bool - regex_match(_Bi_iter __first, _Bi_iter __last, - match_results<_Bi_iter, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default); - - /** - * @brief Indicates if there is a match between the regular expression @p e - * and all of the character sequence [first, last). - * - * @param first Beginning of the character sequence to match. - * @param last One-past-the-end of the character sequence to match. - * @param re The regular expression. - * @param flags Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - */ - template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> - bool - regex_match(_Bi_iter __first, _Bi_iter __last, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { - match_results<_Bi_iter> __what; - return regex_match(__first, __last, __what, __re, __flags); - } - - /** - * @brief Determines if there is a match between the regular expression @p e - * and a C-style null-terminated string. - * - * @param s The C-style null-terminated string to match. - * @param m The match results. - * @param re The regular expression. - * @param f Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_type, typename _Allocator, typename _Rx_traits> - inline bool - regex_match(const _Ch_type* __s, - match_results<const _Ch_type*, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __f - = regex_constants::match_default) - { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } - - /** - * @brief Determines if there is a match between the regular expression @p e - * and a string. - * - * @param s The string to match. - * @param m The match results. - * @param re The regular expression. - * @param flags Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_traits, typename _Ch_alloc, - typename _Allocator, typename _Ch_type, typename _Rx_traits> - inline bool - regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, - match_results<typename basic_string<_Ch_type, - _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } - - /** - * @brief Indicates if there is a match between the regular expression @p e - * and a C-style null-terminated string. - * - * @param s The C-style null-terminated string to match. - * @param re The regular expression. - * @param f Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_type, class _Rx_traits> - inline bool - regex_match(const _Ch_type* __s, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __f - = regex_constants::match_default) - { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } - - /** - * @brief Indicates if there is a match between the regular expression @p e - * and a string. - * - * @param s [IN] The string to match. - * @param re [IN] The regular expression. - * @param flags [IN] Controls how the regular expression is matched. - * - * @retval true A match exists. - * @retval false Otherwise. - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_traits, typename _Str_allocator, - typename _Ch_type, typename _Rx_traits> - inline bool - regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { return regex_match(__s.begin(), __s.end(), __re, __flags); } - - // [7.11.3] Function template regex_search - /** - * Searches for a regular expression within a range. - * @param first [IN] The start of the string to search. - * @param last [IN] One-past-the-end of the string to search. - * @param m [OUT] The match results. - * @param re [IN] The regular expression to search for. - * @param flags [IN] Search policy flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string, the content of %m is - * undefined. - * - * @throws an exception of type regex_error. - * - * @todo Implement this function. - */ - template<typename _Bi_iter, typename _Allocator, - typename _Ch_type, typename _Rx_traits> - inline bool - regex_search(_Bi_iter __first, _Bi_iter __last, - match_results<_Bi_iter, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default); - - /** - * Searches for a regular expression within a range. - * @param first [IN] The start of the string to search. - * @param last [IN] One-past-the-end of the string to search. - * @param re [IN] The regular expression to search for. - * @param flags [IN] Search policy flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string. - * @doctodo - * - * @throws an exception of type regex_error. - */ - template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> - inline bool - regex_search(_Bi_iter __first, _Bi_iter __last, - const basic_regex<_Ch_type, _Rx_traits>& __re, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { - match_results<_Bi_iter> __what; - return regex_search(__first, __last, __what, __re, __flags); - } - - /** - * @brief Searches for a regular expression within a C-string. - * @param s [IN] A C-string to search for the regex. - * @param m [OUT] The set of regex matches. - * @param e [IN] The regex to search for in @p s. - * @param f [IN] The search flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string, the content of %m is - * undefined. - * @doctodo - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_type, class _Allocator, class _Rx_traits> - inline bool - regex_search(const _Ch_type* __s, - match_results<const _Ch_type*, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __e, - regex_constants::match_flag_type __f - = regex_constants::match_default) - { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } - - /** - * @brief Searches for a regular expression within a C-string. - * @param s [IN] The C-string to search. - * @param e [IN] The regular expression to search for. - * @param f [IN] Search policy flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string. - * @doctodo - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_type, typename _Rx_traits> - inline bool - regex_search(const _Ch_type* __s, - const basic_regex<_Ch_type, _Rx_traits>& __e, - regex_constants::match_flag_type __f - = regex_constants::match_default) - { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } - - /** - * @brief Searches for a regular expression within a string. - * @param s [IN] The string to search. - * @param e [IN] The regular expression to search for. - * @param flags [IN] Search policy flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string. - * @doctodo - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_traits, typename _String_allocator, - typename _Ch_type, typename _Rx_traits> - inline bool - regex_search(const basic_string<_Ch_type, _Ch_traits, - _String_allocator>& __s, - const basic_regex<_Ch_type, _Rx_traits>& __e, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { return regex_search(__s.begin(), __s.end(), __e, __flags); } - - /** - * @brief Searches for a regular expression within a string. - * @param s [IN] A C++ string to search for the regex. - * @param m [OUT] The set of regex matches. - * @param e [IN] The regex to search for in @p s. - * @param f [IN] The search flags. - * @retval true A match was found within the string. - * @retval false No match was found within the string, the content of %m is - * undefined. - * - * @throws an exception of type regex_error. - */ - template<typename _Ch_traits, typename _Ch_alloc, - typename _Allocator, typename _Ch_type, - typename _Rx_traits> - inline bool - regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, - match_results<typename basic_string<_Ch_type, - _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, - const basic_regex<_Ch_type, _Rx_traits>& __e, - regex_constants::match_flag_type __f - = regex_constants::match_default) - { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } - - // tr1 [7.11.4] std [28.11.4] Function template regex_replace - /** - * @doctodo - * @param out - * @param first - * @param last - * @param e - * @param fmt - * @param flags - * - * @returns out - * @throws an exception of type regex_error. - * - * @todo Implement this function. - */ - template<typename _Out_iter, typename _Bi_iter, - typename _Rx_traits, typename _Ch_type> - inline _Out_iter - regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, - const basic_regex<_Ch_type, _Rx_traits>& __e, - const basic_string<_Ch_type>& __fmt, - regex_constants::match_flag_type __flags - = regex_constants::match_default); - - /** - * @doctodo - * @param s - * @param e - * @param fmt - * @param flags - * - * @returns a copy of string @p s with replacements. - * - * @throws an exception of type regex_error. - */ - template<typename _Rx_traits, typename _Ch_type> - inline basic_string<_Ch_type> - regex_replace(const basic_string<_Ch_type>& __s, - const basic_regex<_Ch_type, _Rx_traits>& __e, - const basic_string<_Ch_type>& __fmt, - regex_constants::match_flag_type __flags - = regex_constants::match_default) - { - std::string __result; - regex_replace(std::back_inserter(__result), - __s.begin(), __s.end(), __e, __fmt, __flags); - return __result; - } - - //@} - - // tr1 [7.12.1] std [28.12] Class template regex_iterator - /** - * An iterator adaptor that will provide repeated calls of regex_search over - * a range until no more matches remain. - */ - template<typename _Bi_iter, - typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, - typename _Rx_traits = regex_traits<_Ch_type> > - class regex_iterator - { - public: - typedef basic_regex<_Ch_type, _Rx_traits> regex_type; - typedef match_results<_Bi_iter> value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - public: - /** - * @brief Provides a singular iterator, useful for indicating - * one-past-the-end of a range. - * @todo Implement this function. - * @doctodo - */ - regex_iterator(); - - /** - * Constructs a %regex_iterator... - * @param a [IN] The start of a text range to search. - * @param b [IN] One-past-the-end of the text range to search. - * @param re [IN] The regular expression to match. - * @param m [IN] Policy flags for match rules. - * @todo Implement this function. - * @doctodo - */ - regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, - regex_constants::match_flag_type __m - = regex_constants::match_default); - - /** - * Copy constructs a %regex_iterator. - * @todo Implement this function. - * @doctodo - */ - regex_iterator(const regex_iterator& __rhs); - - /** - * @todo Implement this function. - * @doctodo - */ - regex_iterator& - operator=(const regex_iterator& __rhs); - - /** - * @todo Implement this function. - * @doctodo - */ - bool - operator==(const regex_iterator& __rhs); - - /** - * @todo Implement this function. - * @doctodo - */ - bool - operator!=(const regex_iterator& __rhs); - - /** - * @todo Implement this function. - * @doctodo - */ - const value_type& - operator*(); - - /** - * @todo Implement this function. - * @doctodo - */ - const value_type* - operator->(); - - /** - * @todo Implement this function. - * @doctodo - */ - regex_iterator& - operator++(); - - /** - * @todo Implement this function. - * @doctodo - */ - regex_iterator - operator++(int); - - private: - // these members are shown for exposition only: - _Bi_iter begin; - _Bi_iter end; - const regex_type* pregex; - regex_constants::match_flag_type flags; - match_results<_Bi_iter> match; - }; - - typedef regex_iterator<const char*> cregex_iterator; - typedef regex_iterator<string::const_iterator> sregex_iterator; -#ifdef _GLIBCXX_USE_WCHAR_T - typedef regex_iterator<const wchar_t*> wcregex_iterator; - typedef regex_iterator<wstring::const_iterator> wsregex_iterator; -#endif - - // [7.12.2] Class template regex_token_iterator - /** - * Iterates over submatches in a range (or @a splits a text string). - * - * The purpose of this iterator is to enumerate all, or all specified, - * matches of a regular expression within a text range. The dereferenced - * value of an iterator of this class is a std::tr1::sub_match object. - */ - template<typename _Bi_iter, - typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, - typename _Rx_traits = regex_traits<_Ch_type> > - class regex_token_iterator - { - public: - typedef basic_regex<_Ch_type, _Rx_traits> regex_type; - typedef sub_match<_Bi_iter> value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; - typedef std::forward_iterator_tag iterator_category; - - public: - /** - * @brief Default constructs a %regex_token_iterator. - * @todo Implement this function. - * - * A default-constructed %regex_token_iterator is a singular iterator - * that will compare equal to the one-past-the-end value for any - * iterator of the same type. - */ - regex_token_iterator(); - - /** - * Constructs a %regex_token_iterator... - * @param a [IN] The start of the text to search. - * @param b [IN] One-past-the-end of the text to search. - * @param re [IN] The regular expression to search for. - * @param submatch [IN] Which submatch to return. There are some - * special values for this parameter: - * - -1 each enumerated subexpression does NOT - * match the regular expression (aka field - * splitting) - * - 0 the entire string matching the - * subexpression is returned for each match - * within the text. - * - >0 enumerates only the indicated - * subexpression from a match within the text. - * @param m [IN] Policy flags for match rules. - * - * @todo Implement this function. - * @doctodo - */ - regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, - int __submatch = 0, - regex_constants::match_flag_type __m - = regex_constants::match_default); - - /** - * Constructs a %regex_token_iterator... - * @param a [IN] The start of the text to search. - * @param b [IN] One-past-the-end of the text to search. - * @param re [IN] The regular expression to search for. - * @param submatches [IN] A list of subexpressions to return for each - * regular expression match within the text. - * @param m [IN] Policy flags for match rules. - * - * @todo Implement this function. - * @doctodo - */ - regex_token_iterator(_Bi_iter __a, _Bi_iter __b, - const regex_type& __re, - const std::vector<int>& __submatches, - regex_constants::match_flag_type __m - = regex_constants::match_default); - - /** - * Constructs a %regex_token_iterator... - * @param a [IN] The start of the text to search. - * @param b [IN] One-past-the-end of the text to search. - * @param re [IN] The regular expression to search for. - * @param submatches [IN] A list of subexpressions to return for each - * regular expression match within the text. - * @param m [IN] Policy flags for match rules. - - * @todo Implement this function. - * @doctodo - */ - template<std::size_t _Nm> - regex_token_iterator(_Bi_iter __a, _Bi_iter __b, - const regex_type& __re, - const int (&__submatches)[_Nm], - regex_constants::match_flag_type __m - = regex_constants::match_default); - - /** - * @brief Copy constructs a %regex_token_iterator. - * @param rhs [IN] A %regex_token_iterator to copy. - * @todo Implement this function. - */ - regex_token_iterator(const regex_token_iterator& __rhs); - - /** - * @brief Assigns a %regex_token_iterator to another. - * @param rhs [IN] A %regex_token_iterator to copy. - * @todo Implement this function. - */ - regex_token_iterator& - operator=(const regex_token_iterator& __rhs); - - /** - * @brief Compares a %regex_token_iterator to another for equality. - * @todo Implement this function. - */ - bool - operator==(const regex_token_iterator& __rhs); - - /** - * @brief Compares a %regex_token_iterator to another for inequality. - * @todo Implement this function. - */ - bool - operator!=(const regex_token_iterator& __rhs); - - /** - * @brief Dereferences a %regex_token_iterator. - * @todo Implement this function. - */ - const value_type& - operator*(); - - /** - * @brief Selects a %regex_token_iterator member. - * @todo Implement this function. - */ - const value_type* - operator->(); - - /** - * @brief Increments a %regex_token_iterator. - * @todo Implement this function. - */ - regex_token_iterator& - operator++(); - - /** - * @brief Postincrements a %regex_token_iterator. - * @todo Implement this function. - */ - regex_token_iterator - operator++(int); - - private: // data members for exposition only: - typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator; - - position_iterator __position; - const value_type* __result; - value_type __suffix; - std::size_t __n; - std::vector<int> __subs; - }; - - /** @brief Token iterator for C-style NULL-terminated strings. */ - typedef regex_token_iterator<const char*> cregex_token_iterator; - /** @brief Token iterator for standard strings. */ - typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; -#ifdef _GLIBCXX_USE_WCHAR_T - /** @brief Token iterator for C-style NULL-terminated wide strings. */ - typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; - /** @brief Token iterator for standard wide-character strings. */ - typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; -#endif - - //@} - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/type_traits b/libstdc++-v3/include/tr1_impl/type_traits deleted file mode 100644 index 2f6080a19bf..00000000000 --- a/libstdc++-v3/include/tr1_impl/type_traits +++ /dev/null @@ -1,506 +0,0 @@ -// TR1 type_traits -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/type_traits -* This is an internal header file, included by other library headers. -* You should not attempt to use it directly. -*/ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - /** - * @defgroup metaprogramming Type Traits - * @ingroup utilities - * - * Compile time type transformation and information. - * @{ - */ - - // For use in __is_convertible_simple. - struct __sfinae_types - { - typedef char __one; - typedef struct { char __arr[2]; } __two; - }; - -#define _DEFINE_SPEC_0_HELPER \ - template<> - -#define _DEFINE_SPEC_1_HELPER \ - template<typename _Tp> - -#define _DEFINE_SPEC_2_HELPER \ - template<typename _Tp, typename _Cp> - -#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \ - _DEFINE_SPEC_##_Order##_HELPER \ - struct _Trait<_Type> \ - : public integral_constant<bool, _Value> { }; - - // helper classes [4.3]. - - /// integral_constant - template<typename _Tp, _Tp __v> - struct integral_constant - { - static _GLIBCXX_USE_CONSTEXPR _Tp value = __v; - typedef _Tp value_type; - typedef integral_constant<_Tp, __v> type; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - constexpr operator value_type() { return value; } -#endif - }; - - /// typedef for true_type - typedef integral_constant<bool, true> true_type; - - /// typedef for false_type - typedef integral_constant<bool, false> false_type; - - template<typename _Tp, _Tp __v> - _GLIBCXX_USE_CONSTEXPR _Tp integral_constant<_Tp, __v>::value; - - /// remove_cv - template<typename> - struct remove_cv; - - template<typename> - struct __is_void_helper - : public false_type { }; - _DEFINE_SPEC(0, __is_void_helper, void, true) - - // primary type categories [4.5.1]. - - /// is_void - template<typename _Tp> - struct is_void - : public integral_constant<bool, (__is_void_helper<typename - remove_cv<_Tp>::type>::value)> - { }; - - template<typename> - struct __is_integral_helper - : public false_type { }; - _DEFINE_SPEC(0, __is_integral_helper, bool, true) - _DEFINE_SPEC(0, __is_integral_helper, char, true) - _DEFINE_SPEC(0, __is_integral_helper, signed char, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true) -#ifdef _GLIBCXX_USE_WCHAR_T - _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true) -#endif -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - _DEFINE_SPEC(0, __is_integral_helper, char16_t, true) - _DEFINE_SPEC(0, __is_integral_helper, char32_t, true) -#endif - _DEFINE_SPEC(0, __is_integral_helper, short, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true) - _DEFINE_SPEC(0, __is_integral_helper, int, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned int, true) - _DEFINE_SPEC(0, __is_integral_helper, long, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned long, true) - _DEFINE_SPEC(0, __is_integral_helper, long long, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true) - - /// is_integral - template<typename _Tp> - struct is_integral - : public integral_constant<bool, (__is_integral_helper<typename - remove_cv<_Tp>::type>::value)> - { }; - - template<typename> - struct __is_floating_point_helper - : public false_type { }; - _DEFINE_SPEC(0, __is_floating_point_helper, float, true) - _DEFINE_SPEC(0, __is_floating_point_helper, double, true) - _DEFINE_SPEC(0, __is_floating_point_helper, long double, true) - - /// is_floating_point - template<typename _Tp> - struct is_floating_point - : public integral_constant<bool, (__is_floating_point_helper<typename - remove_cv<_Tp>::type>::value)> - { }; - - /// is_array - template<typename> - struct is_array - : public false_type { }; - - template<typename _Tp, std::size_t _Size> - struct is_array<_Tp[_Size]> - : public true_type { }; - - template<typename _Tp> - struct is_array<_Tp[]> - : public true_type { }; - - template<typename> - struct __is_pointer_helper - : public false_type { }; - _DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true) - - /// is_pointer - template<typename _Tp> - struct is_pointer - : public integral_constant<bool, (__is_pointer_helper<typename - remove_cv<_Tp>::type>::value)> - { }; - - /// is_reference - template<typename _Tp> - struct is_reference; - - /// is_function - template<typename _Tp> - struct is_function; - - template<typename> - struct __is_member_object_pointer_helper - : public false_type { }; - _DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*, - !is_function<_Tp>::value) - - /// is_member_object_pointer - template<typename _Tp> - struct is_member_object_pointer - : public integral_constant<bool, (__is_member_object_pointer_helper< - typename remove_cv<_Tp>::type>::value)> - { }; - - template<typename> - struct __is_member_function_pointer_helper - : public false_type { }; - _DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*, - is_function<_Tp>::value) - - /// is_member_function_pointer - template<typename _Tp> - struct is_member_function_pointer - : public integral_constant<bool, (__is_member_function_pointer_helper< - typename remove_cv<_Tp>::type>::value)> - { }; - - /// is_enum - template<typename _Tp> - struct is_enum - : public integral_constant<bool, __is_enum(_Tp)> - { }; - - /// is_union - template<typename _Tp> - struct is_union - : public integral_constant<bool, __is_union(_Tp)> - { }; - - /// is_class - template<typename _Tp> - struct is_class - : public integral_constant<bool, __is_class(_Tp)> - { }; - - /// is_function - template<typename> - struct is_function - : public false_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes...)> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes......)> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes...) const> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes......) const> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes...) volatile> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes......) volatile> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes...) const volatile> - : public true_type { }; - template<typename _Res, typename... _ArgTypes> - struct is_function<_Res(_ArgTypes......) const volatile> - : public true_type { }; - - // composite type traits [4.5.2]. - - /// is_arithmetic - template<typename _Tp> - struct is_arithmetic - : public integral_constant<bool, (is_integral<_Tp>::value - || is_floating_point<_Tp>::value)> - { }; - - /// is_fundamental - template<typename _Tp> - struct is_fundamental - : public integral_constant<bool, (is_arithmetic<_Tp>::value - || is_void<_Tp>::value)> - { }; - - /// is_object - template<typename _Tp> - struct is_object - : public integral_constant<bool, !(is_function<_Tp>::value - || is_reference<_Tp>::value - || is_void<_Tp>::value)> - { }; - - /// is_member_pointer - template<typename _Tp> - struct is_member_pointer; - - /// is_scalar - template<typename _Tp> - struct is_scalar - : public integral_constant<bool, (is_arithmetic<_Tp>::value - || is_enum<_Tp>::value - || is_pointer<_Tp>::value - || is_member_pointer<_Tp>::value)> - { }; - - /// is_compound - template<typename _Tp> - struct is_compound - : public integral_constant<bool, !is_fundamental<_Tp>::value> { }; - - /// is_member_pointer - template<typename _Tp> - struct __is_member_pointer_helper - : public false_type { }; - _DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true) - - template<typename _Tp> - struct is_member_pointer - : public integral_constant<bool, (__is_member_pointer_helper< - typename remove_cv<_Tp>::type>::value)> - { }; - - // type properties [4.5.3]. - /// is_const - template<typename> - struct is_const - : public false_type { }; - - template<typename _Tp> - struct is_const<_Tp const> - : public true_type { }; - - /// is_volatile - template<typename> - struct is_volatile - : public false_type { }; - - template<typename _Tp> - struct is_volatile<_Tp volatile> - : public true_type { }; - - /// is_empty - template<typename _Tp> - struct is_empty - : public integral_constant<bool, __is_empty(_Tp)> - { }; - - /// is_polymorphic - template<typename _Tp> - struct is_polymorphic - : public integral_constant<bool, __is_polymorphic(_Tp)> - { }; - - /// is_abstract - template<typename _Tp> - struct is_abstract - : public integral_constant<bool, __is_abstract(_Tp)> - { }; - - /// has_virtual_destructor - template<typename _Tp> - struct has_virtual_destructor - : public integral_constant<bool, __has_virtual_destructor(_Tp)> - { }; - - /// alignment_of - template<typename _Tp> - struct alignment_of - : public integral_constant<std::size_t, __alignof__(_Tp)> { }; - - /// rank - template<typename> - struct rank - : public integral_constant<std::size_t, 0> { }; - - template<typename _Tp, std::size_t _Size> - struct rank<_Tp[_Size]> - : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; - - template<typename _Tp> - struct rank<_Tp[]> - : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; - - /// extent - template<typename, unsigned _Uint = 0> - struct extent - : public integral_constant<std::size_t, 0> { }; - - template<typename _Tp, unsigned _Uint, std::size_t _Size> - struct extent<_Tp[_Size], _Uint> - : public integral_constant<std::size_t, - _Uint == 0 ? _Size : extent<_Tp, - _Uint - 1>::value> - { }; - - template<typename _Tp, unsigned _Uint> - struct extent<_Tp[], _Uint> - : public integral_constant<std::size_t, - _Uint == 0 ? 0 : extent<_Tp, - _Uint - 1>::value> - { }; - - // relationships between types [4.6]. - - /// is_same - template<typename, typename> - struct is_same - : public false_type { }; - - template<typename _Tp> - struct is_same<_Tp, _Tp> - : public true_type { }; - - // const-volatile modifications [4.7.1]. - - /// remove_const - template<typename _Tp> - struct remove_const - { typedef _Tp type; }; - - template<typename _Tp> - struct remove_const<_Tp const> - { typedef _Tp type; }; - - /// remove_volatile - template<typename _Tp> - struct remove_volatile - { typedef _Tp type; }; - - template<typename _Tp> - struct remove_volatile<_Tp volatile> - { typedef _Tp type; }; - - /// remove_cv - template<typename _Tp> - struct remove_cv - { - typedef typename - remove_const<typename remove_volatile<_Tp>::type>::type type; - }; - - /// add_const - template<typename _Tp> - struct add_const - { typedef _Tp const type; }; - - /// add_volatile - template<typename _Tp> - struct add_volatile - { typedef _Tp volatile type; }; - - /// add_cv - template<typename _Tp> - struct add_cv - { - typedef typename - add_const<typename add_volatile<_Tp>::type>::type type; - }; - - // array modifications [4.7.3]. - - /// remove_extent - template<typename _Tp> - struct remove_extent - { typedef _Tp type; }; - - template<typename _Tp, std::size_t _Size> - struct remove_extent<_Tp[_Size]> - { typedef _Tp type; }; - - template<typename _Tp> - struct remove_extent<_Tp[]> - { typedef _Tp type; }; - - /// remove_all_extents - template<typename _Tp> - struct remove_all_extents - { typedef _Tp type; }; - - template<typename _Tp, std::size_t _Size> - struct remove_all_extents<_Tp[_Size]> - { typedef typename remove_all_extents<_Tp>::type type; }; - - template<typename _Tp> - struct remove_all_extents<_Tp[]> - { typedef typename remove_all_extents<_Tp>::type type; }; - - // pointer modifications [4.7.4]. - - template<typename _Tp, typename> - struct __remove_pointer_helper - { typedef _Tp type; }; - - template<typename _Tp, typename _Up> - struct __remove_pointer_helper<_Tp, _Up*> - { typedef _Up type; }; - - /// remove_pointer - template<typename _Tp> - struct remove_pointer - : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> - { }; - - template<typename> - struct remove_reference; - - /// add_pointer - template<typename _Tp> - struct add_pointer - { typedef typename remove_reference<_Tp>::type* type; }; - -#undef _DEFINE_SPEC_0_HELPER -#undef _DEFINE_SPEC_1_HELPER -#undef _DEFINE_SPEC_2_HELPER -#undef _DEFINE_SPEC - - // @} group metaprogramming - -_GLIBCXX_END_NAMESPACE_TR1 -} diff --git a/libstdc++-v3/include/tr1_impl/utility b/libstdc++-v3/include/tr1_impl/utility deleted file mode 100644 index 71b8719f5ff..00000000000 --- a/libstdc++-v3/include/tr1_impl/utility +++ /dev/null @@ -1,120 +0,0 @@ -// TR1 utility -*- C++ -*- - -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 3, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// <http://www.gnu.org/licenses/>. - -/** @file tr1_impl/utility - * This is an internal header file, included by other library headers. - * You should not attempt to use it directly. - */ - -namespace std -{ -_GLIBCXX_BEGIN_NAMESPACE_TR1 - - template<class _Tp> - class tuple_size; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, class _Tp> -#else - template<int _Int, class _Tp> -#endif - class tuple_element; - - // Various functions which give std::pair a tuple-like interface. - template<class _Tp1, class _Tp2> - struct tuple_size<std::pair<_Tp1, _Tp2> > -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - { static const std::size_t value = 2; }; -#else - { static const int value = 2; }; -#endif - - template<class _Tp1, class _Tp2> -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - const std::size_t -#else - const int -#endif - tuple_size<std::pair<_Tp1, _Tp2> >::value; - - template<class _Tp1, class _Tp2> - struct tuple_element<0, std::pair<_Tp1, _Tp2> > - { typedef _Tp1 type; }; - - template<class _Tp1, class _Tp2> - struct tuple_element<1, std::pair<_Tp1, _Tp2> > - { typedef _Tp2 type; }; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int> -#else - template<int _Int> -#endif - struct __pair_get; - - template<> - struct __pair_get<0> - { - template<typename _Tp1, typename _Tp2> - static _Tp1& __get(std::pair<_Tp1, _Tp2>& __pair) - { return __pair.first; } - - template<typename _Tp1, typename _Tp2> - static const _Tp1& __const_get(const std::pair<_Tp1, _Tp2>& __pair) - { return __pair.first; } - }; - - template<> - struct __pair_get<1> - { - template<typename _Tp1, typename _Tp2> - static _Tp2& __get(std::pair<_Tp1, _Tp2>& __pair) - { return __pair.second; } - - template<typename _Tp1, typename _Tp2> - static const _Tp2& __const_get(const std::pair<_Tp1, _Tp2>& __pair) - { return __pair.second; } - }; - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, class _Tp1, class _Tp2> -#else - template<int _Int, class _Tp1, class _Tp2> -#endif - inline typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& - get(std::pair<_Tp1, _Tp2>& __in) - { return __pair_get<_Int>::__get(__in); } - -#ifdef _GLIBCXX_INCLUDE_AS_CXX0X - template<std::size_t _Int, class _Tp1, class _Tp2> -#else - template<int _Int, class _Tp1, class _Tp2> -#endif - inline const typename tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& - get(const std::pair<_Tp1, _Tp2>& __in) - { return __pair_get<_Int>::__const_get(__in); } - -_GLIBCXX_END_NAMESPACE_TR1 -} - diff --git a/libstdc++-v3/src/atomic.cc b/libstdc++-v3/src/atomic.cc index 08d4d03ac8c..822e022b7e5 100644 --- a/libstdc++-v3/src/atomic.cc +++ b/libstdc++-v3/src/atomic.cc @@ -49,8 +49,8 @@ namespace }; } // anonymous namespace -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace __atomic0 { bool @@ -115,7 +115,8 @@ namespace std _GLIBCXX_END_EXTERN_C } // namespace __atomic0 -} // namespace std + +_GLIBCXX_END_NAMESPACE // XXX GLIBCXX_ABI Deprecated diff --git a/libstdc++-v3/src/chrono.cc b/libstdc++-v3/src/chrono.cc index 6d7a64d0080..699a10a7253 100644 --- a/libstdc++-v3/src/chrono.cc +++ b/libstdc++-v3/src/chrono.cc @@ -33,8 +33,8 @@ #include <sys/time.h> #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace chrono { const bool system_clock::is_monotonic; @@ -74,6 +74,7 @@ namespace std } #endif } -} + +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/src/condition_variable.cc b/libstdc++-v3/src/condition_variable.cc index d3f29f657f4..e7adb5251be 100644 --- a/libstdc++-v3/src/condition_variable.cc +++ b/libstdc++-v3/src/condition_variable.cc @@ -26,8 +26,8 @@ #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + condition_variable::condition_variable() throw () { #ifdef __GTHREAD_COND_INIT @@ -84,6 +84,7 @@ namespace std condition_variable_any::~condition_variable_any() throw () { } -} + +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/src/future.cc b/libstdc++-v3/src/future.cc index 1c9151972af..ed3088d87d6 100644 --- a/libstdc++-v3/src/future.cc +++ b/libstdc++-v3/src/future.cc @@ -64,8 +64,8 @@ namespace } } -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + const error_category& future_category() { return __future_category_instance(); } @@ -73,4 +73,5 @@ namespace std const char* future_error::what() const throw() { return _M_code.message().c_str(); } -} + +_GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/src/mutex.cc b/libstdc++-v3/src/mutex.cc index 2e9124d3d5f..e6eb6d28a72 100644 --- a/libstdc++-v3/src/mutex.cc +++ b/libstdc++-v3/src/mutex.cc @@ -37,8 +37,8 @@ namespace } #endif -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + #ifdef _GLIBCXX_HAVE_TLS __thread void* __once_callable; __thread void (*__once_call)(); @@ -88,7 +88,8 @@ namespace std __once_call(); } } -} + +_GLIBCXX_END_NAMESPACE // XXX GLIBCXX_ABI Deprecated // gcc-4.6.0 diff --git a/libstdc++-v3/src/thread.cc b/libstdc++-v3/src/thread.cc index 2ea6a490735..acc6c038531 100644 --- a/libstdc++-v3/src/thread.cc +++ b/libstdc++-v3/src/thread.cc @@ -28,8 +28,8 @@ #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + namespace { extern "C" void* @@ -95,6 +95,7 @@ namespace std __throw_system_error(__e); } } -} + +_GLIBCXX_END_NAMESPACE #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index b18ff2f2a59..65516cca230 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 688 } +// { dg-error "static assertion failed" "" { target *-*-* } 1119 } #include <utility> diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc index 7dab6f12977..aae7e04c861 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -31,5 +31,5 @@ void test01() test_type d; } -// { dg-error "rep cannot be a duration" "" { target *-*-* } 210 } +// { dg-error "rep cannot be a duration" "" { target *-*-* } 206 } // { dg-error "instantiated from here" "" { target *-*-* } 31 } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc index 640574991bf..33ae9d57d00 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -3,7 +3,7 @@ // { dg-require-cstdint "" } // 2008-07-31 Chris Fairles <chris.fairles@gmail.com> -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,6 +32,6 @@ void test01() test_type d; } -// { dg-error "must be a specialization of ratio" "" { target *-*-* } 211 } +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 207 } // { dg-error "instantiated from here" "" { target *-*-* } 32 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc index d6163867fb5..4faf93a4873 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -3,7 +3,7 @@ // { dg-require-cstdint "" } // 2008-07-31 Chris Fairles <chris.fairles@gmail.com> -// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -33,5 +33,5 @@ void test01() test_type d; } -// { dg-error "period must be positive" "" { target *-*-* } 213 } +// { dg-error "period must be positive" "" { target *-*-* } 209 } // { dg-error "instantiated from here" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index d74f4e6351e..fc5744083c9 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 651 } -// { dg-error "declaration of" "" { target *-*-* } 615 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1082 } +// { dg-error "declaration of" "" { target *-*-* } 1046 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 18fd4fbb72f..abbaefd65a7 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 574 } -// { dg-error "declaration of" "" { target *-*-* } 538 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1005 } +// { dg-error "declaration of" "" { target *-*-* } 969 } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc index adc005d0c50..fb6cc8f5b72 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820.cc @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr<X> p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 566 } + // { dg-error "incomplete" "" { target *-*-* } 762 } std::shared_ptr<X> p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 658 } + // { dg-error "incomplete" "" { target *-*-* } 854 } } diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index b8cf6d8c08c..42a4da992a4 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -42,8 +42,8 @@ main() } // { dg-warning "note" "" { target *-*-* } 347 } +// { dg-warning "note" "" { target *-*-* } 1079 } // { dg-warning "note" "" { target *-*-* } 465 } -// { dg-warning "note" "" { target *-*-* } 883 } // { dg-warning "note" "" { target *-*-* } 580 } // { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 340 } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820.cc index a80a2eec85f..73a0f9e276b 100644 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820.cc +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820.cc @@ -30,9 +30,9 @@ void test01() { X* px = 0; std::tr1::shared_ptr<X> p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 370 } + // { dg-error "incomplete" "" { target *-*-* } 561 } std::tr1::shared_ptr<X> p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 409 } + // { dg-error "incomplete" "" { target *-*-* } 600 } } |