diff options
author | Ed Smith-Rowland <3dw4rd@verizon.net> | 2013-06-08 22:43:18 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2013-06-08 22:43:18 +0000 |
commit | 88c4d6b7988e964625faefd87af6bf55f792609a (patch) | |
tree | bdfcba3df8d9605fc5aa2159b0f9d4871610b778 | |
parent | 83ac9249c8149990f17eea00c092e2ffdbb103f9 (diff) | |
download | gcc-88c4d6b7988e964625faefd87af6bf55f792609a.zip gcc-88c4d6b7988e964625faefd87af6bf55f792609a.tar.gz gcc-88c4d6b7988e964625faefd87af6bf55f792609a.tar.bz2 |
Simplify and clean up library literals.
2013-06-07 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.
From-SVN: r199861
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 43 | ||||
-rw-r--r-- | libstdc++-v3/include/std/chrono | 229 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/duration/literals/types.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/duration/literals/values.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/literals/types.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/literals/values.cc | 4 |
7 files changed, 137 insertions, 161 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index deb7ae2..8ca5e1a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,15 @@ 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 * include/std/iomanip: Add quoted(String, Char delim, Char escape) manipulators and supporting machinery in c++1y mode. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index a249df2..aec48d7 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<char> - operator"" s(const char* __str, size_t __len) - { return basic_string<char>{__str, __len}; } + inline basic_string<char> + operator"" s(const char* __str, size_t __len) + { return basic_string<char>{__str, __len}; } #ifdef _GLIBCXX_USE_WCHAR_T - inline basic_string<wchar_t> - operator"" s(const wchar_t* __str, size_t __len) - { return basic_string<wchar_t>{__str, __len}; } + inline basic_string<wchar_t> + operator"" s(const wchar_t* __str, size_t __len) + { return basic_string<wchar_t>{__str, __len}; } #endif #ifdef _GLIBCXX_USE_C99_STDINT_TR1 - inline basic_string<char16_t> - operator"" s(const char16_t* __str, size_t __len) - { return basic_string<char16_t>{__str, __len}; } + inline basic_string<char16_t> + operator"" s(const char16_t* __str, size_t __len) + { return basic_string<char16_t>{__str, __len}; } - inline basic_string<char32_t> - operator"" s(const char32_t* __str, size_t __len) - { return basic_string<char32_t>{__str, __len}; } + inline basic_string<char32_t> + operator"" s(const char32_t* __str, size_t __len) + { return basic_string<char32_t>{__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 7a574a6..b32fb44 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 - // @} group chrono -} // namespace +#if __cplusplus > 201103L -#endif //_GLIBCXX_USE_C99_STDINT_TR1 + inline namespace literals { + inline namespace chrono_literals { -#endif // C++11 + namespace __detail { -#if __cplusplus > 201103L + using namespace __parse_int; -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + template<unsigned long long _Val, typename _Dur> + struct _Select_type + : conditional< + _Val <= static_cast<unsigned long long> + (numeric_limits<typename _Dur::rep>::max()), + _Dur, void> + { + static constexpr typename _Select_type::type + value{static_cast<typename _Select_type::type>(_Val)}; + }; -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION + template<unsigned long long _Val, typename _Dur> + constexpr typename _Select_type<_Val, _Dur>::type + _Select_type<_Val, _Dur>::value; -inline namespace literals { -inline namespace chrono_literals { + } // __detail - namespace __detail { + constexpr chrono::duration<long double, ratio<3600,1>> + operator"" h(long double __hours) + { return chrono::duration<long double, ratio<3600,1>>{__hours}; } - using namespace __parse_int; + template <char... _Digits> + 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<long double, ratio<60,1>> + operator"" min(long double __mins) + { return chrono::duration<long double, ratio<60,1>>{__mins}; } - template<unsigned long long _Val, typename _Dur> - struct _Select_type - : conditional< - _Val <= static_cast<unsigned long long> - (numeric_limits<typename _Dur::rep>::max()), - _Dur, void> + template <char... _Digits> + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::minutes>::type + operator"" min() { - static constexpr typename _Select_type::type - value{static_cast<typename _Select_type::type>(_Val)}; - }; + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::minutes>::value; + } - template<unsigned long long _Val, typename _Dur> - constexpr typename _Select_type<_Val, _Dur>::type - _Select_type<_Val, _Dur>::value; + constexpr chrono::duration<long double> + operator"" s(long double __secs) + { return chrono::duration<long double>{__secs}; } - } // __detail + template <char... _Digits> + 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<long double, ratio<3600,1>> - operator"" h(long double __hours) - { return chrono::duration<long double, ratio<3600,1>>{__hours}; } + constexpr chrono::duration<long double, milli> + operator"" ms(long double __msecs) + { return chrono::duration<long double, milli>{__msecs}; } - template <char... _Digits> - 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<long double, ratio<60,1>> - operator"" min(long double __mins) - { return chrono::duration<long double, ratio<60,1>>{__mins}; } - - template <char... _Digits> - 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<long double> - operator"" s(long double __secs) - { return chrono::duration<long double>{__secs}; } - - template <char... _Digits> - 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<long double, milli> - operator"" ms(long double __msecs) - { return chrono::duration<long double, milli>{__msecs}; } - - template <char... _Digits> - 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<long double, micro> - operator"" us(long double __usecs) - { return chrono::duration<long double, micro>{__usecs}; } - - template <char... _Digits> - 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<long double, nano> - operator"" ns(long double __nsecs) - { return chrono::duration<long double, nano>{__nsecs}; } - - template <char... _Digits> - 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; - } + template <char... _Digits> + 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; + } -} // inline namespace chrono_literals -} // inline namespace literals + constexpr chrono::duration<long double, micro> + operator"" us(long double __usecs) + { return chrono::duration<long double, micro>{__usecs}; } -_GLIBCXX_END_NAMESPACE_VERSION + template <char... _Digits> + 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<long double, nano> + operator"" ns(long double __nsecs) + { return chrono::duration<long double, nano>{__nsecs}; } + + template <char... _Digits> + 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 std #endif //_GLIBCXX_USE_C99_STDINT_TR1 -#endif // __cplusplus > 201103L +#endif // C++11 #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 67ef2fa..710dc42 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 // <http://www.gnu.org/licenses/>. -// 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 <chrono> #include <type_traits> diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/values.cc b/libstdc++-v3/testsuite/20_util/duration/literals/values.cc index 37bbbd0..8f2be11 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 // <http://www.gnu.org/licenses/>. -// 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 <chrono> #include <testsuite_hooks.h> 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 677f5bf..2580385 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 // <http://www.gnu.org/licenses/>. -// 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 <string> #include <type_traits> 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 0928559..4732f29 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 // <http://www.gnu.org/licenses/>. -// 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 <string> #include <testsuite_hooks.h> |