diff mbox

[C++11,C++14,3/3] Support for SD-6: SG10 Feature Test Recommendations - libstdc++

Message ID 53894FD9.7040705@verizon.net
State New
Headers show

Commit Message

Ed Smith-Rowland May 31, 2014, 3:43 a.m. UTC
This is the libstdc++ and libstdc++ testsuite part.
2014-05-31  Ed Smith-Rowland  <3dw4rd@verizon.net>

	Implement SD-6: SG10 Feature Test Recommendations
	* include/bits/basic_string.h: Add __cpp_lib feature test macro.
	* include/bits/stl_algobase.h: Ditto.
	* include/bits/stl_function.h: Ditto.
	* include/bits/unique_ptr.h: Ditto.
	* include/std/array: Ditto.
	* include/std/chrono: Ditto.
	* include/std/complex: Ditto.
	* include/std/iomanip: Ditto.
	* include/std/mutex: Ditto.
	* include/std/shared_mutex: Ditto.
	* include/std/tuple: Ditto.
	* include/std/type_traits: Ditto.
	* include/std/utility: Ditto.
	* testsuite/experimental/feat-cxx14.cc: New.
	* testsuite/experimental/feat-lib-fund.cc: New.

Comments

Marc Glisse May 31, 2014, 6:34 a.m. UTC | #1
On Fri, 30 May 2014, Ed Smith-Rowland wrote:

> +#define __cpp_lib_constexpr_functions 201210

appears quite a few times, I believe it will warn with -Wsystem-headers. I 
think you should check if it is already defined (or undefine it first).

(you forgot to Cc: libstdc++)
diff mbox

Patch

Index: include/bits/basic_string.h
===================================================================
--- include/bits/basic_string.h	(revision 211078)
+++ include/bits/basic_string.h	(working copy)
@@ -3124,6 +3124,8 @@ 
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_string_udls 201304
+
   inline namespace literals
   {
   inline namespace string_literals
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h	(revision 211078)
+++ include/bits/stl_algobase.h	(working copy)
@@ -1091,6 +1091,7 @@ 
     }
 
 #if __cplusplus > 201103L
+#define __cpp_lib_robust_nonmodifying_seq_ops 201304
   /**
    *  @brief Tests a range for element-wise equality.
    *  @ingroup non_mutating_algorithms
Index: include/bits/stl_function.h
===================================================================
--- include/bits/stl_function.h	(revision 211078)
+++ include/bits/stl_function.h	(working copy)
@@ -217,6 +217,10 @@ 
     };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_transparent_operators 201210
+#define __cpp_lib_generic_associative_lookup 201304
+
   template<>
     struct plus<void>
     {
Index: include/bits/unique_ptr.h
===================================================================
--- include/bits/unique_ptr.h	(revision 211078)
+++ include/bits/unique_ptr.h	(working copy)
@@ -743,6 +743,9 @@ 
     };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_make_unique 201304
+
   template<typename _Tp>
     struct _MakeUniq
     { typedef unique_ptr<_Tp> __single_object; };
Index: include/std/array
===================================================================
--- include/std/array	(revision 211078)
+++ include/std/array	(working copy)
@@ -35,6 +35,8 @@ 
 # include <bits/c++0x_warning.h>
 #else
 
+#define __cpp_lib_constexpr_functions 201210
+
 #include <stdexcept>
 #include <bits/stl_algobase.h>
 #include <bits/range_access.h>
Index: include/std/chrono
===================================================================
--- include/std/chrono	(revision 211078)
+++ include/std/chrono	(working copy)
@@ -43,6 +43,8 @@ 
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
+#define __cpp_lib_constexpr_functions 201210
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   /**
@@ -782,6 +784,8 @@ 
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_chrono_udls 201304
+
   inline namespace literals
   {
   inline namespace chrono_literals
Index: include/std/complex
===================================================================
--- include/std/complex	(revision 211078)
+++ include/std/complex	(working copy)
@@ -1929,6 +1929,8 @@ 
 inline namespace literals {
 inline namespace complex_literals {
 
+#define __cpp_lib_complex_udls 201309
+
   constexpr std::complex<float>
   operator""if(long double __num)
   { return std::complex<float>{0.0F, static_cast<float>(__num)}; }
Index: include/std/iomanip
===================================================================
--- include/std/iomanip	(revision 211078)
+++ include/std/iomanip	(working copy)
@@ -336,6 +336,8 @@ 
 
 #if __cplusplus > 201103L
 
+#define __cpp_lib_quoted_string_io 201304
+
 _GLIBCXX_END_NAMESPACE_VERSION
   namespace __detail {
   _GLIBCXX_BEGIN_NAMESPACE_VERSION
Index: include/std/mutex
===================================================================
--- include/std/mutex	(revision 211078)
+++ include/std/mutex	(working copy)
@@ -35,6 +35,9 @@ 
 # include <bits/c++0x_warning.h>
 #else
 
+// For backwards compatibility of SD-6.
+#define __cpp_lib_shared_mutex 201304
+
 #include <tuple>
 #include <chrono>
 #include <exception>
Index: include/std/shared_mutex
===================================================================
--- include/std/shared_mutex	(revision 211078)
+++ include/std/shared_mutex	(working copy)
@@ -52,6 +52,9 @@ 
    */
 
 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+#define __cpp_lib_shared_mutex 201402
+
   /// shared_timed_mutex
   class shared_timed_mutex
   {
Index: include/std/tuple
===================================================================
--- include/std/tuple	(revision 211078)
+++ include/std/tuple	(working copy)
@@ -744,6 +744,9 @@ 
     }
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_tuples_by_type 201304
+
   template<typename _Head, size_t __i, typename... _Tail>
     constexpr _Head&
     __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
Index: include/std/type_traits
===================================================================
--- include/std/type_traits	(revision 211078)
+++ include/std/type_traits	(working copy)
@@ -73,6 +73,9 @@ 
       typedef integral_constant<_Tp, __v>   type;
       constexpr operator value_type() const { return value; }
 #if __cplusplus > 201103L
+
+#define __cpp_lib_integral_constant_callable 201304
+
       constexpr value_type operator()() const { return value; }
 #endif
     };
@@ -1451,6 +1454,9 @@ 
     };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_transformation_trait_aliases 201304
+
   /// Alias template for remove_const
   template<typename _Tp>
     using remove_const_t = typename remove_const<_Tp>::type;
@@ -2044,6 +2050,8 @@ 
 
   // Sfinae-friendly result_of implementation:
 
+#define __cpp_lib_result_of_sfinae 201210
+
   // [func.require] paragraph 1 bullet 1:
   struct __result_of_memfun_ref_impl
   {
Index: include/std/utility
===================================================================
--- include/std/utility	(revision 211078)
+++ include/std/utility	(working copy)
@@ -70,6 +70,9 @@ 
 #include <bits/stl_pair.h>
 
 #if __cplusplus >= 201103L
+
+#define __cpp_lib_constexpr_functions 201210
+
 #include <bits/move.h>
 #include <initializer_list>
 
@@ -157,6 +160,9 @@ 
     { return __pair_get<_Int>::__const_get(__in); }
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_tuples_by_type 201304
+
   template <typename _Tp, typename _Up>
     constexpr _Tp&
     get(pair<_Tp, _Up>& __p) noexcept
@@ -187,6 +193,8 @@ 
     get(pair<_Up, _Tp>&& __p) noexcept
     { return std::move(__p.second); }
 
+#define __cpp_lib_exchange_function 201304
+
   /// Assign @p __new_val to @p __obj and return its previous value.
   template <typename _Tp, typename _Up = _Tp>
     inline _Tp
@@ -220,6 +228,9 @@ 
     };
 
 #if __cplusplus > 201103L
+
+#define __cpp_lib_integer_sequence 201304
+
   /// Class template integer_sequence
   template<typename _Tp, _Tp... _Idx>
     struct integer_sequence
Index: testsuite/experimental/feat-cxx14.cc
===================================================================
--- testsuite/experimental/feat-cxx14.cc	(revision 0)
+++ testsuite/experimental/feat-cxx14.cc	(working copy)
@@ -0,0 +1,113 @@ 
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+#include <utility>
+#include <tuple>
+#include <memory>
+#include <functional>
+#include <type_traits>
+#include <chrono>
+#include <string>
+#include <complex>
+#include <iomanip>
+#include <shared_mutex>
+
+#ifndef  __cpp_lib_integer_sequence
+#  error "__cpp_lib_integer_sequence"
+#elif  __cpp_lib_integer_sequence != 201304
+#  error "__cpp_lib_integer_sequence != 201304"
+#endif
+
+#ifndef  __cpp_lib_exchange_function
+#  error "__cpp_lib_exchange_function"
+#elif  __cpp_lib_exchange_function != 201304
+#  error "__cpp_lib_exchange_function != 201304"
+#endif
+
+#ifndef  __cpp_lib_tuples_by_type
+#  error "__cpp_lib_tuples_by_type"
+#elif  __cpp_lib_tuples_by_type != 201304
+#  error "__cpp_lib_tuples_by_type != 201304"
+#endif
+
+#ifndef  __cpp_lib_make_unique
+#  error "__cpp_lib_make_unique"
+#elif  __cpp_lib_make_unique != 201304
+#  error "__cpp_lib_make_unique != 201304"
+#endif
+
+#ifndef  __cpp_lib_transparent_operators
+#  error "__cpp_lib_transparent_operators"
+#elif  __cpp_lib_transparent_operators != 201210
+#  error "__cpp_lib_transparent_operators != 201210"
+#endif
+
+#ifndef  __cpp_lib_result_of_sfinae
+#  error "__cpp_lib_result_of_sfinae"
+#elif  __cpp_lib_result_of_sfinae != 201210
+#  error "__cpp_lib_result_of_sfinae != 201210"
+#endif
+
+#ifndef  __cpp_lib_integral_constant_callable
+#  error "__cpp_lib_integral_constant_callable"
+#elif  __cpp_lib_integral_constant_callable != 201304
+#  error "__cpp_lib_integral_constant_callable != 201304"
+#endif
+
+#ifndef  __cpp_lib_transformation_trait_aliases
+#  error "__cpp_lib_transformation_trait_aliases"
+#elif  __cpp_lib_transformation_trait_aliases != 201304
+#  error "__cpp_lib_transformation_trait_aliases != 201304"
+#endif
+
+#ifndef  __cpp_lib_chrono_udls
+#  error "__cpp_lib_chrono_udls"
+#elif  __cpp_lib_chrono_udls != 201304
+#  error "__cpp_lib_chrono_udls != 201304"
+#endif
+
+#ifndef  __cpp_lib_string_udls
+#  error "__cpp_lib_string_udls"
+#elif  __cpp_lib_string_udls != 201304
+#  error "__cpp_lib_string_udls != 201304"
+#endif
+
+#ifndef __cpp_lib_complex_udls
+#  error "__cpp_lib_complex_udls"
+#elif  __cpp_lib_complex_udls != 201309
+#  error "__cpp_lib_complex_udls != 201309"
+#endif
+
+#ifndef  __cpp_lib_generic_associative_lookup
+#  error "__cpp_lib_generic_associative_lookup"
+#elif  __cpp_lib_generic_associative_lookup != 201304
+#  error "__cpp_lib_generic_associative_lookup != 201304"
+#endif
+
+//#ifndef  __cpp_lib_null_iterators
+//#  error "__cpp_lib_null_iterators"
+//#elif  __cpp_lib_null_iterators != 201304
+//#  error "__cpp_lib_null_iterators != 201304"
+//#endif
+
+#ifndef  __cpp_lib_robust_nonmodifying_seq_ops
+#  error "__cpp_lib_robust_nonmodifying_seq_ops"
+#elif  __cpp_lib_robust_nonmodifying_seq_ops != 201304
+#  error "__cpp_lib_robust_nonmodifying_seq_ops != 201304"
+#endif
+
+#ifndef  __cpp_lib_quoted_string_io
+#  error "__cpp_lib_quoted_string_io"
+#elif  __cpp_lib_quoted_string_io != 201304
+#  error "__cpp_lib_quoted_string_io != 201304"
+#endif
+
+#if !__has_include(<shared_mutex>)
+#  error "<shared_mutex>"
+#endif
+
+#ifndef  __cpp_lib_shared_mutex
+#  error "__cpp_lib_shared_mutex"
+#elif  __cpp_lib_shared_mutex != 201402
+#  error "__cpp_lib_shared_mutex != 201402"
+#endif
Index: testsuite/experimental/feat-lib-fund.cc
===================================================================
--- testsuite/experimental/feat-lib-fund.cc	(revision 0)
+++ testsuite/experimental/feat-lib-fund.cc	(working copy)
@@ -0,0 +1,25 @@ 
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+#include <experimental/optional>
+#include <experimental/string_view>
+
+#if !__has_include(<experimental/optional>)
+#  error "<experimental/optional>"
+#endif
+
+//#if !__has_include(<experimental/net>)
+//#  error "<experimental/net>"
+//#endif
+
+//#if !__has_include(<experimental/any>)
+//#  error "<experimental/any>"
+//#endif
+
+//#if !__has_include(<experimental/memory_resource>)
+//#  error "<experimental/memory_resource>"
+//#endif
+
+#if !__has_include(<experimental/string_view>)
+#  error "<experimental/string_view>"
+#endif