Commit 53dc5044 by Paolo Carlini Committed by Paolo Carlini

cinttypes: Remove, move contents to C++0x and TR1 headers.

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.

From-SVN: r166211
parent a9992f7f
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 2010-11-02 Paolo Carlini <paolo.carlini@oracle.com
* testsuite/28_regex/05_constants/syntax_option_type.cc: Avoid * testsuite/28_regex/05_constants/syntax_option_type.cc: Avoid
......
...@@ -610,26 +610,6 @@ tr1_headers = \ ...@@ -610,26 +610,6 @@ tr1_headers = \
${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wchar.h \
${tr1_srcdir}/wctype.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_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal decimal_builddir = ./decimal
decimal_headers = \ decimal_headers = \
...@@ -908,9 +888,9 @@ endif ...@@ -908,9 +888,9 @@ endif
# CLEANFILES and all-local are kept up-to-date. # CLEANFILES and all-local are kept up-to-date.
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr1-impl \ stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \
stamp-decimal stamp-debug stamp-parallel stamp-profile \ stamp-debug stamp-parallel stamp-profile stamp-profile-impl \
stamp-profile-impl stamp-host stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
# catenation. # catenation.
...@@ -1019,11 +999,6 @@ stamp-tr1: ${tr1_headers} ...@@ -1019,11 +999,6 @@ stamp-tr1: ${tr1_headers}
@-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1 @$(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} stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir} @-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
...@@ -1254,9 +1229,6 @@ install-headers: ...@@ -1254,9 +1229,6 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir}
for file in ${tr1_headers}; do \ for file in ${tr1_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done $(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} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \ for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
...@@ -1303,11 +1275,10 @@ clean-local: ...@@ -1303,11 +1275,10 @@ clean-local:
# developer tries to create them via make in the include build # 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 # directory. (This is more of an example of how this kind of rule can
# be made.) # 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) $(decimal_headers) $(ext_headers)
$(std_headers): ; @: $(std_headers): ; @:
$(c_base_headers): ; @: $(c_base_headers): ; @:
$(tr1_headers): ; @: $(tr1_headers): ; @:
$(tr1_impl_headers): ; @:
$(decimal_headers): ; @: $(decimal_headers): ; @:
$(ext_headers): ; @: $(ext_headers): ; @:
...@@ -848,25 +848,6 @@ tr1_headers = \ ...@@ -848,25 +848,6 @@ tr1_headers = \
${tr1_srcdir}/wchar.h \ ${tr1_srcdir}/wchar.h \
${tr1_srcdir}/wctype.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_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal decimal_builddir = ./decimal
decimal_headers = \ decimal_headers = \
...@@ -1133,9 +1114,9 @@ PCHFLAGS = -x c++-header -nostdinc++ $(CXXFLAGS) ...@@ -1133,9 +1114,9 @@ PCHFLAGS = -x c++-header -nostdinc++ $(CXXFLAGS)
# CLEANFILES and all-local are kept up-to-date. # CLEANFILES and all-local are kept up-to-date.
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \ stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-tr1-impl \ stamp-backward stamp-ext stamp-pb stamp-tr1 stamp-decimal \
stamp-decimal stamp-debug stamp-parallel stamp-profile \ stamp-debug stamp-parallel stamp-profile stamp-profile-impl \
stamp-profile-impl stamp-host stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
...@@ -1406,11 +1387,6 @@ stamp-tr1: ${tr1_headers} ...@@ -1406,11 +1387,6 @@ stamp-tr1: ${tr1_headers}
@-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${tr1_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1 @$(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} stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir} @-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
...@@ -1629,9 +1605,6 @@ install-headers: ...@@ -1629,9 +1605,6 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_builddir}
for file in ${tr1_headers}; do \ for file in ${tr1_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_builddir}; done $(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} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \ for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
...@@ -1675,12 +1648,11 @@ clean-local: ...@@ -1675,12 +1648,11 @@ clean-local:
# developer tries to create them via make in the include build # 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 # directory. (This is more of an example of how this kind of rule can
# be made.) # 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) $(decimal_headers) $(ext_headers)
$(std_headers): ; @: $(std_headers): ; @:
$(c_base_headers): ; @: $(c_base_headers): ; @:
$(tr1_headers): ; @: $(tr1_headers): ; @:
$(tr1_impl_headers): ; @:
$(decimal_headers): ; @: $(decimal_headers): ; @:
$(ext_headers): ; @: $(ext_headers): ; @:
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include <vector> #include <vector>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
// [26.4] Random number generation // [26.4] Random number generation
/** /**
...@@ -5376,6 +5376,6 @@ namespace std ...@@ -5376,6 +5376,6 @@ namespace std
/* @} */ // group random_utilities /* @} */ // group random_utilities
/* @} */ // group random /* @} */ // group random
} _GLIBCXX_END_NAMESPACE
#endif #endif
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#include <numeric> // std::accumulate and std::partial_sum #include <numeric> // std::accumulate and std::partial_sum
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/* /*
* (Further) implementation-space details. * (Further) implementation-space details.
*/ */
...@@ -2818,6 +2818,6 @@ namespace std ...@@ -2818,6 +2818,6 @@ namespace std
} }
return __sum / __tmp; return __sum / __tmp;
} }
} _GLIBCXX_END_NAMESPACE
#endif #endif
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup regex Regular Expressions * @defgroup regex Regular Expressions
...@@ -2422,6 +2421,5 @@ namespace std ...@@ -2422,6 +2421,5 @@ namespace std
#endif #endif
//@} // group regex //@} // group regex
_GLIBCXX_END_NAMESPACE
}
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace __regex namespace __regex
{ {
struct _Scanner_base struct _Scanner_base
...@@ -1110,6 +1110,7 @@ namespace __regex ...@@ -1110,6 +1110,7 @@ namespace __regex
__f)._M_nfa())); } __f)._M_nfa())); }
} // namespace __regex } // namespace __regex
} // namespace std
_GLIBCXX_END_NAMESPACE
/* vim: set ts=8 sw=2 sts=2: */ /* vim: set ts=8 sw=2 sts=2: */
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @namespace std::regex_constants * @namespace std::regex_constants
...@@ -295,5 +294,6 @@ namespace regex_constants ...@@ -295,5 +294,6 @@ namespace regex_constants
//@} //@}
} // namespace regex_constants } // namespace regex_constants
} // namespace std
_GLIBCXX_END_NAMESPACE
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace __regex namespace __regex
{ {
// ABC for pattern matching // ABC for pattern matching
...@@ -87,6 +87,5 @@ namespace __regex ...@@ -87,6 +87,5 @@ namespace __regex
{ return _SpecializedCursor<_FwdIterT>(__b, __e); } { return _SpecializedCursor<_FwdIterT>(__b, __e); }
} // namespace __regex } // namespace __regex
} // namespace std
/* vim: set ts=8 sw=2 sts=2: */ _GLIBCXX_END_NAMESPACE
...@@ -30,8 +30,7 @@ ...@@ -30,8 +30,7 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace regex_constants namespace regex_constants
{ {
...@@ -156,5 +155,4 @@ namespace regex_constants ...@@ -156,5 +155,4 @@ namespace regex_constants
__throw_regex_error(regex_constants::error_type __ecode) __throw_regex_error(regex_constants::error_type __ecode)
{ throw regex_error(__ecode); } { throw regex_error(__ecode); }
} // namespace std _GLIBCXX_END_NAMESPACE
...@@ -28,9 +28,8 @@ ...@@ -28,9 +28,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
_GLIBCXX_BEGIN_NAMESPACE(std)
namespace std
{
template<typename _BiIter> template<typename _BiIter>
class sub_match; class sub_match;
...@@ -124,8 +123,7 @@ namespace __regex ...@@ -124,8 +123,7 @@ namespace __regex
}; };
} // 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>
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
/** /**
* @file bits/regex_grep_matcher.tcc * @file bits/regex_grep_matcher.tcc
*/ */
#include <regex> #include <regex>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace namespace
{ {
...@@ -172,6 +172,5 @@ namespace __regex ...@@ -172,6 +172,5 @@ namespace __regex
} }
} // namespace __regex } // namespace __regex
} // namespace std
/* vim: set ts=8 sw=2 sts=2: */ _GLIBCXX_END_NAMESPACE
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
* You should not attempt to use it directly. * You should not attempt to use it directly.
*/ */
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace __regex namespace __regex
{ {
...@@ -397,7 +397,8 @@ namespace __regex ...@@ -397,7 +397,8 @@ namespace __regex
}; };
} // namespace __regex } // namespace __regex
} // namespace std
_GLIBCXX_END_NAMESPACE
#include <bits/regex_nfa.tcc> #include <bits/regex_nfa.tcc>
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
*/ */
#include <regex> #include <regex>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace __regex namespace __regex
{ {
#ifdef _GLIBCXX_DEBUG #ifdef _GLIBCXX_DEBUG
...@@ -166,5 +166,5 @@ _M_clone() ...@@ -166,5 +166,5 @@ _M_clone()
{ return 0; } { return 0; }
} // namespace __regex } // namespace __regex
} // namespace std
_GLIBCXX_END_NAMESPACE
...@@ -51,6 +51,202 @@ ...@@ -51,6 +51,202 @@
_GLIBCXX_BEGIN_NAMESPACE(std) _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. // Forward declarations.
template<typename _Tp, _Lock_policy _Lp = __default_lock_policy> template<typename _Tp, _Lock_policy _Lp = __default_lock_policy>
class __shared_ptr; class __shared_ptr;
......
...@@ -37,22 +37,46 @@ ...@@ -37,22 +37,46 @@
#endif #endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header #if _GLIBCXX_USE_C99_FENV_TR1
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #undef feclearexcept
# include <tr1_impl/cfenv> #undef fegetexceptflag
# else #undef feraiseexcept
# define _GLIBCXX_INCLUDE_AS_CXX0X #undef fesetexceptflag
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef fetestexcept
# define _GLIBCXX_END_NAMESPACE_TR1 #undef fegetround
# define _GLIBCXX_TR1 #undef fesetround
# include <tr1_impl/cfenv> #undef fegetenv
# undef _GLIBCXX_TR1 #undef feholdexcept
# undef _GLIBCXX_END_NAMESPACE_TR1 #undef fesetenv
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef feupdateenv
# undef _GLIBCXX_INCLUDE_AS_CXX0X
# endif _GLIBCXX_BEGIN_NAMESPACE(std)
#endif
// 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 #endif // _GLIBCXX_FENV_H
...@@ -48,22 +48,38 @@ ...@@ -48,22 +48,38 @@
# endif # endif
# endif # endif
# if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_INTTYPES_TR1
# error C++0x header cannot be included from TR1 header
# endif _GLIBCXX_BEGIN_NAMESPACE(std)
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# include <tr1_impl/cinttypes> // types
# else using ::imaxdiv_t;
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 // functions
# define _GLIBCXX_END_NAMESPACE_TR1 using ::imaxabs;
# define _GLIBCXX_TR1
# include <tr1_impl/cinttypes> // May collide with _Longlong abs(_Longlong), and is not described
# undef _GLIBCXX_TR1 // anywhere outside the synopsis. Likely, a defect.
# undef _GLIBCXX_END_NAMESPACE_TR1 //
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 // intmax_t abs(intmax_t)
# undef _GLIBCXX_INCLUDE_AS_CXX0X
# endif 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 #else
......
...@@ -56,22 +56,49 @@ ...@@ -56,22 +56,49 @@
# endif # endif
# endif # endif
# if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_STDINT_TR1
# error C++0x header cannot be included from TR1 header
# endif _GLIBCXX_BEGIN_NAMESPACE(std)
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# include <tr1_impl/cstdint> using ::int8_t;
# else using ::int16_t;
# define _GLIBCXX_INCLUDE_AS_CXX0X using ::int32_t;
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::int64_t;
# define _GLIBCXX_END_NAMESPACE_TR1
# define _GLIBCXX_TR1 using ::int_fast8_t;
# include <tr1_impl/cstdint> using ::int_fast16_t;
# undef _GLIBCXX_TR1 using ::int_fast32_t;
# undef _GLIBCXX_END_NAMESPACE_TR1 using ::int_fast64_t;
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
# undef _GLIBCXX_INCLUDE_AS_CXX0X using ::int_least8_t;
# endif 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 #else
......
...@@ -80,22 +80,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -80,22 +80,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header #ifdef _GLIBCXX_USE_C99_CTYPE_TR1
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #undef isblank
# include <tr1_impl/cctype>
# else _GLIBCXX_BEGIN_NAMESPACE(std)
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::isblank;
# define _GLIBCXX_END_NAMESPACE_TR1
# define _GLIBCXX_TR1 _GLIBCXX_END_NAMESPACE
# include <tr1_impl/cctype>
# undef _GLIBCXX_TR1 #endif // _GLIBCXX_USE_C99_CTYPE_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #endif // __GXX_EXPERIMENTAL_CXX0X__
# undef _GLIBCXX_INCLUDE_AS_CXX0X
# endif
#endif
#endif #endif
...@@ -33,29 +33,53 @@ ...@@ -33,29 +33,53 @@
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#endif #else
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header
#endif
#include <bits/c++config.h> #include <bits/c++config.h>
#if _GLIBCXX_HAVE_FENV_H #if _GLIBCXX_HAVE_FENV_H
# include <fenv.h> # include <fenv.h>
#endif #endif
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #ifdef _GLIBCXX_USE_C99_FENV_TR1
# include <tr1_impl/cfenv>
#else #undef feclearexcept
# define _GLIBCXX_INCLUDE_AS_CXX0X #undef fegetexceptflag
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef feraiseexcept
# define _GLIBCXX_END_NAMESPACE_TR1 #undef fesetexceptflag
# define _GLIBCXX_TR1 #undef fetestexcept
# include <tr1_impl/cfenv> #undef fegetround
# undef _GLIBCXX_TR1 #undef fesetround
# undef _GLIBCXX_END_NAMESPACE_TR1 #undef fegetenv
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef feholdexcept
# undef _GLIBCXX_INCLUDE_AS_CXX0X #undef fesetenv
#endif #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 #endif // _GLIBCXX_CFENV
...@@ -33,11 +33,7 @@ ...@@ -33,11 +33,7 @@
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#endif #else
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header
#endif
#include <cstdint> #include <cstdint>
...@@ -54,18 +50,39 @@ ...@@ -54,18 +50,39 @@
# endif # endif
#endif #endif
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #ifdef _GLIBCXX_USE_C99_INTTYPES_TR1
# include <tr1_impl/cinttypes>
#else _GLIBCXX_BEGIN_NAMESPACE(std)
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 // types
# define _GLIBCXX_END_NAMESPACE_TR1 using ::imaxdiv_t;
# define _GLIBCXX_TR1
# include <tr1_impl/cinttypes> // functions
# undef _GLIBCXX_TR1 using ::imaxabs;
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 // May collide with _Longlong abs(_Longlong), and is not described
# undef _GLIBCXX_INCLUDE_AS_CXX0X // 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_END_NAMESPACE
#endif // _GLIBCXX_USE_C99_INTTYPES_TR1
#endif // __GXX_EXPERIMENTAL_CXX0X__
#endif // _GLIBCXX_CINTTYPES #endif // _GLIBCXX_CINTTYPES
...@@ -846,22 +846,928 @@ _GLIBCXX_END_NAMESPACE ...@@ -846,22 +846,928 @@ _GLIBCXX_END_NAMESPACE
#endif #endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header #ifdef _GLIBCXX_USE_C99_MATH_TR1
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #undef acosh
# include <tr1_impl/cmath> #undef acoshf
# else #undef acoshl
# define _GLIBCXX_INCLUDE_AS_CXX0X #undef asinh
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef asinhf
# define _GLIBCXX_END_NAMESPACE_TR1 #undef asinhl
# define _GLIBCXX_TR1 #undef atanh
# include <tr1_impl/cmath> #undef atanhf
# undef _GLIBCXX_TR1 #undef atanhl
# undef _GLIBCXX_END_NAMESPACE_TR1 #undef cbrt
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef cbrtf
# undef _GLIBCXX_INCLUDE_AS_CXX0X #undef cbrtl
# endif #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 #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 #endif
...@@ -33,11 +33,7 @@ ...@@ -33,11 +33,7 @@
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#endif #else
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header
#endif
#include <bits/c++config.h> #include <bits/c++config.h>
...@@ -62,18 +58,50 @@ ...@@ -62,18 +58,50 @@
# endif # endif
#endif #endif
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #ifdef _GLIBCXX_USE_C99_STDINT_TR1
# include <tr1_impl/cstdint>
#else _GLIBCXX_BEGIN_NAMESPACE(std)
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::int8_t;
# define _GLIBCXX_END_NAMESPACE_TR1 using ::int16_t;
# define _GLIBCXX_TR1 using ::int32_t;
# include <tr1_impl/cstdint> using ::int64_t;
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1 using ::int_fast8_t;
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::int_fast16_t;
# undef _GLIBCXX_INCLUDE_AS_CXX0X using ::int_fast32_t;
#endif 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 #endif // _GLIBCXX_CSTDINT
...@@ -185,23 +185,4 @@ _GLIBCXX_END_NAMESPACE ...@@ -185,23 +185,4 @@ _GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_USE_C99 #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 #endif
...@@ -215,27 +215,38 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -215,27 +215,38 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_USE_C99
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header _GLIBCXX_BEGIN_NAMESPACE(std)
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
# include <tr1_impl/cstdlib> // types
# else using std::lldiv_t;
# define _GLIBCXX_INCLUDE_AS_CXX0X
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 // functions
# define _GLIBCXX_END_NAMESPACE_TR1 using std::llabs;
# define _GLIBCXX_TR1 using std::lldiv;
# include <tr1_impl/cstdlib>
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
# undef _GLIBCXX_INCLUDE_AS_CXX0X
# endif
#endif #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 // !_GLIBCXX_HOSTED
#endif #endif
...@@ -273,22 +273,34 @@ _GLIBCXX_END_NAMESPACE ...@@ -273,22 +273,34 @@ _GLIBCXX_END_NAMESPACE
#endif //_GLIBCXX_USE_WCHAR_T #endif //_GLIBCXX_USE_WCHAR_T
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header #ifdef _GLIBCXX_USE_WCHAR_T
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) _GLIBCXX_BEGIN_NAMESPACE(std)
# include <tr1_impl/cwchar>
# else #if _GLIBCXX_HAVE_WCSTOF
# define _GLIBCXX_INCLUDE_AS_CXX0X using std::wcstof;
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 #endif
# define _GLIBCXX_END_NAMESPACE_TR1 #if _GLIBCXX_HAVE_VFWSCANF
# define _GLIBCXX_TR1 using std::vfwscanf;
# include <tr1_impl/cwchar> #endif
# undef _GLIBCXX_TR1 #if _GLIBCXX_HAVE_VSWSCANF
# undef _GLIBCXX_END_NAMESPACE_TR1 using std::vswscanf;
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
# undef _GLIBCXX_INCLUDE_AS_CXX0X
# endif
#endif #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 #endif
...@@ -111,22 +111,19 @@ _GLIBCXX_END_NAMESPACE ...@@ -111,22 +111,19 @@ _GLIBCXX_END_NAMESPACE
#endif //_GLIBCXX_USE_WCHAR_T #endif //_GLIBCXX_USE_WCHAR_T
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #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
...@@ -35,26 +35,236 @@ ...@@ -35,26 +35,236 @@
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#else #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/stl_algobase.h>
#include <bits/range_access.h> #include <bits/range_access.h>
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) _GLIBCXX_BEGIN_NAMESPACE(std)
# include <tr1_impl/array>
#else /**
# define _GLIBCXX_INCLUDE_AS_CXX0X * @brief A standard container for storing a fixed size sequence of elements.
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 *
# define _GLIBCXX_END_NAMESPACE_TR1 * @ingroup sequences
# define _GLIBCXX_TR1 *
# include <tr1_impl/array> * Meets the requirements of a <a href="tables.html#65">container</a>, a
# undef _GLIBCXX_TR1 * <a href="tables.html#66">reversible container</a>, and a
# undef _GLIBCXX_END_NAMESPACE_TR1 * <a href="tables.html#67">sequence</a>.
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 *
# undef _GLIBCXX_INCLUDE_AS_CXX0X * Sets support random access iterators.
#endif *
* @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__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
...@@ -35,10 +35,6 @@ ...@@ -35,10 +35,6 @@
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#else #else
#ifdef _GLIBCXX_INCLUDE_AS_TR1
# error C++0x header cannot be included from TR1 header
#endif
#include <ratio> #include <ratio>
#include <type_traits> #include <type_traits>
#include <limits> #include <limits>
...@@ -46,8 +42,8 @@ ...@@ -46,8 +42,8 @@
#ifdef _GLIBCXX_USE_C99_STDINT_TR1 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup chrono Time * @defgroup chrono Time
* @ingroup utilities * @ingroup utilities
...@@ -689,7 +685,7 @@ namespace std ...@@ -689,7 +685,7 @@ namespace std
} // namespace chrono } // namespace chrono
// @} group chrono // @} group chrono
} // namespace std _GLIBCXX_END_NAMESPACE
#endif //_GLIBCXX_USE_C99_STDINT_TR1 #endif //_GLIBCXX_USE_C99_STDINT_TR1
......
...@@ -1523,26 +1523,324 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1523,26 +1523,324 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #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) _GLIBCXX_BEGIN_NAMESPACE(std)
// Forward declarations. // 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. // DR 781.
template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&); template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&);
...@@ -1594,6 +1892,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1594,6 +1892,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
#endif #endif // __GXX_EXPERIMENTAL_CXX0X__
#endif /* _GLIBCXX_COMPLEX */ #endif /* _GLIBCXX_COMPLEX */
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup condition_variables Condition Variables * @defgroup condition_variables Condition Variables
* @ingroup concurrency * @ingroup concurrency
...@@ -254,7 +254,7 @@ namespace std ...@@ -254,7 +254,7 @@ namespace std
}; };
// @} group condition_variables // @} group condition_variables
} _GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
#include <bits/functexcept.h> #include <bits/functexcept.h>
#include <bits/functional_hash.h> #include <bits/functional_hash.h>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
_GLIBCXX_HAS_NESTED_TYPE(result_type) _GLIBCXX_HAS_NESTED_TYPE(result_type)
/// If we have found a result_type, extract it. /// If we have found a result_type, extract it.
...@@ -2244,7 +2244,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) ...@@ -2244,7 +2244,8 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
inline void inline void
swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
}
_GLIBCXX_END_NAMESPACE
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include <atomic> #include <atomic>
#include <bits/functexcept.h> #include <bits/functexcept.h>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup futures Futures * @defgroup futures Futures
* @ingroup concurrency * @ingroup concurrency
...@@ -1364,7 +1364,7 @@ namespace std ...@@ -1364,7 +1364,7 @@ namespace std
// && _GLIBCXX_ATOMIC_BUILTINS_4 // && _GLIBCXX_ATOMIC_BUILTINS_4
// @} group futures // @} group futures
} _GLIBCXX_END_NAMESPACE
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
...@@ -69,9 +69,6 @@ ...@@ -69,9 +69,6 @@
#include <bits/stl_raw_storage_iter.h> #include <bits/stl_raw_storage_iter.h>
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #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 <exception> // std::exception
# include <typeinfo> // std::type_info in get_deleter # include <typeinfo> // std::type_info in get_deleter
# include <iosfwd> // std::basic_ostream # include <iosfwd> // std::basic_ostream
...@@ -86,19 +83,6 @@ ...@@ -86,19 +83,6 @@
# include <backward/auto_ptr.h> # include <backward/auto_ptr.h>
# endif # endif
# include <bits/unique_ptr.h> # 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> # include <bits/shared_ptr.h>
#else #else
# include <backward/auto_ptr.h> # include <backward/auto_ptr.h>
......
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup mutexes Mutexes * @defgroup mutexes Mutexes
* @ingroup concurrency * @ingroup concurrency
...@@ -739,7 +739,7 @@ namespace std ...@@ -739,7 +739,7 @@ namespace std
} }
// @} group mutexes // @} group mutexes
} _GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#ifdef _GLIBCXX_USE_C99_STDINT_TR1 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup ratio Rational Arithmetic * @defgroup ratio Rational Arithmetic
* @ingroup utilities * @ingroup utilities
...@@ -339,7 +339,7 @@ namespace std ...@@ -339,7 +339,7 @@ namespace std
typedef ratio< 1000000000000000000, 1> exa; typedef ratio< 1000000000000000000, 1> exa;
// @} group ratio // @} group ratio
} _GLIBCXX_END_NAMESPACE
#endif //_GLIBCXX_USE_C99_STDINT_TR1 #endif //_GLIBCXX_USE_C99_STDINT_TR1
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
* @defgroup threads Threads * @defgroup threads Threads
* @ingroup concurrency * @ingroup concurrency
...@@ -283,7 +283,7 @@ namespace std ...@@ -283,7 +283,7 @@ namespace std
} }
// @} group threads // @} group threads
} _GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
#include <utility> #include <utility>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
// Adds a const reference to a non-reference type. // Adds a const reference to a non-reference type.
template<typename _Tp> template<typename _Tp>
struct __add_c_ref struct __add_c_ref
...@@ -791,7 +791,8 @@ namespace std ...@@ -791,7 +791,8 @@ namespace std
__do_cons(tuple<_Args...>&& __tuple, __do_cons(tuple<_Args...>&& __tuple,
const _Index_tuple<_Indexes...>&) const _Index_tuple<_Indexes...>&)
{ return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); } { return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); }
}
_GLIBCXX_END_NAMESPACE
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
...@@ -35,32 +35,463 @@ ...@@ -35,32 +35,463 @@
# include <bits/c++0x_warning.h> # include <bits/c++0x_warning.h>
#else #else
#if defined(_GLIBCXX_INCLUDE_AS_TR1)
# error C++0x header cannot be included from TR1 header
#endif
#include <bits/c++config.h> #include <bits/c++config.h>
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) _GLIBCXX_BEGIN_NAMESPACE(std)
# 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
namespace std
{
/** /**
* @addtogroup metaprogramming * @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. // Primary classification traits.
...@@ -731,8 +1162,13 @@ namespace std ...@@ -731,8 +1162,13 @@ namespace std
<typename remove_cv<_Tp>::type>::value> \ <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 // @} group metaprogramming
} _GLIBCXX_END_NAMESPACE
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
#include <typeinfo> #include <typeinfo>
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
/** /**
@brief The class type_index provides a simple wrapper for type_info @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) which can be used as an index type in associative containers (23.6)
...@@ -98,7 +98,8 @@ namespace std ...@@ -98,7 +98,8 @@ namespace std
operator()(const type_index& __ti) const operator()(const type_index& __ti) const
{ return __ti.hash_code(); } { return __ti.hash_code(); }
}; };
}
_GLIBCXX_END_NAMESPACE
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
......
// <utility> -*- C++ -*- // <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. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -71,24 +71,73 @@ ...@@ -71,24 +71,73 @@
#include <bits/stl_pair.h> #include <bits/stl_pair.h>
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
# if defined(_GLIBCXX_INCLUDE_AS_TR1) #include <bits/move.h>
# error C++0x header cannot be included from TR1 header #include <initializer_list>
# endif
# if defined(_GLIBCXX_INCLUDE_AS_CXX0X) _GLIBCXX_BEGIN_NAMESPACE(std)
# include <tr1_impl/utility>
# else template<class _Tp>
# define _GLIBCXX_INCLUDE_AS_CXX0X class tuple_size;
# define _GLIBCXX_BEGIN_NAMESPACE_TR1
# define _GLIBCXX_END_NAMESPACE_TR1 template<std::size_t _Int, class _Tp>
# define _GLIBCXX_TR1 class tuple_element;
# include <tr1_impl/utility>
# undef _GLIBCXX_TR1 // Various functions which give std::pair a tuple-like interface.
# undef _GLIBCXX_END_NAMESPACE_TR1 template<class _Tp1, class _Tp2>
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 struct tuple_size<std::pair<_Tp1, _Tp2> >
# undef _GLIBCXX_INCLUDE_AS_CXX0X { static const std::size_t value = 2; };
# endif
# include <bits/move.h> template<class _Tp1, class _Tp2>
# include <initializer_list> 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
#endif /* _GLIBCXX_UTILITY */ #endif /* _GLIBCXX_UTILITY */
// class template array -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,24 +32,217 @@ ...@@ -31,24 +32,217 @@
#pragma GCC system_header #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> #include <bits/stl_algobase.h>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) namespace std
# include <tr1_impl/array> {
#else namespace tr1
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { /**
# define _GLIBCXX_END_NAMESPACE_TR1 } * @brief A standard container for storing a fixed size sequence of elements.
# define _GLIBCXX_TR1 tr1:: *
# include <tr1_impl/array> * @ingroup sequences
# undef _GLIBCXX_TR1 *
# undef _GLIBCXX_END_NAMESPACE_TR1 * Meets the requirements of a <a href="tables.html#65">container</a>, a
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 * <a href="tables.html#66">reversible container</a>, and a
# undef _GLIBCXX_INCLUDE_AS_TR1 * <a href="tables.html#67">sequence</a>.
#endif *
* 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 #endif // _GLIBCXX_TR1_ARRAY
...@@ -32,18 +32,18 @@ ...@@ -32,18 +32,18 @@
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cctype> #include <cctype>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_CTYPE_TR1
# include <tr1_impl/cctype>
#else #undef isblank
# define _GLIBCXX_INCLUDE_AS_TR1
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace std
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: namespace tr1
# include <tr1_impl/cctype> {
# undef _GLIBCXX_TR1 using ::isblank;
# undef _GLIBCXX_END_NAMESPACE_TR1 }
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 }
# undef _GLIBCXX_INCLUDE_AS_TR1
#endif #endif
#endif // _GLIBCXX_TR1_CCTYPE #endif // _GLIBCXX_TR1_CCTYPE
// TR1 cfenv -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -32,22 +32,50 @@ ...@@ -32,22 +32,50 @@
#pragma GCC system_header #pragma GCC system_header
#include <bits/c++config.h> #include <bits/c++config.h>
#if _GLIBCXX_HAVE_FENV_H #if _GLIBCXX_HAVE_FENV_H
# include <fenv.h> # include <fenv.h>
#endif #endif
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_FENV_TR1
# include <tr1_impl/cfenv>
#else #undef feclearexcept
# define _GLIBCXX_INCLUDE_AS_TR1 #undef fegetexceptflag
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { #undef feraiseexcept
# define _GLIBCXX_END_NAMESPACE_TR1 } #undef fesetexceptflag
# define _GLIBCXX_TR1 tr1:: #undef fetestexcept
# include <tr1_impl/cfenv> #undef fegetround
# undef _GLIBCXX_TR1 #undef fesetround
# undef _GLIBCXX_END_NAMESPACE_TR1 #undef fegetenv
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef feholdexcept
# undef _GLIBCXX_INCLUDE_AS_TR1 #undef fesetenv
#endif #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 #endif // _GLIBCXX_TR1_CFENV
// TR1 cinttypes -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -46,18 +46,39 @@ ...@@ -46,18 +46,39 @@
# endif # endif
#endif #endif
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_INTTYPES_TR1
# include <tr1_impl/cinttypes>
#else namespace std
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace tr1
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: // types
# include <tr1_impl/cinttypes> using ::imaxdiv_t;
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1 // functions
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 using ::imaxabs;
# undef _GLIBCXX_INCLUDE_AS_TR1
// 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
}
}
#endif // _GLIBCXX_USE_C99_INTTYPES_TR1
#endif // _GLIBCXX_TR1_CINTTYPES #endif // _GLIBCXX_TR1_CINTTYPES
...@@ -37,20 +37,973 @@ ...@@ -37,20 +37,973 @@
#include <cmath> #include <cmath>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_MATH_TR1
# include <tr1_impl/cmath>
#else #undef acosh
# define _GLIBCXX_INCLUDE_AS_TR1 #undef acoshf
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { #undef acoshl
# define _GLIBCXX_END_NAMESPACE_TR1 } #undef asinh
# define _GLIBCXX_TR1 tr1:: #undef asinhf
# include <tr1_impl/cmath> #undef asinhl
# undef _GLIBCXX_TR1 #undef atanh
# undef _GLIBCXX_END_NAMESPACE_TR1 #undef atanhf
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 #undef atanhl
# undef _GLIBCXX_INCLUDE_AS_TR1 #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 #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 std
{ {
namespace tr1 namespace tr1
......
...@@ -31,30 +31,334 @@ ...@@ -31,30 +31,334 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <complex> #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 std
{ {
namespace tr1 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; using std::arg;
template<typename _Tp> template<typename _Tp>
...@@ -95,6 +399,8 @@ namespace tr1 ...@@ -95,6 +399,8 @@ namespace tr1
inline std::complex<_Tp> inline std::complex<_Tp>
pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y) pow(const std::complex<_Tp>& __x, const std::complex<_Tp>& __y)
{ return std::pow(__x, __y); } { return std::pow(__x, __y); }
// @} group complex_numbers
} }
} }
......
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
#pragma GCC system_header #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/c++config.h>
// For 8.22.1/1 (see C99, Notes 219, 220, 222) // For 8.22.1/1 (see C99, Notes 219, 220, 222)
...@@ -58,19 +54,51 @@ ...@@ -58,19 +54,51 @@
# endif # endif
# endif # endif
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_C99_STDINT_TR1
# include <tr1_impl/cstdint>
#else namespace std
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace tr1
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: using ::int8_t;
# include <tr1_impl/cstdint> using ::int16_t;
# undef _GLIBCXX_TR1 using ::int32_t;
# undef _GLIBCXX_END_NAMESPACE_TR1 using ::int64_t;
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1
# undef _GLIBCXX_INCLUDE_AS_TR1 using ::int_fast8_t;
#endif 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 #endif // _GLIBCXX_TR1_CSTDINT
...@@ -31,24 +31,23 @@ ...@@ -31,24 +31,23 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <cstdio> #include <cstdio>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #if _GLIBCXX_USE_C99
# include <tr1_impl/cstdio>
#else namespace std
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace tr1
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: using std::snprintf;
# include <tr1_impl/cstdio> using std::vsnprintf;
# undef _GLIBCXX_TR1
# undef _GLIBCXX_END_NAMESPACE_TR1 using std::vfscanf;
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 using std::vscanf;
# undef _GLIBCXX_INCLUDE_AS_TR1 using std::vsscanf;
}
}
#endif #endif
#endif // _GLIBCXX_TR1_CSTDIO #endif // _GLIBCXX_TR1_CSTDIO
// TR1 cstdlib -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,24 +31,42 @@ ...@@ -31,24 +31,42 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X) #include <cstdlib>
# error TR1 header cannot be included from C++0x header
#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 #endif
#include <cstdlib> using std::atoll;
using std::strtoll;
using std::strtoull;
using std::strtof;
using std::strtold;
#if defined(_GLIBCXX_INCLUDE_AS_TR1) // overloads
# include <tr1_impl/cstdlib> using std::abs;
#else #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
# define _GLIBCXX_INCLUDE_AS_TR1 using std::div;
# 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
#endif #endif
}
}
#endif // _GLIBCXX_USE_C99
#endif // _GLIBCXX_HOSTED
#endif // _GLIBCXX_TR1_CSTDLIB #endif // _GLIBCXX_TR1_CSTDLIB
// TR1 cwchar -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,24 +31,35 @@ ...@@ -31,24 +31,35 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <cwchar> #include <cwchar>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_WCHAR_T
# include <tr1_impl/cwchar>
#else namespace std
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace tr1
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: #if _GLIBCXX_HAVE_WCSTOF
# include <tr1_impl/cwchar> using std::wcstof;
# undef _GLIBCXX_TR1 #endif
# undef _GLIBCXX_END_NAMESPACE_TR1 #if _GLIBCXX_HAVE_VFWSCANF
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 using std::vfwscanf;
# undef _GLIBCXX_INCLUDE_AS_TR1 #endif
#if _GLIBCXX_HAVE_VSWSCANF
using std::vswscanf;
#endif #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 #endif // _GLIBCXX_TR1_CWCHAR
...@@ -31,24 +31,20 @@ ...@@ -31,24 +31,20 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <cwctype> #include <cwctype>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) #ifdef _GLIBCXX_USE_WCHAR_T
# include <tr1_impl/cwctype>
#else namespace std
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { namespace tr1
# define _GLIBCXX_END_NAMESPACE_TR1 } {
# define _GLIBCXX_TR1 tr1:: #if _GLIBCXX_HAVE_ISWBLANK
# include <tr1_impl/cwctype> using std::iswblank;
# undef _GLIBCXX_TR1 #endif
# undef _GLIBCXX_END_NAMESPACE_TR1 }
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 }
# undef _GLIBCXX_INCLUDE_AS_TR1
#endif #endif // _GLIBCXX_USE_WCHAR_T
#endif // _GLIBCXX_TR1_CWCTYPE #endif // _GLIBCXX_TR1_CWCTYPE
// <tr1/memory> -*- C++ -*- // <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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -47,21 +48,6 @@ ...@@ -47,21 +48,6 @@
#include <bits/stl_function.h> // std::less #include <bits/stl_function.h> // std::less
#include <debug/debug.h> #include <debug/debug.h>
#include <tr1/type_traits> #include <tr1/type_traits>
#include <tr1/shared_ptr.h>
#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
#endif // _GLIBCXX_TR1_MEMORY #endif // _GLIBCXX_TR1_MEMORY
...@@ -33,10 +33,6 @@ ...@@ -33,10 +33,6 @@
#pragma GCC system_header #pragma GCC system_header
#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
# error TR1 header cannot be included from C++0x header
#endif
#include <algorithm> #include <algorithm>
#include <bitset> #include <bitset>
#include <iterator> #include <iterator>
...@@ -47,18 +43,2682 @@ ...@@ -47,18 +43,2682 @@
#include <utility> #include <utility>
#include <sstream> #include <sstream>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) namespace std
# include <tr1_impl/regex> {
#else namespace tr1
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { /**
# define _GLIBCXX_END_NAMESPACE_TR1 } * @defgroup tr1_regex Regular Expressions
# define _GLIBCXX_TR1 tr1:: * A facility for performing regular expression pattern matching.
# include <tr1_impl/regex> */
# undef _GLIBCXX_TR1 //@{
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 /** @namespace std::regex_constants
# undef _GLIBCXX_INCLUDE_AS_TR1 * @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,
* \\&apos;, &apos;, 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
//@}
}
}
#endif // _GLIBCXX_TR1_REGEX #endif // _GLIBCXX_TR1_REGEX
...@@ -49,14 +49,205 @@ ...@@ -49,14 +49,205 @@
#ifndef _TR1_SHARED_PTR_H #ifndef _TR1_SHARED_PTR_H
#define _TR1_SHARED_PTR_H 1 #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 std
{ {
namespace tr1 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> template<typename _Ptr, typename _Deleter, _Lock_policy _Lp>
class _Sp_counted_base_impl class _Sp_counted_base_impl
: public _Sp_counted_base<_Lp> : public _Sp_counted_base<_Lp>
......
...@@ -32,35 +32,467 @@ ...@@ -32,35 +32,467 @@
#pragma GCC system_header #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/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 std
{ {
namespace tr1 namespace tr1
{ {
#define _DEFINE_SPEC(_Trait, _Type) \ /**
template<> \ * @defgroup metaprogramming Type Traits
struct _Trait<_Type> \ * @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 { }; : 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> template<typename>
struct is_reference struct is_reference
: public false_type { }; : public false_type { };
...@@ -112,11 +544,11 @@ namespace tr1 ...@@ -112,11 +544,11 @@ namespace tr1
template<typename> template<typename>
struct __is_signed_helper struct __is_signed_helper
: public false_type { }; : public false_type { };
_DEFINE_SPEC(__is_signed_helper, signed char) _DEFINE_SPEC(0, __is_signed_helper, signed char, true)
_DEFINE_SPEC(__is_signed_helper, short) _DEFINE_SPEC(0, __is_signed_helper, short, true)
_DEFINE_SPEC(__is_signed_helper, int) _DEFINE_SPEC(0, __is_signed_helper, int, true)
_DEFINE_SPEC(__is_signed_helper, long) _DEFINE_SPEC(0, __is_signed_helper, long, true)
_DEFINE_SPEC(__is_signed_helper, long long) _DEFINE_SPEC(0, __is_signed_helper, long long, true)
template<typename _Tp> template<typename _Tp>
struct is_signed struct is_signed
...@@ -127,11 +559,11 @@ namespace tr1 ...@@ -127,11 +559,11 @@ namespace tr1
template<typename> template<typename>
struct __is_unsigned_helper struct __is_unsigned_helper
: public false_type { }; : public false_type { };
_DEFINE_SPEC(__is_unsigned_helper, unsigned char) _DEFINE_SPEC(0, __is_unsigned_helper, unsigned char, true)
_DEFINE_SPEC(__is_unsigned_helper, unsigned short) _DEFINE_SPEC(0, __is_unsigned_helper, unsigned short, true)
_DEFINE_SPEC(__is_unsigned_helper, unsigned int) _DEFINE_SPEC(0, __is_unsigned_helper, unsigned int, true)
_DEFINE_SPEC(__is_unsigned_helper, unsigned long) _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long, true)
_DEFINE_SPEC(__is_unsigned_helper, unsigned long long) _DEFINE_SPEC(0, __is_unsigned_helper, unsigned long long, true)
template<typename _Tp> template<typename _Tp>
struct is_unsigned struct is_unsigned
...@@ -243,6 +675,9 @@ namespace tr1 ...@@ -243,6 +675,9 @@ namespace tr1
}; };
}; };
#undef _DEFINE_SPEC_0_HELPER
#undef _DEFINE_SPEC_1_HELPER
#undef _DEFINE_SPEC_2_HELPER
#undef _DEFINE_SPEC #undef _DEFINE_SPEC
} }
} }
......
// TR1 utility -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -31,26 +32,74 @@ ...@@ -31,26 +32,74 @@
#pragma GCC system_header #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/c++config.h>
#include <bits/stl_relops.h> #include <bits/stl_relops.h>
#include <bits/stl_pair.h> #include <bits/stl_pair.h>
#if defined(_GLIBCXX_INCLUDE_AS_TR1) namespace std
# include <tr1_impl/utility> {
#else namespace tr1
# define _GLIBCXX_INCLUDE_AS_TR1 {
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 { template<class _Tp>
# define _GLIBCXX_END_NAMESPACE_TR1 } class tuple_size;
# define _GLIBCXX_TR1 tr1::
# include <tr1_impl/utility> template<int _Int, class _Tp>
# undef _GLIBCXX_TR1 class tuple_element;
# undef _GLIBCXX_END_NAMESPACE_TR1
# undef _GLIBCXX_BEGIN_NAMESPACE_TR1 // Various functions which give std::pair a tuple-like interface.
# undef _GLIBCXX_INCLUDE_AS_TR1 template<class _Tp1, class _Tp2>
#endif 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 #endif // _GLIBCXX_TR1_UTILITY
// 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
}
// <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
}
// 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
// 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
// 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
// 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
}
// 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
}
// 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
// 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
}
// 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
// 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
// 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
// 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,
* \\&apos;, &apos;, 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
}
// 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
}
// 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
}
...@@ -49,8 +49,8 @@ namespace ...@@ -49,8 +49,8 @@ namespace
}; };
} // anonymous namespace } // anonymous namespace
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace __atomic0 namespace __atomic0
{ {
bool bool
...@@ -115,7 +115,8 @@ namespace std ...@@ -115,7 +115,8 @@ namespace std
_GLIBCXX_END_EXTERN_C _GLIBCXX_END_EXTERN_C
} // namespace __atomic0 } // namespace __atomic0
} // namespace std
_GLIBCXX_END_NAMESPACE
// XXX GLIBCXX_ABI Deprecated // XXX GLIBCXX_ABI Deprecated
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace chrono namespace chrono
{ {
const bool system_clock::is_monotonic; const bool system_clock::is_monotonic;
...@@ -74,6 +74,7 @@ namespace std ...@@ -74,6 +74,7 @@ namespace std
} }
#endif #endif
} }
}
_GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_USE_C99_STDINT_TR1
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
condition_variable::condition_variable() throw () condition_variable::condition_variable() throw ()
{ {
#ifdef __GTHREAD_COND_INIT #ifdef __GTHREAD_COND_INIT
...@@ -84,6 +84,7 @@ namespace std ...@@ -84,6 +84,7 @@ namespace std
condition_variable_any::~condition_variable_any() throw () condition_variable_any::~condition_variable_any() throw ()
{ } { }
}
_GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
...@@ -64,8 +64,8 @@ namespace ...@@ -64,8 +64,8 @@ namespace
} }
} }
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
const error_category& future_category() const error_category& future_category()
{ return __future_category_instance(); } { return __future_category_instance(); }
...@@ -73,4 +73,5 @@ namespace std ...@@ -73,4 +73,5 @@ namespace std
const char* const char*
future_error::what() const throw() { return _M_code.message().c_str(); } future_error::what() const throw() { return _M_code.message().c_str(); }
}
_GLIBCXX_END_NAMESPACE
...@@ -37,8 +37,8 @@ namespace ...@@ -37,8 +37,8 @@ namespace
} }
#endif #endif
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
#ifdef _GLIBCXX_HAVE_TLS #ifdef _GLIBCXX_HAVE_TLS
__thread void* __once_callable; __thread void* __once_callable;
__thread void (*__once_call)(); __thread void (*__once_call)();
...@@ -88,7 +88,8 @@ namespace std ...@@ -88,7 +88,8 @@ namespace std
__once_call(); __once_call();
} }
} }
}
_GLIBCXX_END_NAMESPACE
// XXX GLIBCXX_ABI Deprecated // XXX GLIBCXX_ABI Deprecated
// gcc-4.6.0 // gcc-4.6.0
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
namespace std _GLIBCXX_BEGIN_NAMESPACE(std)
{
namespace namespace
{ {
extern "C" void* extern "C" void*
...@@ -95,6 +95,7 @@ namespace std ...@@ -95,6 +95,7 @@ namespace std
__throw_system_error(__e); __throw_system_error(__e);
} }
} }
}
_GLIBCXX_END_NAMESPACE
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// { dg-error "static assertion failed" "" { target *-*-* } 688 } // { dg-error "static assertion failed" "" { target *-*-* } 1119 }
#include <utility> #include <utility>
......
...@@ -31,5 +31,5 @@ void test01() ...@@ -31,5 +31,5 @@ void test01()
test_type d; 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 } // { dg-error "instantiated from here" "" { target *-*-* } 31 }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// 2008-07-31 Chris Fairles <chris.fairles@gmail.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -32,6 +32,6 @@ void test01() ...@@ -32,6 +32,6 @@ void test01()
test_type d; 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-error "instantiated from here" "" { target *-*-* } 32 }
// { dg-excess-errors "In instantiation of" } // { dg-excess-errors "In instantiation of" }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// { dg-require-cstdint "" } // { dg-require-cstdint "" }
// 2008-07-31 Chris Fairles <chris.fairles@gmail.com> // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -33,5 +33,5 @@ void test01() ...@@ -33,5 +33,5 @@ void test01()
test_type d; 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 } // { dg-error "instantiated from here" "" { target *-*-* } 33 }
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 } // { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 651 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1082 }
// { dg-error "declaration of" "" { target *-*-* } 615 } // { dg-error "declaration of" "" { target *-*-* } 1046 }
...@@ -48,5 +48,5 @@ void test01() ...@@ -48,5 +48,5 @@ void test01()
// { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 } // { dg-error "instantiated from here" "" { target *-*-* } 42 }
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 574 } // { dg-error "invalid use of incomplete type" "" { target *-*-* } 1005 }
// { dg-error "declaration of" "" { target *-*-* } 538 } // { dg-error "declaration of" "" { target *-*-* } 969 }
...@@ -32,9 +32,9 @@ void test01() ...@@ -32,9 +32,9 @@ void test01()
{ {
X* px = 0; X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" } 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" } std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 658 } // { dg-error "incomplete" "" { target *-*-* } 854 }
} }
...@@ -42,8 +42,8 @@ main() ...@@ -42,8 +42,8 @@ main()
} }
// { dg-warning "note" "" { target *-*-* } 347 } // { dg-warning "note" "" { target *-*-* } 347 }
// { dg-warning "note" "" { target *-*-* } 1079 }
// { dg-warning "note" "" { target *-*-* } 465 } // { dg-warning "note" "" { target *-*-* } 465 }
// { dg-warning "note" "" { target *-*-* } 883 }
// { dg-warning "note" "" { target *-*-* } 580 } // { dg-warning "note" "" { target *-*-* } 580 }
// { dg-warning "note" "" { target *-*-* } 1027 } // { dg-warning "note" "" { target *-*-* } 1027 }
// { dg-warning "note" "" { target *-*-* } 340 } // { dg-warning "note" "" { target *-*-* } 340 }
......
...@@ -30,9 +30,9 @@ void test01() ...@@ -30,9 +30,9 @@ void test01()
{ {
X* px = 0; X* px = 0;
std::tr1::shared_ptr<X> p1(px); // { dg-error "here" } 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" } std::tr1::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 409 } // { dg-error "incomplete" "" { target *-*-* } 600 }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment