From patchwork Fri Mar 2 07:11:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v3] tweak traits for base classes Date: Thu, 01 Mar 2012 21:11:33 -0000 From: Benjamin Kosnik X-Patchwork-Id: 144148 Message-Id: <20120301231133.627cd3fb@adair> To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org After discussions in Kona, some suggestions to refine this trait were proposed, as attached. In addition, there is some documentation which will be checked in later. tested x86/linux -benjamin 2012-03-01 Michael Spertus * include/tr2/type_traits (typelist): To __reflection_typelist. (first, rest, empty): Remove. diff --git a/libstdc++-v3/include/tr2/type_traits b/libstdc++-v3/include/tr2/type_traits index 9c301b3..eb8c012 100644 --- a/libstdc++-v3/include/tr2/type_traits +++ b/libstdc++-v3/include/tr2/type_traits @@ -1,6 +1,6 @@ // TR2 -*- C++ -*- -// Copyright (C) 2011 Free Software Foundation, Inc. +// Copyright (C) 2011, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -53,60 +53,48 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Simple typelist. Compile-time list of types. */ template - struct typelist; + struct __reflection_typelist; /// Specialization for an empty typelist. template<> - struct typelist<> + struct __reflection_typelist<> { - typedef std::true_type empty; + typedef std::true_type empty; }; /// Partial specialization. template - struct typelist<_First, _Rest...> + struct __reflection_typelist<_First, _Rest...> { - typedef std::false_type empty; + typedef std::false_type empty; struct first { - typedef _First type; + typedef _First type; }; struct rest { - typedef typelist<_Rest...> type; + typedef __reflection_typelist<_Rest...> type; }; }; /// Sequence abstraction metafunctions for manipulating a typelist. - /// Return the first type in a typelist. - template - struct first : public _Tp::first { }; - - /// Return the typelist minus the first type. - template - struct rest : public _Tp::rest { }; - - /// Query to see if a typelist is empty. - template - struct empty : public _Tp::empty { }; - /// Enumerate all the base classes of a class. Form of a typelist. template struct bases { - typedef typelist<__bases(_Tp)...> type; + typedef __reflection_typelist<__bases(_Tp)...> type; }; /// Enumerate all the direct base classes of a class. Form of a typelist. template struct direct_bases { - typedef typelist<__direct_bases(_Tp)...> type; + typedef __reflection_typelist<__direct_bases(_Tp)...> type; }; /// @} group metaprogramming