Message ID | 53F91799.2070902@verizon.net |
---|---|
State | New |
Headers | show |
Hi, On 08/24/2014 12:37 AM, Ed Smith-Rowland wrote: > With revision 214400 we have the C++14 value of __cplusplus set to the > correct value of 201402L (from 201300L). It occurs to me: instead of having to remember every time those numbers, couldn't we predefine, for example: __cplusplus_98 __cplusplus_11 __cplusplus_14 with the correct values of course?!? Thanks, Paolo.
Paolo Carlini <paolo.carlini@oracle.com> writes: > Hi, > > On 08/24/2014 12:37 AM, Ed Smith-Rowland wrote: >> With revision 214400 we have the C++14 value of __cplusplus set to the >> correct value of 201402L (from 201300L). > It occurs to me: instead of having to remember every time those numbers, > couldn't we predefine, for example: > > __cplusplus_98 > __cplusplus_11 > __cplusplus_14 > > with the correct values of course?!? But won't this lead to portability trouble in the future when people see those macros and start using them in their own code, breaking compilation with older or non-g++ compilers? Rainer
On 26/08/14 10:28 +0200, Paolo Carlini wrote: >Hi, > >On 08/24/2014 12:37 AM, Ed Smith-Rowland wrote: >>With revision 214400 we have the C++14 value of __cplusplus set to >>the correct value of 201402L (from 201300L). >It occurs to me: instead of having to remember every time those >numbers, couldn't we predefine, for example: > > __cplusplus_98 > __cplusplus_11 > __cplusplus_14 > >with the correct values of course?!? That seems like a good idea, but I'm not convinced there's any benefit in Ed's changes to do: -#if __cplusplus > 201103L +#if __cplusplus >= 201402L It seems like unnecessary churn to me, but if someone was changing every test to use a symbolic constant instead of an integer literal then I suppose it does no harm to change "> C++11" to ">= C++14" at the same time.
Hi, On 08/26/2014 10:42 AM, Rainer Orth wrote: > Paolo Carlini <paolo.carlini@oracle.com> writes: > >> Hi, >> >> On 08/24/2014 12:37 AM, Ed Smith-Rowland wrote: >>> With revision 214400 we have the C++14 value of __cplusplus set to the >>> correct value of 201402L (from 201300L). >> It occurs to me: instead of having to remember every time those numbers, >> couldn't we predefine, for example: >> >> __cplusplus_98 >> __cplusplus_11 >> __cplusplus_14 >> >> with the correct values of course?!? > But won't this lead to portability trouble in the future when people see > those macros and start using them in their own code, breaking > compilation with older or non-g++ compilers? Well, this can happen for any GNU predefined macro... What can I say, I tried to help ;) As a last resort we can maybe define the macros in bits/c++config... Paolo.
Hi, On 08/26/2014 10:52 AM, Jonathan Wakely wrote: > That seems like a good idea, but I'm not convinced there's any benefit > in Ed's changes to do: > > -#if __cplusplus > 201103L > +#if __cplusplus >= 201402L > > It seems like unnecessary churn to me, about this, I had the same thought ;) Paolo.
Hi Paolo, > On 08/26/2014 10:42 AM, Rainer Orth wrote: >> Paolo Carlini <paolo.carlini@oracle.com> writes: >> >>> Hi, >>> >>> On 08/24/2014 12:37 AM, Ed Smith-Rowland wrote: >>>> With revision 214400 we have the C++14 value of __cplusplus set to the >>>> correct value of 201402L (from 201300L). >>> It occurs to me: instead of having to remember every time those numbers, >>> couldn't we predefine, for example: >>> >>> __cplusplus_98 >>> __cplusplus_11 >>> __cplusplus_14 >>> >>> with the correct values of course?!? >> But won't this lead to portability trouble in the future when people see >> those macros and start using them in their own code, breaking >> compilation with older or non-g++ compilers? > Well, this can happen for any GNU predefined macro... What can I say, I true, but in this case they will be prominent throughout libstdc++ headers. > tried to help ;) As a last resort we can maybe define the macros in Greatly appreciated: they are certainly way more mnemonic than the naked numbers ;-) > bits/c++config... Which won't help users seeing them in the headers. Maybe the issue could be avoided by chosing names that make it clear that they are g++/libstdc++ specific, not generic? Thanks. Rainer
Hi, On 08/26/2014 10:56 AM, Rainer Orth wrote: > bits/c++config... > Which won't help users seeing them in the headers. Maybe the issue > could be avoided by chosing names that make it clear that they are > g++/libstdc++ specific, not generic? Sure, whatever works, the names were tentative, for the cpp idea. Paolo.
On 08/26/2014 04:59 AM, Paolo Carlini wrote: > Hi, > > On 08/26/2014 10:56 AM, Rainer Orth wrote: >> bits/c++config... >> Which won't help users seeing them in the headers. Maybe the issue >> could be avoided by chosing names that make it clear that they are >> g++/libstdc++ specific, not generic? > Sure, whatever works, the names were tentative, for the cpp idea. > > Paolo. > I should have mentioned this thought. Maybe we could do something more scary like __GLIBCXX_CPLUSPLUS_98 __GLIBCXX_CPLUSPLUS_11 __GLIBCXX_CPLUSPLUS_14 so people won't use them. The __cplusplus_11 etc. look almost "standard" ;-) Ed
On 26/08/14 07:11 -0400, Ed Smith-Rowland wrote: >On 08/26/2014 04:59 AM, Paolo Carlini wrote: >>Hi, >> >>On 08/26/2014 10:56 AM, Rainer Orth wrote: >>>bits/c++config... >>>Which won't help users seeing them in the headers. Maybe the issue >>>could be avoided by chosing names that make it clear that they are >>>g++/libstdc++ specific, not generic? >>Sure, whatever works, the names were tentative, for the cpp idea. >> >>Paolo. >> >I should have mentioned this thought. > >Maybe we could do something more scary like > > __GLIBCXX_CPLUSPLUS_98 > __GLIBCXX_CPLUSPLUS_11 > __GLIBCXX_CPLUSPLUS_14 If they're macros defined by the library they should start with _GLIBCXX (i.e. a single underscore). >so people won't use them. > >The __cplusplus_11 etc. look almost "standard" ;-) Agreed.
Hi again, On 08/26/2014 10:54 AM, Paolo Carlini wrote: > Hi, > > On 08/26/2014 10:52 AM, Jonathan Wakely wrote: >> That seems like a good idea, but I'm not convinced there's any benefit >> in Ed's changes to do: >> >> -#if __cplusplus > 201103L >> +#if __cplusplus >= 201402L >> >> It seems like unnecessary churn to me, > about this, I had the same thought ;) By the way, in case isn't already clear, it occurs to me that the kind of change proposed by Ed, thus standardize on __cplusplus >= "required version", will make more sense when the C++17 Standard will be closer. So far, since we can simply do everything with only 201103L, my idea too of adding _GLIBCXX_CXX11 & co seems quite pointless. Paolo.
On 09/15/2014 05:17 AM, Paolo Carlini wrote: > Hi again, > > On 08/26/2014 10:54 AM, Paolo Carlini wrote: >> Hi, >> >> On 08/26/2014 10:52 AM, Jonathan Wakely wrote: >>> That seems like a good idea, but I'm not convinced there's any benefit >>> in Ed's changes to do: >>> >>> -#if __cplusplus > 201103L >>> +#if __cplusplus >= 201402L >>> >>> It seems like unnecessary churn to me, >> about this, I had the same thought ;) > By the way, in case isn't already clear, it occurs to me that the kind > of change proposed by Ed, thus standardize on __cplusplus >= "required > version", will make more sense when the C++17 Standard will be closer. > So far, since we can simply do everything with only 201103L, my idea > too of adding _GLIBCXX_CXX11 & co seems quite pointless. > > Paolo. > I understand. I guess I was looking far ahead through the eyes of some new maintainer where we have CXX11, CXX14, CXX17, CXX20, ... and after the experimental names Cxx0x, Cxx1y had long lost their meaning and thinking that these dates and names would be a jumble. As new library components come into std:: proper we should look at straightening that out and standardizing on something. For now, one date works well. The new libraries are safely tucked away in experimental behind #if __cplusplus <= 201103L # include <bits/c++14_warning.h> #else *** Jonathan: <filesystem> uses: #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else and should probably eventually be like the others. Ed
On 15/09/14 07:15 -0400, Ed Smith-Rowland wrote: >The new libraries are safely tucked away in experimental behind >#if __cplusplus <= 201103L ># include <bits/c++14_warning.h> >#else > >*** Jonathan: <filesystem> uses: > >#if __cplusplus < 201103L ># include <bits/c++0x_warning.h> >#else >and should probably eventually be like the others. My Filesystem implementation works fine in C++11, I see no reason to force C++14 usage when it isn't needed.
Index: libsupc++/new =================================================================== --- libsupc++/new (revision 214399) +++ libsupc++/new (working copy) @@ -81,7 +81,7 @@ // We throw this exception for GNU VLAs of negative length in all C++ // dialects, so declare it if we aren't in strict conformance mode. -#if __cplusplus > 201103L || !defined(__STRICT_ANSI__) +#if __cplusplus >= 201402L || !defined(__STRICT_ANSI__) class bad_array_length : public bad_alloc { public: Index: include/bits/parse_numbers.h =================================================================== --- include/bits/parse_numbers.h (revision 214399) +++ include/bits/parse_numbers.h (working copy) @@ -34,7 +34,7 @@ // From n3642.pdf except I added binary literals and digit separator '\''. -#if __cplusplus > 201103L +#if __cplusplus >= 201402L #include <limits> @@ -283,6 +283,6 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace std -#endif // __cplusplus > 201103L +#endif // __cplusplus >= 201402L #endif // _GLIBCXX_PARSE_NUMBERS_H Index: include/bits/stl_function.h =================================================================== --- include/bits/stl_function.h (revision 214399) +++ include/bits/stl_function.h (working copy) @@ -56,7 +56,7 @@ #ifndef _STL_FUNCTION_H #define _STL_FUNCTION_H 1 -#if __cplusplus > 201103L +#if __cplusplus >= 201402L #include <bits/move.h> #endif @@ -140,7 +140,7 @@ * @{ */ -#if __cplusplus > 201103L +#if __cplusplus >= 201402L struct __is_transparent; // undefined template<typename _Tp = void> @@ -216,7 +216,7 @@ { return -__x; } }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<> struct plus<void> { @@ -311,7 +311,7 @@ * * @{ */ -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _Tp = void> struct equal_to; @@ -385,7 +385,7 @@ { return __x <= __y; } }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// One of the @link comparison_functors comparison functors@endlink. template<> struct equal_to<void> @@ -481,7 +481,7 @@ * * @{ */ -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _Tp = void> struct logical_and; @@ -519,7 +519,7 @@ { return !__x; } }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// One of the @link logical_functors Boolean operations functors@endlink. template<> struct logical_and<void> @@ -564,7 +564,7 @@ #endif /** @} */ -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _Tp = void> struct bit_and; @@ -612,7 +612,7 @@ { return ~__x; } }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template <> struct bit_and<void> { Index: include/bits/unique_ptr.h =================================================================== --- include/bits/unique_ptr.h (revision 214399) +++ include/bits/unique_ptr.h (working copy) @@ -742,7 +742,7 @@ } }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _Tp> struct _MakeUniq { typedef unique_ptr<_Tp> __single_object; }; Index: include/bits/stl_algo.h =================================================================== --- include/bits/stl_algo.h (revision 214399) +++ include/bits/stl_algo.h (working copy) @@ -3570,7 +3570,7 @@ __gnu_cxx::__ops::__iter_comp_iter(__pred)); } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _ForwardIterator1, typename _ForwardIterator2, typename _BinaryPredicate> bool Index: include/bits/stl_algobase.h =================================================================== --- include/bits/stl_algobase.h (revision 214399) +++ include/bits/stl_algobase.h (working copy) @@ -1090,7 +1090,7 @@ return true; } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /** * @brief Tests a range for element-wise equality. * @ingroup non_mutating_algorithms @@ -1326,7 +1326,7 @@ __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _InputIterator1, typename _InputIterator2, typename _BinaryPredicate> Index: include/bits/basic_string.h =================================================================== --- include/bits/basic_string.h (revision 214399) +++ include/bits/basic_string.h (working copy) @@ -3138,7 +3138,7 @@ { }; #endif -#if __cplusplus > 201103L +#if __cplusplus >= 201402L inline namespace literals { @@ -3168,7 +3168,7 @@ } // inline namespace string_literals } // inline namespace literals -#endif // __cplusplus > 201103L +#endif // __cplusplus >= 201402L _GLIBCXX_END_NAMESPACE_VERSION } // namespace std Index: include/std/complex =================================================================== --- include/std/complex (revision 214399) +++ include/std/complex (working copy) @@ -1924,7 +1924,7 @@ conj(_Tp __x) { return __x; } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L inline namespace literals { inline namespace complex_literals { Index: include/std/iomanip =================================================================== --- include/std/iomanip (revision 214399) +++ include/std/iomanip (working copy) @@ -41,7 +41,7 @@ #if __cplusplus >= 201103L #include <locale> -#if __cplusplus > 201103L +#if __cplusplus >= 201402L #include <sstream> // used in quoted. #endif #endif @@ -337,7 +337,7 @@ return __os; } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L _GLIBCXX_END_NAMESPACE_VERSION namespace __detail { @@ -495,7 +495,7 @@ __string, __delim, __escape); } -#endif // __cplusplus > 201103L +#endif // __cplusplus >= 201402L #endif // __cplusplus >= 201103L Index: include/std/utility =================================================================== --- include/std/utility (revision 214399) +++ include/std/utility (working copy) @@ -156,7 +156,7 @@ get(const std::pair<_Tp1, _Tp2>& __in) noexcept { return __pair_get<_Int>::__const_get(__in); } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template <typename _Tp, typename _Up> constexpr _Tp& get(pair<_Tp, _Up>& __p) noexcept @@ -219,7 +219,7 @@ typedef _Index_tuple<> __type; }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Class template integer_sequence template<typename _Tp, _Tp... _Idx> struct integer_sequence Index: include/std/type_traits =================================================================== --- include/std/type_traits (revision 214399) +++ include/std/type_traits (working copy) @@ -72,7 +72,7 @@ typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; constexpr operator value_type() const { return value; } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L constexpr value_type operator()() const { return value; } #endif }; @@ -1450,7 +1450,7 @@ add_const<typename add_volatile<_Tp>::type>::type type; }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for remove_const template<typename _Tp> using remove_const_t = typename remove_const<_Tp>::type; @@ -1519,7 +1519,7 @@ : public __add_rvalue_reference_helper<_Tp> { }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for remove_reference template<typename _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; @@ -1750,7 +1750,7 @@ template<> struct make_signed<bool>; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for make_signed template<typename _Tp> using make_signed_t = typename make_signed<_Tp>::type; @@ -1788,7 +1788,7 @@ struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for remove_extent template<typename _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; @@ -1829,7 +1829,7 @@ : public __add_pointer_helper<_Tp> { }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for remove_pointer template<typename _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; @@ -2246,7 +2246,7 @@ >::type { }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L /// Alias template for aligned_storage template<size_t _Len, size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> Index: include/std/tuple =================================================================== --- include/std/tuple (revision 214399) +++ include/std/tuple (working copy) @@ -686,7 +686,7 @@ typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type; }; -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<std::size_t __i, typename _Tp> using tuple_element_t = typename tuple_element<__i, _Tp>::type; #endif @@ -745,7 +745,7 @@ return std::forward<__element_type&&>(std::get<__i>(__t)); } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L template<typename _Head, size_t __i, typename... _Tail> constexpr _Head& __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept Index: include/std/chrono =================================================================== --- include/std/chrono (revision 214399) +++ include/std/chrono (working copy) @@ -780,7 +780,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace chrono -#if __cplusplus > 201103L +#if __cplusplus >= 201402L inline namespace literals { @@ -864,7 +864,7 @@ } // inline namespace chrono_literals } // inline namespace literals -#endif // __cplusplus > 201103L +#endif // __cplusplus >= 201402L // @} group chrono } // namespace std Index: include/parallel/algobase.h =================================================================== --- include/parallel/algobase.h (revision 214399) +++ include/parallel/algobase.h (working copy) @@ -114,7 +114,7 @@ std::__iterator_category(__begin2)); } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L // Sequential fallback. template<typename _InputIterator1, typename _InputIterator2> inline pair<_InputIterator1, _InputIterator2> @@ -231,7 +231,7 @@ == __end1; } -#if __cplusplus > 201103L +#if __cplusplus >= 201402L // Sequential fallback template<typename _IIter1, typename _IIter2> inline bool