$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r81607 - in trunk: boost/tti boost/tti/detail libs/tti/test
From: eldiener_at_[hidden]
Date: 2012-11-28 00:20:23
Author: eldiener
Date: 2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
New Revision: 81607
URL: http://svn.boost.org/trac/boost/changeset/81607
Log:
Updated has_type functionality.
Added:
   trunk/boost/tti/detail/dmetafunc.hpp   (contents, props changed)
Removed:
   trunk/libs/tti/test/test_has_type_ct.hpp
Text files modified: 
   trunk/boost/tti/detail/dtype.hpp                 |    53 ++++++++++---                           
   trunk/boost/tti/has_type.hpp                     |   151 ++++++++++++++++++++++++++++++++++----- 
   trunk/libs/tti/test/test_has_type_ct.cpp         |     2                                         
   trunk/libs/tti/test/test_has_type_ct_compile.cpp |     2                                         
   trunk/libs/tti/test/test_has_type_ct_fail.cpp    |     2                                         
   trunk/libs/tti/test/test_has_type_ct_fail2.cpp   |     2                                         
   trunk/libs/tti/test/test_has_type_ct_fail3.cpp   |     2                                         
   trunk/libs/tti/test/test_has_type_ct_fail4.cpp   |     2                                         
   trunk/libs/tti/test/test_has_type_ct_fail5.cpp   |     2                                         
   9 files changed, 180 insertions(+), 38 deletions(-)
Added: trunk/boost/tti/detail/dmetafunc.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/tti/detail/dmetafunc.hpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -0,0 +1,28 @@
+
+//  (C) Copyright Edward Diener 2012
+//  Use, modification and distribution are subject to the Boost Software License,
+//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt).
+
+#if !defined(BOOST_TTI_DETAIL_METAFUNC_HPP)
+#define BOOST_TTI_DETAIL_METAFUNC_HPP
+
+#include <boost/mpl/has_xxx.hpp>
+
+namespace boost
+  {
+  namespace tti
+    {
+    namespace detail
+      {
+      BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(is_metafunction_class_apply, apply, false)
+      template <class TTI_T>
+      struct is_metafunction_class :
+        boost::tti::detail::is_metafunction_class_apply<TTI_T>
+        {
+        };
+      }
+    }
+  }
+  
+#endif // BOOST_TTI_DETAIL_METAFUNC_HPP
Modified: trunk/boost/tti/detail/dtype.hpp
==============================================================================
--- trunk/boost/tti/detail/dtype.hpp	(original)
+++ trunk/boost/tti/detail/dtype.hpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -1,5 +1,5 @@
 
-//  (C) Copyright Edward Diener 2011
+//  (C) Copyright Edward Diener 2011,2012
 //  Use, modification and distribution are subject to the Boost Software License,
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
@@ -8,38 +8,67 @@
 #define BOOST_TTI_DETAIL_TYPE_HPP
 
 #include <boost/config.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/apply.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/not.hpp>
 #include <boost/preprocessor/cat.hpp>
+#include <boost/tti/detail/ddeftype.hpp>
+#include <boost/tti/detail/dmetafunc.hpp>
 #include <boost/tti/gen/namespace_gen.hpp>
 #include <boost/type_traits/is_same.hpp>
-#include <boost/tti/detail/dnotype.hpp>
+
+#define BOOST_TTI_DETAIL_TRAIT_IS_SAME_HAS_TYPE(trait,name) \
+template<class TTI_T,class TTI_U> \
+struct BOOST_PP_CAT(trait,_detail_type_is_same) : \
+  boost::is_same<typename TTI_T::name,TTI_U> \
+  { \
+  }; \
+/**/
+
+#define BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \
+template<class TTI_T,class TTI_MFC> \
+struct BOOST_PP_CAT(trait,_detail_type_invoke) : \
+  boost::mpl::apply<TTI_MFC,typename TTI_T::name> \
+  { \
+  }; \
+/**/
 
 #define BOOST_TTI_DETAIL_TRAIT_HAS_TYPE(trait,name) \
-BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(trait,_detail_mpl), name, false) \
-template<class T,class U,class B> \
-struct BOOST_PP_CAT(trait,_detail) \
+BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(BOOST_PP_CAT(trait,_detail_type_mpl), name, false) \
+BOOST_TTI_DETAIL_TRAIT_IS_SAME_HAS_TYPE(trait,name) \
+BOOST_TTI_DETAIL_TRAIT_INVOKE_HAS_TYPE(trait,name) \
+template<class TTI_T,class TTI_U,class TTI_NOINV,class TTI_B> \
+struct BOOST_PP_CAT(trait,_detail_type) \
   { \
   typedef typename \
     boost::mpl::eval_if \
       < \
-      boost::is_same<typename T::name,U>, \
-      boost::mpl::true_, \
-      boost::mpl::false_ \
+      boost::mpl::and_ \
+        < \
+        boost::mpl::not_ \
+          < \
+          TTI_NOINV \
+          >, \
+        typename BOOST_TTI_NAMESPACE::detail::is_metafunction_class<TTI_U>::type \
+        >, \
+      BOOST_PP_CAT(trait,_detail_type_invoke)<TTI_T,TTI_U>, \
+      BOOST_PP_CAT(trait,_detail_type_is_same)<TTI_T,TTI_U> \
       >::type type; \
   BOOST_STATIC_CONSTANT(bool,value=type::value); \
   }; \
 \
-template<class T,class U> \
-struct BOOST_PP_CAT(trait,_detail)<T,U,boost::mpl::false_::type> \
+template<class TTI_T,class TTI_U,class TTI_NOINV> \
+struct BOOST_PP_CAT(trait,_detail_type)<TTI_T,TTI_U,TTI_NOINV,boost::mpl::false_::type> \
   { \
   typedef boost::mpl::false_::type type; \
   BOOST_STATIC_CONSTANT(bool,value=type::value); \
   }; \
 \
-template<class T> \
-struct BOOST_PP_CAT(trait,_detail)<T,BOOST_TTI_NAMESPACE::detail::notype,boost::mpl::true_::type> \
+template<class TTI_T,class TTI_NOINV> \
+struct BOOST_PP_CAT(trait,_detail_type)<TTI_T,BOOST_TTI_NAMESPACE::detail::deftype,TTI_NOINV,boost::mpl::true_::type> \
   { \
   typedef boost::mpl::true_::type type; \
   BOOST_STATIC_CONSTANT(bool,value=type::value); \
Modified: trunk/boost/tti/has_type.hpp
==============================================================================
--- trunk/boost/tti/has_type.hpp	(original)
+++ trunk/boost/tti/has_type.hpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -1,5 +1,5 @@
 
-//  (C) Copyright Edward Diener 2011
+//  (C) Copyright Edward Diener 2011,2012
 //  Use, modification and distribution are subject to the Boost Software License,
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
@@ -7,11 +7,12 @@
 #if !defined(TTI_HAS_TYPE_HPP)
 #define TTI_HAS_TYPE_HPP
 
+#include <boost/mpl/bool.hpp>
 #include <boost/preprocessor/cat.hpp>
 #include <boost/tti/gen/has_type_gen.hpp>
 #include <boost/tti/gen/namespace_gen.hpp>
 #include <boost/tti/detail/dtype.hpp>
-#include <boost/tti/detail/dnotype.hpp>
+#include <boost/tti/detail/ddeftype.hpp>
 
 /*
 
@@ -22,16 +23,20 @@
 /** \file
 */
 
-/// Expands to a metafunction which tests whether an inner type with a particular name exists and optionally is the same as a particular type.
 /**
 
+    BOOST_TTI_TRAIT_HAS_TYPE is a macro which expands to a metafunction.
+    The metafunction tests whether an inner type with a particular name exists
+    and, optionally, whether a second type is the same type as the inner type
+    or whether a lambda expression invoked with the inner type is true or not.
+    
     trait = the name of the metafunction within the tti namespace.
     
     name  = the name of the inner type.
 
     generates a metafunction called "trait" where 'trait' is the macro parameter.
     
-              template<class TTI_T,class TTI_U>
+              template<class TTI_T,class TTI_U,class TTI_B>
               struct trait
                 {
                 static const value = unspecified;
@@ -42,36 +47,95 @@
     
                 TTI_T = the enclosing type in which to look for our 'name'.
                 
-                TTI_U = the type of the inner type named 'name' as an optional parameter.
+                TTI_U = (optional) An optional template parameter, defaulting to a marker type.. 
+                                   If specified it is a type which is one of two possibilities.
+                                   
+                                   1) A type, which if specified, is checked to be the same as
+                                      the inner type found.
+                                      
+                                   2) An MPL lambda expression which is invoked with the inner 
+                                      type found and must return a constant boolean value.
+                                      
+                TTI_B = (optional) An optional template parameter of type boost::mpl::bool_,
+                                   defaulting to boost::mpl::false_.
+                                   
+                                   If TTI_U is an MPL lambda expression, whose type is meant to 
+                                   be checked to be the same as the inner type, rather than be 
+                                   invoked by the inner type, this parameter shoud be set to
+                                   boost::mpl::true_.
+                
+                returns = 'value' depends on whether or not the optional TTI_U is specified.
                 
-                returns = 'value' is true if the 'name' type exists within the enclosing type TTI_T
-                          and, if type TTI_U is specified, the 'name' type is the same as the type TTI_U,
-                          otherwise 'value' is false.
+                          If TTI_U is not specified, then 'value' is true if the 'name' type 
+                          exists within the enclosing type TTI_T, otherwise 'value' is false.
+                          
+                          If TTI_U is specified there are two possibiltities:
+                          
+                          1) TTI_U is an MPL lambda expression and TTI_B is not specified ( or 
+                             specified as the default boost::mpl::false_ ), then 'value' is true 
+                             if the 'name' type exists within the enclosing type TTI_T and the 
+                             lambda expression as specified by TTI_U, invoked by passing the 
+                             actual inner type of 'name', returns a 'value' of true, otherwise 
+                             'value' is false.
+                             
+                          2) TTI_U is not an MPL lambda expression or TTI_B is boost::mpl::true_,
+                             'value' is true if the 'name' type exists within the enclosing type 
+                             TTI_T and the TTI_U type is the same as the actual inner type,
+                             otherwise 'value' is false.
+                             
+                          In either case the action taken with TTI_U occurs only when the 'name'
+                          type exists within the enclosing type TTI_T.
+                             
+  Example usage:
+  
+  BOOST_TTI_TRAIT_HAS_TYPE(LookFor,MyType) generates the metafunction LookFor in the current scope
+  to look for an inner type called MyType.
+  
+  LookFor<EnclosingType>::value is true if MyType is an inner type of EnclosingType, otherwise false.
+  
+  LookFor<EnclosingType,AnotherType>::value is true if MyType is an inner type of EnclosingType
+    and the inner type is the same type as AnotherType, otherwise false.
+    
+  LookFor<EnclosingType,ALambdaExpression>::value is true if MyType is an inner type of EnclosingType
+    and invoking ALambdaExpression with the inner type returns a value of true, otherwise false.
+  
+  LookFor<EnclosingType,ALambdaExpression,boost::mpl::true_>::value is true if MyType is an inner type 
+    of EnclosingType and the inner type is the same type as ALambdaExpression, otherwise false.
     
 */
 #define BOOST_TTI_TRAIT_HAS_TYPE(trait,name) \
   BOOST_TTI_DETAIL_TRAIT_HAS_TYPE(trait,name) \
-  template<class TTI_T,class TTI_U = BOOST_TTI_NAMESPACE::detail::notype> \
+  template \
+    < \
+    class TTI_T, \
+    class TTI_U = BOOST_TTI_NAMESPACE::detail::deftype, \
+    class TTI_B = boost::mpl::false_ \
+    > \
   struct trait : \
-    BOOST_PP_CAT(trait,_detail) \
+    BOOST_PP_CAT(trait,_detail_type) \
       < \
       TTI_T, \
       TTI_U, \
-      typename BOOST_PP_CAT(trait,_detail_mpl)<TTI_T>::type \
+      TTI_B, \
+      typename BOOST_PP_CAT(trait,_detail_type_mpl)<TTI_T>::type \
       > \
     { \
     }; \
 /**/
 
-/// Expands to a metafunction which tests whether an inner type with a particular name exists and optionally is a particular type.
 /**
 
+    BOOST_TTI_HAS_TYPE is a macro which expands to a metafunction.
+    The metafunction tests whether an inner type with a particular name exists
+    and, optionally, whether a second type is the same type as the inner type
+    or whether a lambda expression invoked with the inner type is true or not.
+    
     name  = the name of the inner type.
 
-    generates a metafunction called "has_type_name" where 'name' is the macro parameter.
+    generates a metafunction called "has_type_'name'" where 'name' is the macro parameter.
     
-              template<class TTI_T,class TTI_U>
-              struct has_type_name
+              template<class TTI_T,class TTI_U,class TTI_B>
+              struct has_type_'name'
                 {
                 static const value = unspecified;
                 typedef mpl::bool_<true-or-false> type;
@@ -81,11 +145,60 @@
     
                 TTI_T = the enclosing type in which to look for our 'name'.
                 
-                TTI_U = the type of the inner type named 'name' as an optional parameter.
+                TTI_U = (optional) An optional template parameter, defaulting to a marker type.. 
+                                   If specified it is a type which is one of two possibilities.
+                                   
+                                   1) A type, which if specified, is checked to be the same as
+                                      the inner type found.
+                                      
+                                   2) An MPL lambda expression which is invoked with the inner 
+                                      type found and must return a constant boolean value.
+                                      
+                TTI_B = (optional) An optional template parameter of type boost::mpl::bool_,
+                                   defaulting to boost::mpl::false_.
+                                   
+                                   If TTI_U is an MPL lambda expression, whose type is meant to 
+                                   be checked to be the same as the inner type, rather than be 
+                                   invoked by the inner type, this parameter shoud be set to
+                                   boost::mpl::true_.
+                
+                returns = 'value' depends on whether or not the optional TTI_U is specified.
                 
-                returns = 'value' is true if the 'name' type exists within the enclosing type TTI_T
-                          and, if type TTI_U is specified, the 'name' type is the same as the type TTI_U,
-                          otherwise 'value' is false.
+                          If TTI_U is not specified, then 'value' is true if the 'name' type 
+                          exists within the enclosing type TTI_T, otherwise 'value' is false.
+                          
+                          If TTI_U is specified there are two possibiltities:
+                          
+                          1) TTI_U is an MPL lambda expression and TTI_B is not specified ( or 
+                             specified as the default boost::mpl::false_ ), then 'value' is true 
+                             if the 'name' type exists within the enclosing type TTI_T and the 
+                             lambda expression as specified by TTI_U, invoked by passing the 
+                             actual inner type of 'name', returns a 'value' of true, otherwise 
+                             'value' is false.
+                             
+                          2) TTI_U is not an MPL lambda expression or TTI_B is boost::mpl::true_,
+                             'value' is true if the 'name' type exists within the enclosing type 
+                             TTI_T and the TTI_U type is the same as the actual inner type,
+                             otherwise 'value' is false.
+                             
+                          In either case the action taken with TTI_U occurs only when the 'name'
+                          type exists within the enclosing type TTI_T.
+                             
+  Example usage:
+  
+  BOOST_TTI_HAS_TYPE(MyType) generates the metafunction has_type_MyType in the current scope
+  to look for an inner type called MyType.
+  
+  has_type_MyType<EnclosingType>::value is true if MyType is an inner type of EnclosingType, otherwise false.
+  
+  has_type_MyType<EnclosingType,AnotherType>::value is true if MyType is an inner type of EnclosingType
+    and the inner type is the same type as AnotherType, otherwise false.
+    
+  has_type_MyType<EnclosingType,ALambdaExpression>::value is true if MyType is an inner type of EnclosingType
+    and invoking ALambdaExpression with the inner type returns a value of true, otherwise false.
+  
+  has_type_MyType<EnclosingType,ALambdaExpression,boost::mpl::true_>::value is true if MyType is an inner type 
+    of EnclosingType and the inner type is the same type as ALambdaExpression, otherwise false.
     
 */
 #define BOOST_TTI_HAS_TYPE(name) \
Modified: trunk/libs/tti/test/test_has_type_ct.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 #include <boost/detail/lightweight_test.hpp>
 
 int main()
Deleted: trunk/libs/tti/test/test_has_type_ct.hpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct.hpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
+++ (empty file)
@@ -1,23 +0,0 @@
-
-//  (C) Copyright Edward Diener 2011
-//  Use, modification and distribution are subject to the Boost Software License,
-//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-//  http://www.boost.org/LICENSE_1_0.txt).
-
-#if !defined(TEST_HAS_TYPE_CHECK_TYPEDEF_HPP)
-#define TEST_HAS_TYPE_CHECK_TYPEDEF_HPP
-
-#include "test_structs.hpp"
-#include <boost/tti/has_type.hpp>
-
-BOOST_TTI_HAS_TYPE(AnIntType)
-BOOST_TTI_TRAIT_HAS_TYPE(NameStruct,AStructType)
-BOOST_TTI_HAS_TYPE(AnIntTypeReference)
-BOOST_TTI_HAS_TYPE(BType)
-BOOST_TTI_TRAIT_HAS_TYPE(TheInteger,AnIntegerType)
-BOOST_TTI_HAS_TYPE(CType)
-BOOST_TTI_HAS_TYPE(AnotherIntegerType)
-BOOST_TTI_TRAIT_HAS_TYPE(SomethingElse,someOtherType)
-BOOST_TTI_HAS_TYPE(NoOtherType)
-
-#endif // TEST_HAS_TYPE_CHECK_TYPEDEF_HPP
Modified: trunk/libs/tti/test/test_has_type_ct_compile.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_compile.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_compile.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 #include <boost/mpl/assert.hpp>
 
 int main()
Modified: trunk/libs/tti/test/test_has_type_ct_fail.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_fail.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_fail.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 #include <boost/mpl/assert.hpp>
 
 int main()
Modified: trunk/libs/tti/test/test_has_type_ct_fail2.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_fail2.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_fail2.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 #include <boost/mpl/assert.hpp>
 
 int main()
Modified: trunk/libs/tti/test/test_has_type_ct_fail3.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_fail3.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_fail3.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 
 int main()
   {
Modified: trunk/libs/tti/test/test_has_type_ct_fail4.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_fail4.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_fail4.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 
 int main()
   {
Modified: trunk/libs/tti/test/test_has_type_ct_fail5.cpp
==============================================================================
--- trunk/libs/tti/test/test_has_type_ct_fail5.cpp	(original)
+++ trunk/libs/tti/test/test_has_type_ct_fail5.cpp	2012-11-28 00:20:19 EST (Wed, 28 Nov 2012)
@@ -4,7 +4,7 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#include "test_has_type_ct.hpp"
+#include "test_has_type.hpp"
 #include <boost/mpl/assert.hpp>
 
 int main()