libstdc++
tr2/type_traits
Go to the documentation of this file.
00001 // TR2 <type_traits> -*- C++ -*-
00002 
00003 // Copyright (C) 2011, 2012 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file tr2/type_traits
00026  *  This is a TR2 C++ Library header.
00027  */
00028 
00029 #ifndef _GLIBCXX_TR2_TYPE_TRAITS
00030 #define _GLIBCXX_TR2_TYPE_TRAITS 1
00031 
00032 #pragma GCC system_header
00033 #include <type_traits>
00034 #include <bits/c++config.h>
00035 
00036 namespace std _GLIBCXX_VISIBILITY(default)
00037 {
00038 namespace tr2
00039 {
00040 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00041 
00042   /**
00043    * @addtogroup metaprogramming
00044    * @{
00045    */
00046 
00047   /**
00048    *  See N2965: Type traits and base classes
00049    *  by Michael Spertus
00050    */
00051 
00052   /**
00053    *  Simple typelist. Compile-time list of types.
00054    */
00055   template<typename... _Elements>
00056     struct __reflection_typelist;
00057 
00058   /// Specialization for an empty typelist.
00059   template<>
00060     struct __reflection_typelist<>
00061     {
00062       typedef std::true_type                    empty;
00063     };
00064 
00065   /// Partial specialization.
00066   template<typename _First, typename... _Rest>
00067     struct __reflection_typelist<_First, _Rest...>
00068     {
00069       typedef std::false_type                   empty;
00070 
00071       struct first
00072       {
00073     typedef _First                      type;
00074       };
00075 
00076       struct rest
00077       {
00078     typedef __reflection_typelist<_Rest...>         type;
00079       };
00080     };
00081 
00082   /// Sequence abstraction metafunctions for manipulating a typelist.
00083 
00084 
00085 
00086   /// Enumerate all the base classes of a class. Form of a typelist.
00087   template<typename _Tp>
00088     struct bases
00089     {
00090       typedef __reflection_typelist<__bases(_Tp)...>        type;
00091     };
00092 
00093   /// Enumerate all the direct base classes of a class. Form of a typelist.
00094   template<typename _Tp>
00095     struct direct_bases
00096     {
00097       typedef __reflection_typelist<__direct_bases(_Tp)...> type;
00098     };
00099 
00100   /// @} group metaprogramming
00101 
00102 _GLIBCXX_END_NAMESPACE_VERSION
00103 }
00104 }
00105 
00106 #endif // _GLIBCXX_TR2_TYPE_TRAITS