|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81038 - trunk/libs/tti/doc
From: eldiener_at_[hidden]
Date: 2012-10-21 10:33:04
Author: eldiener
Date: 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
New Revision: 81038
URL: http://svn.boost.org/trac/boost/changeset/81038
Log:
Updated docs.
Added:
trunk/libs/tti/doc/tti_detail_has_member_data.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_member_function.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_member_function_with_sig.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_static_member_data.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_static_member_function.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_static_member_function_with_sig.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_template.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_template_check_params.qbk (contents, props changed)
trunk/libs/tti/doc/tti_detail_has_type.qbk (contents, props changed)
trunk/libs/tti/doc/tti_nested_type_and_signatures.qbk (contents, props changed)
Text files modified:
trunk/libs/tti/doc/Jamfile.v2 | 40 ++++++------
trunk/libs/tti/doc/tti.qbk | 15 +++-
trunk/libs/tti/doc/tti_func_templates.qbk | 23 +++---
trunk/libs/tti/doc/tti_functionality.qbk | 35 +++++++---
trunk/libs/tti/doc/tti_introduction.qbk | 29 +++-----
trunk/libs/tti/doc/tti_metafunctions.qbk | 6 +
trunk/libs/tti/doc/tti_nested_type.qbk | 128 ++++++++++++++++++++-------------------
trunk/libs/tti/doc/tti_using_mm.qbk | 4
trunk/libs/tti/doc/tti_why.qbk | 2
9 files changed, 151 insertions(+), 131 deletions(-)
Modified: trunk/libs/tti/doc/Jamfile.v2
==============================================================================
--- trunk/libs/tti/doc/Jamfile.v2 (original)
+++ trunk/libs/tti/doc/Jamfile.v2 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -48,26 +48,26 @@
$(here)/../../../boost/tti/has_type.hpp
$(here)/../../../boost/tti/member_type.hpp
$(here)/../../../boost/tti/vm_has_template_check_params.hpp
- $(here)/../../../boost/tti/gen/has_member_data_gen.hpp
- $(here)/../../../boost/tti/gen/has_member_function_gen.hpp
- $(here)/../../../boost/tti/gen/has_member_function_with_sig_gen.hpp
- $(here)/../../../boost/tti/gen/has_static_member_data_gen.hpp
- $(here)/../../../boost/tti/gen/has_static_member_function_gen.hpp
- $(here)/../../../boost/tti/gen/has_static_member_function_with_sig_gen.hpp
- $(here)/../../../boost/tti/gen/has_template_check_params_gen.hpp
- $(here)/../../../boost/tti/gen/has_template_gen.hpp
- $(here)/../../../boost/tti/gen/has_type_gen.hpp
- $(here)/../../../boost/tti/gen/member_type_gen.hpp
- $(here)/../../../boost/tti/gen/namespace_gen.hpp
- $(here)/../../../boost/tti/gen/vm_has_template_check_params_gen.hpp
- $(here)/../../../boost/tti/mf/mf_has_member_data.hpp
- $(here)/../../../boost/tti/mf/mf_has_member_function.hpp
- $(here)/../../../boost/tti/mf/mf_has_static_member_data.hpp
- $(here)/../../../boost/tti/mf/mf_has_static_member_function.hpp
- $(here)/../../../boost/tti/mf/mf_has_template.hpp
- $(here)/../../../boost/tti/mf/mf_has_template_check_params.hpp
- $(here)/../../../boost/tti/mf/mf_has_type.hpp
- $(here)/../../../boost/tti/mf/mf_member_type.hpp
+# $(here)/../../../boost/tti/gen/has_member_data_gen.hpp
+# $(here)/../../../boost/tti/gen/has_member_function_gen.hpp
+# $(here)/../../../boost/tti/gen/has_member_function_with_sig_gen.hpp
+# $(here)/../../../boost/tti/gen/has_static_member_data_gen.hpp
+# $(here)/../../../boost/tti/gen/has_static_member_function_gen.hpp
+# $(here)/../../../boost/tti/gen/has_static_member_function_with_sig_gen.hpp
+# $(here)/../../../boost/tti/gen/has_template_check_params_gen.hpp
+# $(here)/../../../boost/tti/gen/has_template_gen.hpp
+# $(here)/../../../boost/tti/gen/has_type_gen.hpp
+# $(here)/../../../boost/tti/gen/member_type_gen.hpp
+# $(here)/../../../boost/tti/gen/namespace_gen.hpp
+# $(here)/../../../boost/tti/gen/vm_has_template_check_params_gen.hpp
+# $(here)/../../../boost/tti/mf/mf_has_member_data.hpp
+# $(here)/../../../boost/tti/mf/mf_has_member_function.hpp
+# $(here)/../../../boost/tti/mf/mf_has_static_member_data.hpp
+# $(here)/../../../boost/tti/mf/mf_has_static_member_function.hpp
+# $(here)/../../../boost/tti/mf/mf_has_template.hpp
+# $(here)/../../../boost/tti/mf/mf_has_template_check_params.hpp
+# $(here)/../../../boost/tti/mf/mf_has_type.hpp
+# $(here)/../../../boost/tti/mf/mf_member_type.hpp
:
<doxygen:param>PROJECT_NAME="TTI"
<doxygen:param>PROJECT_NUMBER=1
Modified: trunk/libs/tti/doc/tti.qbk
==============================================================================
--- trunk/libs/tti/doc/tti.qbk (original)
+++ trunk/libs/tti/doc/tti.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -7,7 +7,7 @@
[library The Type Traits Introspection Library
[quickbook 1.5]
- [version 1.5]
+ [version 1.6]
[id tti]
[dirname tti]
[copyright 2010-2011 Tropic Software East Inc]
@@ -22,11 +22,18 @@
[include tti_terminology.qbk]
[include tti_functionality.qbk]
[include tti_detail.qbk]
+[include tti_detail_has_type.qbk]
+[include tti_detail_has_template.qbk]
+[include tti_detail_has_template_check_params.qbk]
+[include tti_detail_has_member_data.qbk]
+[include tti_detail_has_member_function.qbk]
+[include tti_detail_has_member_function_with_sig.qbk]
+[include tti_detail_has_static_member_data.qbk]
+[include tti_detail_has_static_member_function.qbk]
+[include tti_detail_has_static_member_function_with_sig.qbk]
[include tti_nested_type.qbk]
+[include tti_nested_type_and_signatures.qbk]
[include tti_using_mm.qbk]
-[include tti_meta_classes.qbk]
-[include tti_metafunctions.qbk]
-[include tti_using_ntm.qbk]
[include tti_func_templates.qbk]
[include tti_tests.qbk]
[include tti_history.qbk]
Added: trunk/libs/tti/doc/tti_detail_has_member_data.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_member_data.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,90 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_member_data Introspecting member data]
+
+The TTI macro [macroref BOOST_TTI_HAS_MEMBER_DATA] introspects
+member data of a class.
+
+BOOST_TTI_HAS_MEMBER_DATA macro takes a single
+parameter which is the name of an inner member data whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_member_data_'name_of_inner_member_data'.
+
+The metafunction can be invoked by passing it the enclosing type
+to introspect and the type of the member data.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+member data, of the specified type, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner member data:
+
+ BOOST_TTI_HAS_MEMBER_DATA(AMemberData)
+
+generates a metafunction called 'has_member_data_AMemberData' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect and the type of the member data. A return value called
+'value' is a compile time bool constant.
+
+ has_member_data_AMemberData<Enclosing_Type,MemberData_Type>::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner member data names:
+
+ #include <boost/tti/has_member_data.hpp>
+
+ BOOST_TTI_HAS_MEMBER_DATA(data1)
+ BOOST_TTI_HAS_MEMBER_DATA(data2)
+ BOOST_TTI_HAS_MEMBER_DATA(data3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass
+ {
+ };
+ struct Top
+ {
+ int data1;
+ AClass * data2;
+ };
+ struct Top2
+ {
+ long data1;
+ Top data3;
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_member_data_data1<Top,int>::value; // true
+ has_member_data_data1<Top,long>::value; // false
+ has_member_data_data1<Top2,int>::value; // false
+ has_member_data_data1<Top2,long>::value; // true
+
+ has_member_data_data2<Top,AClass *>::value; // true
+ has_member_data_data2<Top,int *>::value; // false
+
+ has_member_data_data3<Top2,int>::value; // false
+ has_member_data_data3<Top2,Top>::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner member data by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner member data type, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_member_function.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_member_function.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,100 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_member_function Introspecting member function]
+
+The TTI macro [macroref BOOST_TTI_HAS_MEMBER_FUNCTION] introspects
+a member function of a class.
+
+BOOST_TTI_HAS_MEMBER_FUNCTION takes a single
+parameter which is the name of an inner member function whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_member_function_'name_of_inner_member_function'.
+
+The metafunction can be invoked by passing it the enclosing type to
+introspect and a signature for the member function as separate template
+arguments. The signature for the member function consists of a return
+type, optional parameter types in the form of a boost::mpl forward
+sequence of types, and an optional Boost FunctionTypes tag type. A
+typical boost::mpl forward sequence of types is a boost::mpl::vector<>.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+member function, of the specified signature, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner member function:
+
+ BOOST_TTI_HAS_MEMBER_FUNCTION(AMemberFunction)
+
+generates a metafunction called 'has_member_function_AMemberFunction' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect and the signature of the member function as a series of template
+parameters. A return value called 'value' is a compile time bool constant.
+
+ has_member_function_AMemberFunction
+ <
+ Enclosing_Type,
+ MemberFunction_ReturnType,
+ boost::mpl::vector<MemberFunction_ParameterTypes>, // optional, can be any mpl forward sequence
+ boost::function_types::SomeTagType // optional, can be any FunctionTypes tag type
+ >::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner member function names:
+
+ #include <boost/tti/has_member_function.hpp>
+
+ BOOST_TTI_HAS_MEMBER_FUNCTION(function1)
+ BOOST_TTI_HAS_MEMBER_FUNCTION(function2)
+ BOOST_TTI_HAS_MEMBER_FUNCTION(function3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass
+ {
+ };
+ struct Top
+ {
+ int function1();
+ AClass function2(double,short *);
+ };
+ struct Top2
+ {
+ long function2(Top &,int,bool,short,float);
+ Top * function3(long,int,AClass &);
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_member_function_function1<Top,int>::value; // true
+ has_member_function_function1<Top,int,boost::mpl::vector<> >::value; // true
+ has_member_function_function1<Top2,int>::value; // false
+
+ has_member_function_function2<Top,AClass,boost::mpl::vector<double,short *> >::value; // true
+ has_member_function_function2<Top2,AClass,boost::mpl::vector<double,short *> >::value; // false
+ has_member_function_function2<Top2,long,boost::mpl::vector<Top &,int,bool,short,float> >::value; // true
+
+ has_member_function_function3<Top2,int>::value; // false
+ has_member_function_function3<Top2,Top *,boost::mpl::vector<long,int,AClass &> >::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner member function by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner member function, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_member_function_with_sig.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_member_function_with_sig.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,90 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_member_function_sig Introspecting member function using signature]
+
+The TTI macro [macroref BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG] introspects
+a member function of a class using a member function pointer signature.
+
+BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG macro takes a single
+parameter which is the name of an inner member function whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_member_function_with_sig_'name_of_inner_member_function'.
+
+The metafunction can be invoked by passing it the enclosing type to
+introspect and a signature for the member function as a member function
+pointer.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+member function, of the specified member function pointer signature,
+exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner member function:
+
+ BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG(AMemberFunction)
+
+generates a metafunction called
+'has_member_function_with_sig_AMemberFunction' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with
+an enclosing type to introspect and a type of pointer to member
+function. A return value called 'value' is a compile time bool
+constant.
+
+[heading Examples]
+
+First we generate metafunctions for various inner member function names:
+
+ #include <boost/tti/has_member_function_with_sig.hpp>
+
+ BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG(function1)
+ BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG(function2)
+ BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG(function3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass { };
+ struct Top
+ {
+ int function1();
+ AClass function2(double,short *);
+ };
+ struct Top2
+ {
+ long function2(Top &,int,bool,short,float);
+ Top * function3(long,int,AClass &);
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_member_function_with_sig_function1<int (Top::*)()>::value; // true
+ has_member_function_with_sig_function1<int (Top::*)(void)>::value; // true
+ has_member_function_with_sig_function1<int (Top2::*)()>::value; // false
+
+ has_member_function_with_sig_function2<AClass (Top::*)(double,short *)>::value; // true
+ has_member_function_with_sig_function2<AClass (Top2::*)(double,short *)>::value; // false
+ has_member_function_with_sig_function2<long (Top2::*)(Top &,int,bool,short,float)>::value; // true
+
+ has_member_function_with_sig_function3<int (Top2::*)()>::value; // false
+ has_member_function_with_sig_function3<Top * (Top2::*)(long,int,AClass &)>::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner member function by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner member function, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_static_member_data.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_static_member_data.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,90 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_static_member_data Introspecting static member data]
+
+The TTI macro [macroref BOOST_TTI_HAS_STATIC_MEMBER_DATA] introspects
+static member data of a class.
+
+BOOST_TTI_HAS_STATIC_MEMBER_DATA macro takes a single
+parameter which is the name of an inner static member data whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_static_member_data_'name_of_inner_static_member_data'.
+
+The metafunction can be invoked by passing it the enclosing type
+to introspect and the type of the static member data.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+static member data, of the specified type, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner static member data:
+
+ BOOST_TTI_HAS_STATIC_MEMBER_DATA(AStaticMemberData)
+
+generates a metafunction called 'has_static_member_data_AStaticMemberData' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect and the type of the static member data. A return value called
+'value' is a compile time bool constant.
+
+ has_static_member_data_AStaticMemberData<Enclosing_Type,StaticMemberData_Type>::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner member data names:
+
+ #include <boost/tti/has_static_member_data.hpp>
+
+ BOOST_TTI_HAS_STATIC_MEMBER_DATA(data1)
+ BOOST_TTI_HAS_STATIC_MEMBER_DATA(data2)
+ BOOST_TTI_HAS_STATIC_MEMBER_DATA(data3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass
+ {
+ };
+ struct Top
+ {
+ static int data1;
+ static AClass * data2;
+ };
+ struct Top2
+ {
+ static long data1;
+ static Top data3;
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_static_member_data_data1<Top,int>::value; // true
+ has_static_member_data_data1<Top,long>::value; // false
+ has_static_member_data_data1<Top2,int>::value; // false
+ has_static_member_data_data1<Top2,long>::value; // true
+
+ has_static_member_data_data2<Top,AClass *>::value; // true
+ has_static_member_data_data2<Top,int *>::value; // false
+
+ has_static_member_data_data3<Top2,int>::value; // false
+ has_static_member_data_data3<Top2,Top>::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner static member data by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner static member data type, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_static_member_function.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_static_member_function.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,98 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_static_member_function Introspecting static member function]
+
+The TTI macro [macroref BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION] introspects
+a static member function of a class.
+
+BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION takes a single
+parameter which is the name of an inner static member function whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_static_member_function_'name_of_inner_static_member_function'.
+
+The metafunction can be invoked by passing it the enclosing type to
+introspect and a signature for the static member function as separate template
+arguments. The signature for the static member function consists of a return
+type, optional parameter types in the form of a boost::mpl forward
+sequence of types, and an optional Boost FunctionTypes tag type. A
+typical boost::mpl forward sequence of types is a boost::mpl::vector<>.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+static member function, of the specified signature, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner static member function:
+
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(AStaticMemberFunction)
+
+generates a metafunction called 'has_static_member_function_AStaticMemberFunction' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect and the signature of the static member function as a series of template
+parameters. A return value called 'value' is a compile time bool constant.
+
+ has_static_member_function_AStaticMemberFunction
+ <
+ Enclosing_Type,
+ StaticMemberFunction_ReturnType,
+ boost::mpl::vector<StaticMemberFunction_ParameterTypes>, // optional, can be any mpl forward sequence
+ boost::function_types::SomeTagType // optional, can be any FunctionTypes tag type
+ >::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner static member function names:
+
+ #include <boost/tti/has_static_member_function.hpp>
+
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(function1)
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(function2)
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(function3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass { };
+ struct Top
+ {
+ static int function1();
+ static AClass function2(double,short *);
+ };
+ struct Top2
+ {
+ static long function2(Top &,int,bool,short,float);
+ static Top * function3(long,int,AClass &);
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_static_member_function_function1<Top,int>::value; // true
+ has_static_member_function_function1<Top,int,boost::mpl::vector<> >::value; // true
+ has_static_member_function_function1<Top2,int>::value; // false
+
+ has_static_member_function_function2<Top,AClass,boost::mpl::vector<double,short *> >::value; // true
+ has_static_member_function_function2<Top2,AClass,boost::mpl::vector<double,short *> >::value; // false
+ has_static_member_function_function2<Top2,long,boost::mpl::vector<Top &,int,bool,short,float> >::value; // true
+
+ has_static_member_function_function3<Top2,int>::value; // false
+ has_static_member_function_function3<Top2,Top *,boost::mpl::vector<long,int,AClass &> >::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner static member function by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner static member function, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_static_member_function_with_sig.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_static_member_function_with_sig.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,86 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_static_member_function_sig Introspecting static member function using signature]
+
+The TTI macro [macroref BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG] introspects
+a static member function of a class using a function signature.
+
+BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG macro takes a single
+parameter which is the name of an inner static member function whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_static_member_function_with_sig_'name_of_inner_static_member_function'.
+
+The metafunction can be invoked by passing it the enclosing type to
+introspect and a signature for the static member function as a plain function.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+static member function, of the specified function signature, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner static member function:
+
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG(AStaticMemberFunction)
+
+generates a metafunction called
+'has_static_member_function_with_sig_AStaticMemberFunction' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with
+an enclosing type to introspect and a type as a function signature.
+A return value called 'value' is a compile time bool constant.
+
+[heading Examples]
+
+First we generate metafunctions for various inner member function names:
+
+ #include <boost/tti/has_static_member_function_with_sig.hpp>
+
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG(function1)
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG(function2)
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG(function3)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct AClass { };
+ struct Top
+ {
+ static int function1();
+ static AClass function2(double,short *);
+ };
+ struct Top2
+ {
+ static long function2(Top &,int,bool,short,float);
+ static Top * function3(long,int,AClass &);
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_static_member_function_with_sig_function1<Top,int ()>::value; // true
+ has_static_member_function_with_sig_function1<Top2,int ()>::value; // false
+
+ has_static_member_function_with_sig_function2<Top,AClass (double,short *)>::value; // true
+ has_static_member_function_with_sig_function2<Top2,AClass (double,short *)>::value; // false
+ has_static_member_function_with_sig_function2<Top2,long (Top &,int,bool,short,float)>::value; // true
+
+ has_static_member_function_with_sig_function3<Top2,int ()>::value; // false
+ has_static_member_function_with_sig_function3<Top2,Top * (long,int,AClass &)>::value; // true;
+
+It should be noticed that once we create our metafunction for
+introspecting an inner static member function by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type,
+with any inner static member function, for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_template.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_template.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,95 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_template Introspecting an inner class template]
+
+The TTI macro [macroref BOOST_TTI_HAS_TEMPLATE] introspects
+an inner class template of a class.
+
+BOOST_TTI_HAS_TEMPLATE takes a single
+parameter which is the name of an inner class template whose
+existence the programmer wants to check. The inner class template
+must have all class ( or typename ) template parameters. The macro
+generates a metafunction called 'has_template_'name_of_inner_class_template'.
+
+The metafunction can be invoked by passing it the enclosing type
+to introspect.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction returns the
+value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+class template exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner class template:
+
+ BOOST_TTI_HAS_TEMPLATE(AType)
+
+generates a metafunction called 'has_template_AType' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect. A return value called 'value' is a compile time bool constant.
+
+ has_template_AType<Enclosing_Type>::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner class template names:
+
+ #include <boost/tti/has_template.hpp>
+
+ BOOST_TTI_HAS_TEMPLATE(Template1)
+ BOOST_TTI_HAS_TEMPLATE(Template2)
+ BOOST_TTI_HAS_TEMPLATE(Template3)
+ BOOST_TTI_HAS_TEMPLATE(Template4)
+ BOOST_TTI_HAS_TEMPLATE(Template5)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct Top
+ {
+ template <class X> struct Template1 { };
+ template <typename A,typename B,typename C> class Template2 { };
+ template <typename A,typename B,typename C,int D> class Template3 { };
+ };
+ struct Top2
+ {
+ template <typename A,typename B,typename C,class D> class Template3 { };
+ template <class X,typename Y> struct Template4 { };
+ template <typename A,class B,typename C,class D,typename E> class Template5 { };
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_template_Template1<Top>::value; // true
+ has_template_Template1<Top2>::value; // false
+
+ has_template_Template2<Top>::value; // true
+ has_template_Template2<Top2>::value; // false
+
+ has_template_Template3<Top>::value; // false, not all typename/class tempate parameters
+ has_template_Template3<Top2>::value; // true
+
+ has_template_Template4<Top>::value; // false
+ has_template_Template4<Top2>::value; // true
+
+ has_template_Template5<Top>::value; // false
+ has_template_Template5<Top2>::value; // true
+
+It should be noticed that once we create our metafunction for
+introspecting an inner class template by name, we can reuse the
+metafunction for introspecting any enclosing user-defined type
+for that name.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_template_check_params.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_template_check_params.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,173 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_template_check_params Introspecting an inner class template with specific parameters]
+
+The TTI macro [macroref BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS]
+introspects an inner class template, with specific template
+parameters, of a class.
+
+BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS takes
+two macro parameters. The first is the name of an inner class template
+whose existence the programmer wants to check. The second is a Boost PP
+sequence which specifies the template parameters of the inner class
+template to check. The macro generates a metafunction called
+'has_template_check_params_'name_of_inner_class_template'.
+
+The metafunction can be invoked by passing it the enclosing type to
+introspect.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction returns the
+value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+class template, with the template parameters specified, exists or not.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner class template, as well as its template parameters as
+a Boost PP sequence:
+
+ BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS(AType,(class X)(int Y))
+
+generates a metafunction called 'has_template_check_params_AType' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect. A return value called 'value' is a compile time bool constant.
+
+ has_template_check_params_AType<Enclosing_Type>::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner class template names
+and corresponding template parameters:
+
+ #include <boost/tti/has_template_check_params.hpp>
+
+ BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS(Template1,(class X)(int Y))
+ BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS(Template2,(typename A)(template<class)(class> struct B)(long C))
+ BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS(Template3,(double X)(typename Y))
+ BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS(Template4,(typename A)(class B)(typename C)(class D)(typename E)(short F))
+
+Next let us create some user-defined types we want to introspect.
+
+ struct Top
+ {
+ template <class X,int Y> struct Template1 { };
+ template <typename A,template<class,class> struct B,long C> class Template2 { };
+ };
+ struct Top2
+ {
+ template <double X,typename Y> struct Template3 { };
+ template <typename A,class B,typename C,class D,typename E,short F> class Template4 { };
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_template_check_params_Template1<Top>::value; // true
+ has_template_check_params_Template1<Top2>::value; // false
+
+ has_template_check_params_Template2<Top>::value; // true
+ has_template_check_params_Template2<Top2>::value; // false
+
+ has_template_check_params_Template3<Top>::value; // false
+ has_template_check_params_Template3<Top2>::value; // true
+
+ has_template_check_params_Template4<Top>::value; // false
+ has_template_check_params_Template4<Top2>::value; // true
+
+It should be noticed that once we create our metafunction for
+introspecting an inner class template by name, with its corresponding
+template parameters, we can reuse the metafunction for introspecting
+any enclosing user-defined type for that same inner class template name,
+with its corresponding template parameters.
+
+[heading Alternate form when variadic macros are supported]
+
+An alternate form of the macro, which uses a variadic macro for
+compilers which support them, is called
+[macroref BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS]. In this form
+the first parameter is still the name of an inner class template
+whose existence the programmer wants to check. Subsequent parameters
+are the the template parameters of the inner class template to check,
+each as an individual macro parameter. The macro generates a
+metafunction with the same name as the non-variadic macro form,
+namely 'has_template_check_params_'name_of_inner_class_template'.
+
+In all other respects the metafunction works exactly the same
+as the one that is generated from BOOST_TTI_HAS_TEMPLATE_CHECK_PARAMS.
+
+[heading Generating the metafunction from the variadic macro]
+
+You generate the metafunction by invoking the macro with the name
+of an inner class template, as well as its template parameters as
+a Boost PP sequence:
+
+ BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(AType,class X,int Y)
+
+generates a metafunction called 'has_template_check_params_AType' in the current scope.
+
+[heading Invoking the metafunction created by the variadic macro]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect. A return value called 'value' is a compile time bool constant.
+
+ has_template_check_params_AType<Enclosing_Type>::value
+
+[heading Examples of the variadic macro form]
+
+First we generate metafunctions for various inner class template names
+and corresponding template parameters:
+
+ #include <boost/tti/vm_has_template_check_params.hpp>
+
+ BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(Template1,class X,int Y)
+ BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(Template2,typename A,template<class,class> struct B,long C)
+ BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(Template3,double X,typename Y)
+ BOOST_TTI_VM_HAS_TEMPLATE_CHECK_PARAMS(Template4,typename A,class B,typename C,class D,typename E,short F)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct Top
+ {
+ template <class X,int Y> struct Template1 { };
+ template <typename A,template<class,class> struct B,long C> class Template2 { };
+ };
+ struct Top2
+ {
+ template <double X,typename Y> struct Template3 { };
+ template <typename A,class B,typename C,class D,typename E,short F> class Template4 { };
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_template_check_params_Template1<Top>::value; // true
+ has_template_check_params_Template1<Top2>::value; // false
+
+ has_template_check_params_Template2<Top>::value; // true
+ has_template_check_params_Template2<Top2>::value; // false
+
+ has_template_check_params_Template3<Top>::value; // false
+ has_template_check_params_Template3<Top2>::value; // true
+
+ has_template_check_params_Template4<Top>::value; // false
+ has_template_check_params_Template4<Top2>::value; // true
+
+Just as before it should be noticed that once we create our metafunction for
+introspecting an inner class template by name, with its corresponding
+template parameters, we can reuse the metafunction for introspecting
+any enclosing user-defined type for that name, with its corresponding
+template parameters.
+
+[endsect]
Added: trunk/libs/tti/doc/tti_detail_has_type.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_detail_has_type.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,102 @@
+[/
+ (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).
+]
+
+[section:tti_detail_has_type Introspecting an inner type]
+
+The TTI macro [macroref BOOST_TTI_HAS_TYPE] introspects
+a nested type of a class.
+
+BOOST_TTI_HAS_TYPE takes a single
+parameter which is the name of an inner type whose existence
+the programmer wants to check. The macro generates a metafunction
+called 'has_type_'name_of_inner_type'. The purpose of the macro
+is to check for the existence by name of an inner type and,
+optionally, check whether that inner type is equivalent to
+a particular type. This latter functionality is normally only
+used to check whether or not the inner type is a typedef for
+another type, since an inner user-defined type declares its
+own type by its name.
+
+The metafunction can be invoked by passing it the enclosing type
+to introspect. Optionally a second type can be passed to the
+metafunction, whose purpose is to check that if the inner type
+exists it is of the same type as this second type.
+
+The metafunction returns a single type called 'type', which is a
+boost::mpl::bool_. As a convenience the metafunction
+returns the value of this type directly as a compile time bool constant
+called 'value'. This is true or false depending on whether the inner
+type exists or not and, if a second optional type is passed, whether .
+the second type is the same as the type which exists.
+
+[heading Generating the metafunction]
+
+You generate the metafunction by invoking the macro with the name
+of an inner type:
+
+ BOOST_TTI_HAS_TYPE(AType)
+
+generates a metafunction called 'has_type_AType' in the current scope.
+
+[heading Invoking the metafunction]
+
+You invoke the metafunction by instantiating the template with an enclosing
+type to introspect and, optionally, a type which the inner type must match.
+A return value called 'value' is a compile time bool constant.
+
+ has_type_AType<Enclosing_Type>::value
+ has_type_AType<Enclosing_Type,Another_Type>::value
+
+[heading Examples]
+
+First we generate metafunctions for various inner type names:
+
+ #include <boost/tti/has_type.hpp>
+
+ BOOST_TTI_HAS_TYPE(MyTypeDef)
+ BOOST_TTI_HAS_TYPE(AType)
+ BOOST_TTI_HAS_TYPE(ATypeDef)
+ BOOST_TTI_HAS_TYPE(MyType)
+
+Next let us create some user-defined types we want to introspect.
+
+ struct Top
+ {
+ typedef int MyTypeDef;
+ struct AType { };
+ };
+ struct Top2
+ {
+ typedef long ATypeDef;
+ struct MyType { };
+ };
+
+Finally we invoke our metafunction and return our value.
+This all happens at compile time, and can be used by
+programmers doing compile time template metaprogramming.
+
+ has_type_MyTypeDef<Top>::value; // true
+ has_type_MyTypeDef<Top2>::value; // false
+ has_type_MyTypeDef<Top,int>::value; // true
+ has_type_MyTypeDef<Top,long>::value; // false
+
+ has_type_AType<Top>::value; // true
+ has_type_AType<Top2>::value; // false
+
+ has_type_ATypeDef<Top>::value; // false
+ has_type_ATypeDef<Top2>::value; // true
+ has_type_ATypeDef<Top2,int>::value; // false
+ has_type_ATypeDef<Top2,long>::value; // true
+
+ has_type_MyType<Top>::value; // false
+ has_type_MyType<Top2>::value; // true
+
+It should be noticed that once we create our metafunction for
+introspecting an inner type by name, we can reuse the metafunction
+for introspecting any enclosing user-defined type for that name.
+
+[endsect]
Modified: trunk/libs/tti/doc/tti_func_templates.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_func_templates.qbk (original)
+++ trunk/libs/tti/doc/tti_func_templates.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -34,9 +34,9 @@
My efforts to discuss this on the major C++ newsgroups have
met with arguments both against its practical usage and the justification
that one can pass a function template to another template nested in a non-template
-class. But of course we can do the same thing with class templates, which is in fact
-what Boost MPL does to pass templates as metadata, yet we still have template template
-parameters as class templates.
+class, which serves as a type. But of course we can do the same thing with class templates,
+which is in fact what Boost MPL does to pass templates as metadata, yet we still have
+template template parameters as class templates.
Nonetheless the fact that we can pass class templates as a template parameter but not
function templates as a template parameter is the major factor why there is no really good
@@ -48,11 +48,12 @@
I will endeavor to explain why this way is not currently included in the TTI library,
but first I will explain what it is.
-It is possible to check whether some particular instantiation of a nested function
-template exists at compile-time without generating a compiler error. While this does
-not prove that the nested function template does not exist, since the instantiation itself may be
-incorrect and fail even when the nested function template exists, it provides a partially
-flawed means of checking.
+It is possible to check whether some particular [*instantiation] of a nested function
+template exists at compile-time without generating a compiler error. Although checking if
+some particular instantiation of a nested function template exists at compile-time does
+not prove that the nested function template itself does or does not exist,
+since the instantiation itself may be incorrect and fail even when the nested function
+template exists, it provides a partial, if flawed, means of checking.
The code to do this for member function templates looks like this
( similar code also exists for static member function templates ):
@@ -73,9 +74,9 @@
};
where 'SomeFuncTemplateName' is the name of the nested function template,
-followed by some parameters to instantiate it. The 'class T' is the
-type of the instantiated member function template as a member function, and
-'class C' is the type of the enclosing class.
+followed by some parameters to instantiate it. The 'class C' is the type of
+the enclosing class and the 'class T' is the type of the instantiated member
+function template as a member function.
As an example if we had:
Modified: trunk/libs/tti/doc/tti_functionality.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_functionality.qbk (original)
+++ trunk/libs/tti/doc/tti_functionality.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -7,11 +7,11 @@
[section:tti_functionality General Functionality]
-The elements about which a template metaprogrammer might be interested in finding
-out at compile time about a type are:
+The elements of a type about which a template metaprogrammer might be interested in finding
+out at compile time are:
* Does it have a nested type with a particular name ?
-* Does it have a nested type with a particular name which is a typedef for a particular type ?
+* Does it have a nested type with a particular name which is also a typedef for a particular type ?
* Does it have a nested class template with a particular name ?
* Does it have a nested class template with a particular name and a particular signature ?
* Does it have a member function with a particular name and a particular signature ?
@@ -20,7 +20,17 @@
* Does it have a static member data with a particular name and of a particular type ?
These are the compile-time questions which the TTI library answers. It does this
-by creating metafunctions which can be used at compile-time.
+by creating metafunctions which can be used at compile-time using C++ macros.
+Each of the metafunctions created returns a compile time constant bool value
+which answers one of the above questions at compile time. When the particular
+element above exists the value is 'true', or more precisely boost::mpl::true_,
+while if the element does not exist the value is 'false', or more precisely
+boost::mpl::false_. In either case the type of this value is boost::mpl::bool_.
+
+This constant bool value, in the terminology of the Boost MPL library, is called an 'integral
+constant wrapper' and the metafunction generated is called a 'numerical metafunction'. The
+results from calling the metafunction can be passed to other metafunctions for type selection,
+the most popular of these being the boolean-valued operators in the Boost MPL library.
All of the questions above attempt to find an answer about an inner element with
a particular name. In order to do this using template metaprogramming, macros are used
@@ -51,7 +61,7 @@
corresponding macro metafunction works exactly the same way and has the exact same functionality.
In the succeeding documentation all macro metafunctions will be referred by their simple form
-name, but remember that the complex form can alternatively always be used instead.
+name, but remember that the complex form can always be used instead.
[heading Macro Metafunction Name Generation]
@@ -59,26 +69,29 @@
the generated metafunction is named, TTI also provides, for each macro metafunction,
a corresponding 'naming' macro which the end-user can use and whose sole purpose
is to expand to the metafunction name. The naming macro for each macro metafunction has the form:
-'corresponding-macro'_GEN(name). As an example, BOOST_TTI_HAS_TYPE(MyType) creates a metafunction
+'corresponding-macro'_GEN(name).
+
+As an example, BOOST_TTI_HAS_TYPE(MyType) creates a metafunction
which looks for a nested type called 'MyType' within some enclosing type. The name of the metafunction
generated, given our algorithm above is 'has_type_MyType'. A corresponding macro called
BOOST_TTI_HAS_TYPE_GEN, invoked as BOOST_TTI_HAS_TYPE_GEN(MyType) in our example, expands to the
-same 'has_type_MyType'. These name generating macros, for each of the metafunction generating macros,
+same 'has_type_MyType' name. These name generating macros, for each of the metafunction generating macros,
are purely a convenience for end-users who find using them easier than remembering the name-generating
algorithm given above.
[section:tti_functionality_nm_gen Macro metafunction name generation considerations]
Because having a double underscore ( __ ) in a name is reserved by the C++ implementation,
-creating C++ identifiers with double underscores should not avoided by the end-user. When using
+creating C++ identifiers with double underscores should be avoided by the end-user. When using
a TTI macro to generate a metafunction using the simple macro form, TTI appends a single
underscore to the macro name preceding the name of the element that is being introspected.
The reason for doing this is because Boost discourages as non=portable C++ identifiers with mixed
case letters and the underscore then becomes the normal way to separate parts of an identifier
name so that it looks understandable. Because of this decision to use the underscore to generate
the metafunction name from the macro name, any inner element starting with an underscore will cause
-the identifier for the metafunction name being generated to contain a double underscore. A rule
-to avoid this problem is:
+the identifier for the metafunction name being generated to contain a double underscore.
+
+A rule to avoid this problem is:
* When the name of the inner element to be introspected begins with an underscore, use
the complex macro form, where the name of the metafunction is specifically given.
@@ -177,7 +190,7 @@
macro form, do not create any C++ construct with an identifier starting with 'MyMetaFunction',
such as 'MyMetaFunction_Enumeration' or 'MyMetaFunctionHelper' in the same scope.
All names starting wih the metafunction name in the current scope should be considered
-out of bounds for the programmer using TTI to use.
+out of bounds for the programmer using TTI.
[endsect]
Modified: trunk/libs/tti/doc/tti_introduction.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_introduction.qbk (original)
+++ trunk/libs/tti/doc/tti_introduction.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -7,23 +7,23 @@
[section:tti_intro Introduction]
-Welcome to the Type Traits Introspection library version 1.5.
+Welcome to the Boost Type Traits Introspection library, abbreviated TTI.
-The Type Traits Introspection library, or TTI for short, is a library
-of macros generating metafunctions, and a set of parallel nullary type
-metafunctions, which provide the ability to introspect by name the
-elements of a type at compile time.
+TTI is a library of macros generating metafunctions which provide the
+ability to introspect by name the elements of a type at compile time.
The name of the library is chosen because the library offers
compile time functionality on a type, similar to the Boost Type Traits library,
and because the functionality the library offers is the ability to introspect
-a type about the existence of a specific element.
+a type about the existence of a specific element within that type.
I use the word "introspect" in a very broad sense here. Normally language
introspection means initially asking for information to be returned by name,
which can then further be used to introspect for more specific information.
In the TTI library one must always supply the name, and use the functionality
-for the correct type of inner element to find out if the particular named entity exists.
+provided for the correct type of inner element to find out if that particular
+named entity exists.
+
You may prefer the term "query" instead of "introspection" to denote what this
library does, but I use terminology based on the word "introspect" throughout
this documentation.
@@ -36,20 +36,13 @@
subsequently invoked to determine whether or not the
element exists within the type. These generated metafunctions
will be called "macro metafunctions" in the documentation.
-* Provide a set of named metafunctions which can operate
- on the generated macro metafunctions using a different syntax
- which some programmers may find easier to use. These named
- metafunctions will be called "nullary type metafunctions"
- in the documentation. This set of nullary type metafunctions
- can be completely ignored by programmers who do not find
- their syntax useful since they have the exact
- same functionality as the macro metafunctions above.
The library is dependent on Boost PP, Boost MPL,
Boost Type Traits, and Boost Function Types.
+
The library is also dependent on the variadic macro support
-of the Boost PP library currently in the sandbox
-if the variadic macros in the library are used.
+of the Boost PP library if the variadic macros in the library
+are used.
The library is a header only library.
@@ -80,7 +73,7 @@
or the specific header file
[headerref boost/tti/vm_has_template_check_params.hpp `vm_has_template_check_params.hpp`],
are used, the library uses variadic macros and is also dependent
-on the variadic macro support of the Boost PP library currently in the Boost trunk.
+on the variadic macro support of the Boost PP library.
[endsect]
Modified: trunk/libs/tti/doc/tti_metafunctions.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_metafunctions.qbk (original)
+++ trunk/libs/tti/doc/tti_metafunctions.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -8,7 +8,9 @@
[section:tti_metafunctions Nullary Type Metafunctions]
The macro metafunctions provide a complete set of functionality for
-anything one would like to do using the TTI library.
+anything one would like to do using the TTI library. Invoking the
+metafunctions allows the template metaprogrammer to discover whether
+a C++ type has inner elements of a particular name.
What is presented here is a set of named metafunctions,
in the boost::tti namespace, which offer
@@ -59,7 +61,7 @@
a known non-class type as is than having to wrap it with boost::mpl::identity.
For nested types, which may or may not exist, we can pass the resulting nullary
-metafunction generated by `BOOST_TTI_MEMBER_TYPE`, raher than its nested ::type, or its equivalent
+metafunction generated by `BOOST_TTI_MEMBER_TYPE`, rather than its nested ::type, or its equivalent
nullary type metafunction `boost::tti::mf_member_type` ( explained later ).
To use these metafunctions you need to include the main header file `boost/tti/tti.hpp`,
Modified: trunk/libs/tti/doc/tti_nested_type.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_nested_type.qbk (original)
+++ trunk/libs/tti/doc/tti_nested_type.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -9,7 +9,7 @@
[heading The problem]
-The goal of the TTI library is never to produce a compiler error by just
+One of the goals of the TTI library is never to produce a compiler error by just
using the functionality in the library, whether it is invoking its function-like macros
or instantiating the macro metafunctions created by them, and whether the inner element exists
or not. In this sense The TTI library macros for introspecting an enclosing type for
@@ -18,41 +18,46 @@
The metafunctions generated by the TTI macros all work with types, whether in specifying
an enclosing type or in specifying the type of some inner element, which may also involve
-types in the signature of that element, such as a parameter or return type of a function. The C++ notation for
-a nested type, given an enclosing type 'T' and an inner type 'InnerType', is 'T::InnerType'. If either
-the enclosing type 'T' does not exist, or the inner type 'InnerType' does not exist within 'T',
-the expression 'T::InnerType' will give a compiler error if we attempt to use it in our template
-instantiation of one of TTI's macro metafunctions.
-
-We want to be able to introspect for the existence of inner elements to an enclosing type
-without producing compiler errors. Of course if we absolutely know what types we have and
-that a nested type exists, and these declarations are within our scope, we can always use
-an expression like T::InnerType without error. But this is often not the case when doing template
-programming since the type being passed to us at compile-time in a class or function template
-is chosen at instantiation time and is created by the user of a template.
+types in the signature of that element, such as a parameter or return type of a function.
+The C++ notation for a nested type, given an enclosing type 'T' and an inner type 'InnerType',
+is 'T::InnerType'. If either the enclosing type 'T' does not exist, or the inner type 'InnerType'
+does not exist within 'T', the expression 'T::InnerType' will give a compiler error if we attempt
+to use it in our template instantiation of one of TTI's macro metafunctions.
+
+This is a problem if we want to be able to introspect for the existence of inner elements
+to an enclosing type without producing compiler errors. Of course if we absolutely know what
+types we have and that a nested type exists, and these declarations are within our scope, we can
+always use an expression like 'T::InnerType' without compiler error. But this is often not the
+case when doing template programming since the type being passed to us at compile-time in a class
+or function template is chosen at instantiation time and is created by the user of a template.
One solution to this is afforded by the library itself. Given an enclosing type 'T'
which we know must exist, either because it is a top-level type we know about or
it is passed to us in some template as a 'class T' or 'typename T', and given an inner type
-named 'InnerType' whose existence we would like ascertain, we can use a `BOOST_TTI_HAS_TYPE(InnerType)` macro and it's related
-`has_type_InnerType` metafunction to determine if the nested type 'InnerType' exists. This solution is perfectly valid
-and, with Boost MPL's selection metafunctions, we can do compile-time selection to generate the
-correct template code.
+named 'InnerType' whose existence we would like ascertain, we can use a `BOOST_TTI_HAS_TYPE(InnerType)`
+macro and it's related `has_type_InnerType` metafunction to determine if the nested type 'InnerType'
+exists. This solution is perfectly valid, and in conjunction with Boost MPL's selection metafunctions,
+we can do compile-time selection to generate the correct template code.
-However this does not ordinarily scale that well syntactically if we need to drill down further
+However this does not scale that well syntactically if we need to drill down further
from a top-level enclosing type to a deeply nested type, or even to look for some deeply nested
type's inner elements. We are going to be generating a great deal of `boost::mpl::if_` and/or
`boost::mpl::eval_if` type selection statements to get to some final condition where we know we
can generate the compile-time code which we want.
-[heading One solution]
+[heading The solution]
The TTI library offers a solution in the form of a construct which works with a
-nested type without producing a compiler error if the nested type does not exist, but still
-is able to do the introspecting for inner elements that our TTI macro metafunctions do.
+nested type without producing a compiler error if the nested type does not exist, while still
+allowing us to introspect inner elements using such a potentially non-existing nested type.
-This is a metafunction created by the macro [macroref BOOST_TTI_MEMBER_TYPE]. Its general
-explanation is given as:
+This is a metafunction created by the macro [macroref BOOST_TTI_MEMBER_TYPE]. The macro takes
+a single parameter, which is the name of a type. We will call this our 'named type'.
+The macro generates a metafunction called `member_type_'named_type'` which, passed an enclosing type,
+returns the named type if it exists, else an unspecified marker type internal to the TTI library
+if it does not.
+
+Its general explanation is given as:
[table:tbmacronested TTI Nested Type Macro Metafunction
[
@@ -77,14 +82,25 @@
]
]
-Instead of telling us whether an inner type of a particular name exists,
-as the metafunction generated by BOOST_TTI_HAS_TYPE does,
-the BOOST_TTI_MEMBER_TYPE macro generates a metafunction which,
-passed an enclosing type as its single template parameter, returns
-a typedef 'type' which is that inner type if it exists, else it is an unspecified marker 'type' if it
-does not. In this way we have created a metafunction, very similar in functionality to
-boost::mpl::identity, but which still returns some unspecified marker 'type' if our nested type
-is invalid.
+A simple example:
+
+ #include <boost/tti/member_type.hpp>
+
+ BOOST_TTI_MEMBER_TYPE(ANamedType)
+
+ typedef typename member_type_ANamedType<EnclosingType>::type AType;
+
+If type 'ANamedType' is a nested type of 'EnclosingType' then
+AType is the same type as 'ANamedType', otherwise AType is a
+type internal to the TTI library. In either case AType could
+further be used as a type in template programming, even if
+'EnclosingType::ANamedType' did not exist.
+
+If, on the other hand, we had to specify Atype as 'EnclosingType::ANamedType'
+in template programming, this would lead to a compiler error if this type
+did not exist at the point of instantiation.
+
+[heading A nested type example]
We can use the functionality of `BOOST_TTI_MEMBER_TYPE` to construct nested types
for our other macro metafunctions, without having to use the T::InnerType syntax and produce a compiler
@@ -119,7 +135,9 @@
BOOST_TTI_MEMBER_TYPE(CType)
Next we can create a typedef to reflect a nested type called FindType which has the relationship
-as specified above by instantiating our macro metafunctions.
+as specified above by instantiating our macro metafunctions. We have to do this in the reverse
+order of our hypothetical 'struct T' above since the metafunction `BOOST_TTI_MEMBER_TYPE` takes
+its enclosing type as its template parameter.
typedef typename
member_type_FindType
@@ -138,10 +156,11 @@
We can use the above typedef to pass the type as FindType
to one of our macro metafunctions. FindType may not actually exist but we will not generate
-a compiler error when we use it, but will only generate, if it does not exist, a failure by having our meteafunction
-return a false value at compile-time.
+a compiler error when we use it. It will only generate, if it does not exist, an eventual
+failure by having whatever metafunction uses such a type return a false value at compile-time.
-As one example, let's ask whether FindType has a static member data called MyData of type 'int'. We add:
+As one example, let's ask whether FindType has a static member data called MyData of type 'int'.
+We add:
BOOST_TTI_HAS_STATIC_MEMBER_DATA(MyData)
@@ -172,8 +191,10 @@
FindType does not exist or if it does exist but does not have a static member data
of type 'int' called 'MyData'. In neither situation will we produce a compiler error.
-Somewhere else we may also be interested in ascertaining whether the deeply nested type 'FindType'
-actually exists. Our metafunction, using BOOST_TTI_MEMBER_TYPE
+[heading Existence of nested type]
+
+In some situations we may also be interested in ascertaining whether the deeply nested
+type 'FindType' actually exists. Our metafunction, using BOOST_TTI_MEMBER_TYPE
and repeating our macros from above, would be:
BOOST_TTI_MEMBER_TYPE(FindType)
@@ -201,15 +222,19 @@
>
But this duplicates much of our code when we generated the 'MyFindType' typedef, so
-it would be much better if we could simply pass our
+it would be much better if we could simply pass our originally typedefed
'MyFindType' type to some other metafunction which would tell us directly if 'MyFindType'
-actually exists. And so we can ! The TTI library has a named metafunction
-called 'boost::tti::valid_member_type' which takes a type and determines
+actually exists.
+
+And so we can !
+
+The TTI library has a specifically named metafunction,
+called 'boost::tti::valid_member_type', which takes a type and determines
if it 'actually exists', returning the compile-time boolean constant called 'value'
of 'true' if it does or 'false' if it does not. The meaning of 'actually exists',
as far as 'boost::tti::valid_member_type' is concerned, is that the type does not
equal the unspecified type which BOOST_TTI_MEMBER_TYPE returns when its nested type
-does not exist, and therefore 'boost::tti::valid_member_type' is meant to be used
+does not exist. Therefore 'boost::tti::valid_member_type' is meant to be used
with the return 'type' of BOOST_TTI_MEMBER_TYPE, which is what 'MyFindType' represents.
The general explanation of 'boost::tti::valid_member_type' is given as:
@@ -249,25 +274,4 @@
directly instead of replicating the same functionality with our 'boost::tti::has_type_FindType'
metafunction.
-[section:tti_func_sig Nested Types and Function Signatures]
-
-The strength of `BOOST_TTI_MEMBER_TYPE` to represent a type which may or may not exist, and which
-then can be subsequently used in other macro metafunctions whenever a type is needed as a template
-parameter, without producing a compiler error, should not be underestimated. It is one of the
-reasons why we have two different versions of metafunctions for introspecting a member function or
-static member function of a type.
-
-In the more general case, when using `BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG` and
-`BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG`, the signature for the member function and
-the static member function is a composite type. This makes for a syntactical notation
-which is natural to specify, but because of that composite type notation we
-can not use the nested type functionality in `BOOST_TTI_MEMBER_TYPE` very easily.
-
-But in the more specific case,
-when we use `BOOST_TTI_HAS_MEMBER_FUNCTION` and `BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION`,
-the composite types in our signatures are broken down into their individual types so that using
-`BOOST_TTI_MEMBER_TYPE`, if necessary, for any one of the individual types is easy and natural.
-
-[endsect]
-
[endsect]
Added: trunk/libs/tti/doc/tti_nested_type_and_signatures.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/tti/doc/tti_nested_type_and_signatures.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -0,0 +1,93 @@
+[/
+ (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).
+]
+
+[section:tti_func_sig Nested Types and Function Signatures]
+
+The strength of `BOOST_TTI_MEMBER_TYPE` to represent a type which may or may not exist, and which
+then can be subsequently used in other macro metafunctions whenever a type is needed as a template
+parameter, without producing a compiler error, should not be underestimated. It is one of the
+reasons why we have two different versions of metafunctions for introspecting a member function or
+static member function of a type.
+
+In the more general case, when using `BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG` and
+`BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG`, the signature for the member function and
+the static member function is a single composite type. This makes for a syntactical notation
+which is natural to specify, but because of the composite type notation we
+can not use the nested type functionality in `BOOST_TTI_MEMBER_TYPE` for potential parts
+of that composite type. If any part of this signature, which specifies a composite of various
+types, is invalid, a compiler time error will occur.
+
+But in the more specific case, when we use `BOOST_TTI_HAS_MEMBER_FUNCTION` and
+`BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION`, the composite types in our signatures are broken down
+into their individual types so that using `BOOST_TTI_MEMBER_TYPE`, if necessary, for any one
+of the individual types will not lead to a compile time error if the type specified does not
+actually exist.
+
+A few examples will suffice.
+
+Given known types T and U, and the supposed type Ntype as a
+nested type of U, we want to find out if type T has a member function whose signature is
+`void aMemberFunction(U::Ntype)`.
+
+First using `BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG` we would code:
+
+ #include <boost/tti/has_member_function_with_sig.hpp>
+
+ BOOST_TTI_HAS_MEMBER_FUNCTION_WITH_SIG(aMemberFunction)
+
+ has_member_function_with_sig_aMemberFunction<void (T::*)(U::Ntype)>::value;
+
+If the nested type U::Ntype does not exist, this leads to a compiler error.
+We really want to avoid this situation, so let's try our alternative.
+
+Second using `BOOST_TTI_HAS_MEMBER_FUNCTION` we would code:
+
+ #include <boost/tti/member_type.hpp>
+ #include <boost/tti/has_member_function.hpp>
+
+ BOOST_TTI_HAS_MEMBER_TYPE(Ntype)
+ BOOST_TTI_HAS_MEMBER_FUNCTION(aMemberFunction)
+
+ typedef typename has_member_type_Ntype<U>::type OurType;
+ has_member_function_aMemberFunction<T,void,boost::mpl::vector<OurType> >::value;
+
+If the nested type U::Ntype does exist and T does have a member function
+whose signature is `void aMemberFunction(U::Ntype)` our 'value' is true,
+otherwise it is false. We will never get a compiler error in this case.
+
+As a second example we will once again use the suppositions of our first
+example; given known types T and U, and the supposed type Ntype as a
+nested type of U. But this time let us look for a static member function
+whose signature is `void aStaticMemberFunction(U::Ntype)`.
+
+First using `BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG` we would code:
+
+ #include <boost/tti/has_static_member_function_with_sig.hpp>
+
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_WITH_SIG(aStaticMemberFunction)
+
+ has_static_member_function_with_sig_aStaticMemberFunction<T,void (U::Ntype)>::value;
+
+Once again if the nested type U::Ntype does not exist, this leads to a compiler error,
+so let's try our alternative.
+
+Second using `BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION` we would code:
+
+ #include <boost/tti/member_type.hpp>
+ #include <boost/tti/has_static_member_function.hpp>
+
+ BOOST_TTI_HAS_MEMBER_TYPE(Ntype)
+ BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(aStaticMemberFunction)
+
+ typedef typename has_member_type_Ntype<U>::type OurType;
+ has_static_member_function_aStaticMemberFunction<T,void,boost::mpl::vector<OurType> >::value;
+
+If the nested type U::Ntype does exist and T does have a member function
+whose signature is `void aMemberFunction(U::Ntype)` our 'value' is true,
+otherwise it is false. We will never get a compiler error in this case.
+
+[endsect]
Modified: trunk/libs/tti/doc/tti_using_mm.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_using_mm.qbk (original)
+++ trunk/libs/tti/doc/tti_using_mm.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -5,14 +5,14 @@
http://www.boost.org/LICENSE_1_0.txt).
]
-[section:tti_usingMM Using the Macro Metafunctions]
+[section:tti_usingMM An example using the Macro Metafunctions]
[#sectti_usingMM]
Using the macro metafunctions can be illustrated by first creating some hypothetical
user-defined type with corresponding nested types and other inner elements.
With this type we can illustrate the use of the macro metafunctions. This is
just meant to serve as a model for what a type T might entail from within
-a class or function template.
+a class or function template where 'T' is a type passed to the template.
// An enclosing type
Modified: trunk/libs/tti/doc/tti_why.qbk
==============================================================================
--- trunk/libs/tti/doc/tti_why.qbk (original)
+++ trunk/libs/tti/doc/tti_why.qbk 2012-10-21 10:33:02 EDT (Sun, 21 Oct 2012)
@@ -25,7 +25,7 @@
to determine whether an enclosing type has a particular nested type or nested
class template. An example with a library which was never submitted to Boost
is the Concept Traits Library from which much of the functionality of this
-library, related to type traits, was taken and improved upon.
+library, related to type traits, was taken and expanded.
It may also be possible that some other Boost libraries, highly dependent
on advanced template metaprogramming techniques, also have internal
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk