From patchwork Fri Jun 7 14:45:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Smith-Rowland <3dw4rd@verizon.net> X-Patchwork-Id: 249735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 8414C2C008F for ; Sat, 8 Jun 2013 00:46:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=Kwbg8OoVcauqKGycbr0mtimxVvJVRxSpdZlE+ozI9ZYjiZ fYKCrh3hixW024PmhbD+3C/Ayuc/+PcPFDZYVMwXrvoPp6SrST8myEz5LYPAC4dG Jj2tGtiOG0vlZnMtdN+m2YnJUc15JvraO3SM2JKF1BrD0I1dTAe/4RANu4WzM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=/x9aT6voG/KGcWULKzPILiypP5g=; b=UnkhvLKfZJgKLAOwULCa B7VKeq+ocTGmE7qfTO625dHpsgUKtBRebt8Tp1CUpxBptZx5t/vjizWKO+Ovgt25 H3S8V9S8CKI1lURdm9GawrKXjShM08HUzeaJ+XYIyJfay2G5vqsy7osiPSHQuVBa JY+t6OZG5A1FoB0wuUt+yCM= Received: (qmail 3387 invoked by alias); 7 Jun 2013 14:45:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3369 invoked by uid 89); 7 Jun 2013 14:45:56 -0000 X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=AWL, BAYES_00, BOTNET, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from vms173011pub.verizon.net (HELO vms173011pub.verizon.net) (206.46.173.11) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 07 Jun 2013 14:45:55 +0000 Received: from [192.168.1.4] ([unknown] [96.244.50.87]) by vms173011.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0MO1006IP2C45430@vms173011.mailsrvcs.net>; Fri, 07 Jun 2013 09:45:41 -0500 (CDT) Message-id: <51B1F216.2070405@verizon.net> Date: Fri, 07 Jun 2013 10:45:42 -0400 From: Ed Smith-Rowland <3dw4rd@verizon.net> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-version: 1.0 To: "libstdc++@gcc.gnu.org" , gcc-patches , Jonathan Wakely Subject: Clean up after standard literals patch. Content-type: multipart/mixed; boundary=------------070507060005070409010700 X-Virus-Found: No Greetings, Jonathan had asked if I could make some simplifications to the organization of C++ versioning macros and namespaces in my standard literals patch. I plum forgot to do it before I put in the patch. Also, I noticed I had picked up some garbage comments in the test cases. This patch cleans all that up. Built and tested on x86_64-linux. Thanks, Ed Smith-Rowland 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. Index: include/std/chrono =================================================================== --- include/std/chrono (revision 199730) +++ include/std/chrono (working copy) @@ -713,7 +713,7 @@ * * 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 @@ */ 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 + struct _Select_type + : conditional< + _Val <= static_cast + (numeric_limits::max()), + _Dur, void> + { + static constexpr typename _Select_type::type + value{static_cast(_Val)}; + }; -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + 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> + operator"" h(long double __hours) + { return chrono::duration>{__hours}; } - using namespace __parse_int; - - template - struct _Select_type - : conditional< - _Val <= static_cast - (numeric_limits::max()), - _Dur, void> + template + constexpr typename + __detail::_Select_type<__select_int::_Select_int<_Digits...>::value, + chrono::hours>::type + operator"" h() { - static constexpr typename _Select_type::type - value{static_cast(_Val)}; - }; + return __detail::_Select_type< + __select_int::_Select_int<_Digits...>::value, + chrono::hours>::value; + } - template - constexpr typename _Select_type<_Val, _Dur>::type - _Select_type<_Val, _Dur>::value; + constexpr chrono::duration> + operator"" min(long double __mins) + { return chrono::duration>{__mins}; } - } // __detail + 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"" h(long double __hours) - { return chrono::duration>{__hours}; } + 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::hours>::type - operator"" h() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::hours>::value; - } + 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"" min(long double __mins) - { return chrono::duration>{__mins}; } + 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::minutes>::type - operator"" min() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::minutes>::value; - } + 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"" s(long double __secs) - { return chrono::duration{__secs}; } + 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::seconds>::type - operator"" s() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::seconds>::value; - } + 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"" ms(long double __msecs) - { return chrono::duration{__msecs}; } + 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::milliseconds>::type - operator"" ms() - { - return __detail::_Select_type< - __select_int::_Select_int<_Digits...>::value, - chrono::milliseconds>::value; - } + 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; + } - constexpr chrono::duration - operator"" us(long double __usecs) - { return chrono::duration{__usecs}; } + } // inline namespace chrono_literals + } // inline namespace literals - 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; - } +#endif // __cplusplus > 201103L - 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 + // @} group chrono } // namespace std #endif //_GLIBCXX_USE_C99_STDINT_TR1 -#endif // __cplusplus > 201103L +#endif // C++11 #endif //_GLIBCXX_CHRONO Index: include/bits/basic_string.h =================================================================== --- include/bits/basic_string.h (revision 199730) +++ include/bits/basic_string.h (working copy) @@ -3103,46 +3103,39 @@ { }; #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 */ Index: testsuite/20_util/duration/literals/types.cc =================================================================== --- testsuite/20_util/duration/literals/types.cc (revision 199730) +++ testsuite/20_util/duration/literals/types.cc (working copy) @@ -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 Index: testsuite/20_util/duration/literals/values.cc =================================================================== --- testsuite/20_util/duration/literals/values.cc (revision 199730) +++ testsuite/20_util/duration/literals/values.cc (working copy) @@ -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 Index: testsuite/21_strings/basic_string/literals/types.cc =================================================================== --- testsuite/21_strings/basic_string/literals/types.cc (revision 199730) +++ testsuite/21_strings/basic_string/literals/types.cc (working copy) @@ -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 Index: testsuite/21_strings/basic_string/literals/values.cc =================================================================== --- testsuite/21_strings/basic_string/literals/values.cc (revision 199730) +++ testsuite/21_strings/basic_string/literals/values.cc (working copy) @@ -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