diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index deb7ae2c336..8ca5e1ac814 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2013-06-08 Ed Smith-Rowland <3dw4rd@verizon.net> + + Simplify and clean up library literals. + * include/std/chrono: Simplify namespace and versioning management. + * include/bits/basic_string.h: Ditto. + * testsuite/20_util/duration/literals/types.cc: Remove bogus comment. + * testsuite/20_util/duration/literals/values.cc: Ditto. + * testsuite/21_strings/basic_string/literals/types.cc: Ditto. + * testsuite/21_strings/basic_string/literals/values.cc: Ditto. + 2013-06-08 Ed Smith-Rowland <3dw4rd@verizon.net> Implement N3654 - Quoted Strings Library Proposal diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index a249df23742..aec48d7430a 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -3103,46 +3103,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace - #if __cplusplus > 201103L -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION + inline namespace literals { + inline namespace string_literals { -inline namespace literals { -inline namespace string_literals { - - inline basic_string - operator"" s(const char* __str, size_t __len) - { return basic_string{__str, __len}; } + inline basic_string + operator"" s(const char* __str, size_t __len) + { return basic_string{__str, __len}; } #ifdef _GLIBCXX_USE_WCHAR_T - inline basic_string - operator"" s(const wchar_t* __str, size_t __len) - { return basic_string{__str, __len}; } + inline basic_string + operator"" s(const wchar_t* __str, size_t __len) + { return basic_string{__str, __len}; } #endif #ifdef _GLIBCXX_USE_C99_STDINT_TR1 - inline basic_string - operator"" s(const char16_t* __str, size_t __len) - { return basic_string{__str, __len}; } + inline basic_string + operator"" s(const char16_t* __str, size_t __len) + { return basic_string{__str, __len}; } - inline basic_string - operator"" s(const char32_t* __str, size_t __len) - { return basic_string{__str, __len}; } + inline basic_string + operator"" s(const char32_t* __str, size_t __len) + { return basic_string{__str, __len}; } #endif -} // inline namespace string_literals -} // inline namespace literals + } // inline namespace string_literals + } // inline namespace literals + +#endif // __cplusplus > 201103L _GLIBCXX_END_NAMESPACE_VERSION } // namespace std -#endif // __cplusplus > 201103L - #endif // C++11 #endif /* _BASIC_STRING_H */ diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 7a574a62894..b32fb4460de 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -713,7 +713,7 @@ _GLIBCXX_END_NAMESPACE_VERSION * * Time returned represents wall time from the system-wide clock. */ - struct system_clock + struct system_clock { typedef chrono::nanoseconds duration; typedef duration::rep rep; @@ -775,148 +775,137 @@ _GLIBCXX_END_NAMESPACE_VERSION */ using high_resolution_clock = system_clock; - } // end inline namespace _V2 + } // end inline namespace _V2 _GLIBCXX_END_NAMESPACE_VERSION } // namespace chrono +#if __cplusplus > 201103L + + inline namespace literals { + inline namespace chrono_literals { + + namespace __detail { + + using namespace __parse_int; + + template + struct _Select_type + : conditional< + _Val <= static_cast + (numeric_limits::max()), + _Dur, void> + { + static constexpr typename _Select_type::type + value{static_cast(_Val)}; + }; + + template + constexpr typename _Select_type<_Val, _Dur>::type + _Select_type<_Val, _Dur>::value; + + } // __detail + + constexpr chrono::duration> + operator"" h(long double __hours) + { return chrono::duration>{__hours}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::hours>::type + operator"" h() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::hours>::value; + } + + constexpr chrono::duration> + operator"" min(long double __mins) + { return chrono::duration>{__mins}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::minutes>::type + operator"" min() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::minutes>::value; + } + + constexpr chrono::duration + operator"" s(long double __secs) + { return chrono::duration{__secs}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::seconds>::type + operator"" s() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::seconds>::value; + } + + constexpr chrono::duration + operator"" ms(long double __msecs) + { return chrono::duration{__msecs}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::milliseconds>::type + operator"" ms() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::milliseconds>::value; + } + + constexpr chrono::duration + operator"" us(long double __usecs) + { return chrono::duration{__usecs}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::microseconds>::type + operator"" us() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::microseconds>::value; + } + + constexpr chrono::duration + operator"" ns(long double __nsecs) + { return chrono::duration{__nsecs}; } + + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::nanoseconds>::type + operator"" ns() + { + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::nanoseconds>::value; + } + + } // inline namespace chrono_literals + } // inline namespace literals + +#endif // __cplusplus > 201103L + // @} group chrono -} // namespace +} // namespace std #endif //_GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 -#if __cplusplus > 201103L - -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 - -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - -inline namespace literals { -inline namespace chrono_literals { - - namespace __detail { - - using namespace __parse_int; - - template - struct _Select_type - : conditional< - _Val <= static_cast - (numeric_limits::max()), - _Dur, void> - { - static constexpr typename _Select_type::type - value{static_cast(_Val)}; - }; - - template - constexpr typename _Select_type<_Val, _Dur>::type - _Select_type<_Val, _Dur>::value; - - } // __detail - - constexpr chrono::duration> - operator"" h(long double __hours) - { return chrono::duration>{__hours}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::hours>::type - operator"" h() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::hours>::value; - } - - constexpr chrono::duration> - operator"" min(long double __mins) - { return chrono::duration>{__mins}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::minutes>::type - operator"" min() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::minutes>::value; - } - - constexpr chrono::duration - operator"" s(long double __secs) - { return chrono::duration{__secs}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::seconds>::type - operator"" s() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::seconds>::value; - } - - constexpr chrono::duration - operator"" ms(long double __msecs) - { return chrono::duration{__msecs}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::milliseconds>::type - operator"" ms() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::milliseconds>::value; - } - - constexpr chrono::duration - operator"" us(long double __usecs) - { return chrono::duration{__usecs}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::microseconds>::type - operator"" us() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::microseconds>::value; - } - - constexpr chrono::duration - operator"" ns(long double __nsecs) - { return chrono::duration{__nsecs}; } - - template - constexpr typename - __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, - chrono::nanoseconds>::type - operator"" ns() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::nanoseconds>::value; - } - -} // inline namespace chrono_literals -} // inline namespace literals - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace std - -#endif //_GLIBCXX_USE_C99_STDINT_TR1 - -#endif // __cplusplus > 201103L - #endif //_GLIBCXX_CHRONO diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/types.cc b/libstdc++-v3/testsuite/20_util/duration/literals/types.cc index 67ef2faf292..710dc425655 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/types.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/types.cc @@ -18,10 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changed -// this test may begin to fail. - #include #include diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/values.cc b/libstdc++-v3/testsuite/20_util/duration/literals/values.cc index 37bbbd02cb7..8f2be113749 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/values.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/values.cc @@ -18,10 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changed -// this test may begin to fail. - #include #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/literals/types.cc b/libstdc++-v3/testsuite/21_strings/basic_string/literals/types.cc index 677f5bf8560..25803853dd8 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/literals/types.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/literals/types.cc @@ -18,10 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changed -// this test may begin to fail. - #include #include diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/literals/values.cc b/libstdc++-v3/testsuite/21_strings/basic_string/literals/values.cc index 09285590e2a..4732f29f814 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/literals/values.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/literals/values.cc @@ -18,10 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changed -// this test may begin to fail. - #include #include