public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Use aliases for type traits in C++14 mode.
@ 2014-11-04  2:51 Jonathan Wakely
  2014-11-04  4:25 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2014-11-04  2:51 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/x-patch, Size: 108 bytes --]

For C++14-only components we can use the aliases for type traits.

Tested x86_64-linux, committed to trunk.

[-- Attachment #2: patch-1.txt --]
[-- Type: text/plain, Size: 6296 bytes --]

commit cdb81d65750569f86a526856c99c2ef3c5266d11
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date:   Tue Nov 5 23:21:01 2013 +0000

    Use aliases for type traits in C++14 mode.
    
    	* include/bits/unique_ptr.h (make_unique): Use alias for trait.
    	* include/experimental/optional (__constexpr_addressof): Likewise.
    	(_Optional_base, optional, make_optional): Likewise.

diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index ce38c5a..5c2c534 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -768,7 +768,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     inline typename _MakeUniq<_Tp>::__array
     make_unique(size_t __num)
-    { return unique_ptr<_Tp>(new typename remove_extent<_Tp>::type[__num]()); }
+    { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
 
   /// Disable std::make_unique for arrays of known bound
   template<typename _Tp, typename... _Args>
diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional
index 973775b..7e01abe 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -151,16 +151,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     * overloaded addressof operator (unary operator&), in which case the call
     * will not be a constant expression.
     */
-  template<typename _Tp, typename enable_if<!_Has_addressof<_Tp>::value,
-                                            int>::type...>
+  template<typename _Tp, enable_if_t<!_Has_addressof<_Tp>::value, int>...>
     constexpr _Tp* __constexpr_addressof(_Tp& __t)
     { return &__t; }
 
   /**
     * @brief Fallback overload that defers to __addressof.
     */
-  template<typename _Tp, typename enable_if<_Has_addressof<_Tp>::value,
-                                            int>::type...>
+  template<typename _Tp, enable_if_t<_Has_addressof<_Tp>::value, int>...>
     inline _Tp* __constexpr_addressof(_Tp& __t)
     { return std::__addressof(__t); }
 
@@ -184,7 +182,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // Remove const to avoid prohibition of reusing object storage for
       // const-qualified types in [3.8/9]. This is strictly internal
       // and even optional itself is oblivious to it.
-      using _Stored_type = typename remove_const<_Tp>::type;
+      using _Stored_type = remove_const_t<_Tp>;
 
     public:
       // [X.Y.4.1] Constructors.
@@ -208,10 +206,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
 
       template<typename _Up, typename... _Args,
-               typename enable_if<is_constructible<_Tp,
-                                                   initializer_list<_Up>&,
-                                                   _Args&&...>::value,
-                                  int>::type...>
+               enable_if_t<is_constructible<_Tp,
+                                            initializer_list<_Up>&,
+                                            _Args&&...>::value,
+                           int>...>
         constexpr explicit _Optional_base(in_place_t,
                                           initializer_list<_Up> __il,
                                           _Args&&... __args)
@@ -330,7 +328,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class _Optional_base<_Tp, false>
     {
     private:
-      using _Stored_type = typename remove_const<_Tp>::type;
+      using _Stored_type = remove_const_t<_Tp>;
 
     public:
       constexpr _Optional_base() noexcept
@@ -350,10 +348,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
 
       template<typename _Up, typename... _Args,
-               typename enable_if<is_constructible<_Tp,
-                                                   initializer_list<_Up>&,
-                                                   _Args&&...>::value,
-                                  int>::type...>
+               enable_if_t<is_constructible<_Tp,
+                                            initializer_list<_Up>&,
+                                            _Args&&...>::value,
+			   int>...>
         constexpr explicit _Optional_base(in_place_t,
                                           initializer_list<_Up> __il,
                                           _Args&&... __args)
@@ -472,10 +470,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         // Unique tag type.
         optional<_Tp>>
     {
-      static_assert(__and_<__not_<is_same<typename remove_cv<_Tp>::type,
-					  nullopt_t>>,
-			   __not_<is_same<typename remove_cv<_Tp>::type,
-					  in_place_t>>,
+      static_assert(__and_<__not_<is_same<remove_cv_t<_Tp>, nullopt_t>>,
+			   __not_<is_same<remove_cv_t<_Tp>, in_place_t>>,
 			   __not_<is_reference<_Tp>>>(),
                     "Invalid instantiation of optional<T>");
 
@@ -497,10 +493,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       template<typename _Up>
-        typename enable_if<
-                 is_same<_Tp, typename decay<_Up>::type>::value,
-                 optional&
-               >::type
+        enable_if_t<is_same<_Tp, decay_t<_Up>>::value, optional&>
         operator=(_Up&& __u)
         {
           static_assert(__and_<is_constructible<_Tp, _Up>,
@@ -527,11 +520,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
 
       template<typename _Up, typename... _Args>
-        typename enable_if<
-                 is_constructible<_Tp,
-                                  initializer_list<_Up>&,
-                                  _Args&&...>::value
-               >::type
+        enable_if_t<is_constructible<_Tp, initializer_list<_Up>&,
+				     _Args&&...>::value>
 	emplace(initializer_list<_Up> __il, _Args&&... __args)
 	{
 	  this->_M_reset();
@@ -795,9 +785,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { __lhs.swap(__rhs); }
 
   template<typename _Tp>
-    constexpr optional<typename decay<_Tp>::type>
+    constexpr optional<decay_t<_Tp>>
     make_optional(_Tp&& __t)
-    { return optional<typename decay<_Tp>::type> { std::forward<_Tp>(__t) }; }
+    { return optional<decay_t<_Tp>> { std::forward<_Tp>(__t) }; }
 
   // @} group optional
 _GLIBCXX_END_NAMESPACE_VERSION

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Use aliases for type traits in C++14 mode.
  2014-11-04  2:51 [patch] Use aliases for type traits in C++14 mode Jonathan Wakely
@ 2014-11-04  4:25 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2014-11-04  4:25 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Hmm, not sure how I managed to swap the content-type of the two parts
of that message. The body was meant to read:

On 04/11/14 02:51 +0000, Jonathan Wakely wrote:
>For C++14-only components we can use the aliases for type traits.
>
>Tested x86_64-linux, committed to trunk.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-04  4:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-04  2:51 [patch] Use aliases for type traits in C++14 mode Jonathan Wakely
2014-11-04  4:25 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).