Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67645 - in sandbox/tti/libs/tti: doc test
From: eldiener_at_[hidden]
Date: 2011-01-03 21:04:01


Author: eldiener
Date: 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
New Revision: 67645
URL: http://svn.boost.org/trac/boost/changeset/67645

Log:
Testing of mf_has_template metafunction
Added:
   sandbox/tti/libs/tti/test/TestMFHasTemplate.cpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplate.hpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplateCompile.cpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplateFail.cpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplateFail2.cpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplateFail3.cpp (contents, props changed)
   sandbox/tti/libs/tti/test/TestMFHasTemplateFail4.cpp (contents, props changed)
Text files modified:
   sandbox/tti/libs/tti/doc/TTIFunctionality.qbk | 20 ++++++++++----------
   sandbox/tti/libs/tti/test/Jamfile.v2 | 6 ++++++
   2 files changed, 16 insertions(+), 10 deletions(-)

Modified: sandbox/tti/libs/tti/doc/TTIFunctionality.qbk
==============================================================================
--- sandbox/tti/libs/tti/doc/TTIFunctionality.qbk (original)
+++ sandbox/tti/libs/tti/doc/TTIFunctionality.qbk 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -3,14 +3,14 @@
 The elements which a template metaprogrammer might be interested in finding
 out about at compile time about a type 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 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 ?
-# Does it have a member data with a particular name and of a particular type ?
-# Does it have a static member function with a particular name and a particular signature ?
-# Does it have a static member data with a particular name and of a particular type ?
+* 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 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 ?
+* Does it have a member data with a particular name and of a particular type ?
+* Does it have a static member function with a particular name and a particular signature ?
+* 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.
 
@@ -22,7 +22,7 @@
 to the macro as a macro parameter, but other macro parameters may also be needed in some cases.
 
 All of the macros start with the prefix TTI_, create their metafunctions in a top-level
-namespace called 'tti, and come in two forms:
+namespace called 'tti', and come in two forms:
 
 # In the simplest form the 'name' of the inner element is used directly to generate the name
   of the metafunction as well as serving as the 'name' to introspect. The 'name' is appended
@@ -47,6 +47,6 @@
   
 Once either of these two macro forms are used for a particular type of inner element, the
 corresponding macro metafunction has the exact same functionality. I refer to these two macros as
-a macro pair.
+a macro pair, and their are denoted in the documentation as 'SIMPLE_FORM ( COMPLEX_FORM )'.
   
 [endsect]

Modified: sandbox/tti/libs/tti/test/Jamfile.v2
==============================================================================
--- sandbox/tti/libs/tti/test/Jamfile.v2 (original)
+++ sandbox/tti/libs/tti/test/Jamfile.v2 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -88,6 +88,12 @@
         [ compile-fail TestMFHasTypeCheckTypedefFail.cpp ]
         [ compile-fail TestMFHasTypeCheckTypedefFail2.cpp ]
         [ compile-fail TestMFHasTypeCheckTypedefFail3.cpp ]
+ [ run TestMFHasTemplate.cpp ]
+ [ compile TestMFHasTemplateCompile.cpp ]
+ [ compile-fail TestMFHasTemplateFail.cpp ]
+ [ compile-fail TestMFHasTemplateFail2.cpp ]
+ [ compile-fail TestMFHasTemplateFail3.cpp ]
+ [ compile-fail TestMFHasTemplateFail4.cpp ]
         [ run TestMFHasTemplateCheckParams.cpp ]
         [ compile TestMFHasTemplateCheckParamsCompile.cpp ]
         [ compile-fail TestMFHasTemplateCheckParamsFail.cpp ]

Added: sandbox/tti/libs/tti/test/TestMFHasTemplate.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplate.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,49 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/detail/lightweight_test.hpp>
+
+int main()
+ {
+
+ BOOST_TEST((tti::mf_has_template
+ <
+ tti::HaveMStr,
+ tti::member_type_AStructType<AType>
+ >
+ ::value
+ ));
+
+ BOOST_TEST((!tti::mf_has_template
+ <
+ tti::has_template_TemplateNotExist,
+ tti::MT_BType<AType>
+ >
+ ::value
+ ));
+
+ BOOST_TEST((tti::mf_has_template
+ <
+ tti::has_template_ATPMemberTemplate,
+ boost::mpl::identity<AType>
+ >
+ ::value
+ ));
+
+ BOOST_TEST((tti::mf_has_template
+ <
+ tti::HaveCL,
+ boost::mpl::identity<AType>
+ >
+ ::value
+ ));
+
+ BOOST_TEST((tti::mf_has_template
+ <
+ tti::has_template_SimpleTMP,
+ boost::mpl::identity<AnotherType>
+ >
+ ::value
+ ));
+
+ return boost::report_errors();
+
+ }

Added: sandbox/tti/libs/tti/test/TestMFHasTemplate.hpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplate.hpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,18 @@
+#if !defined(TEST_MF_HAS_TEMPLATE_HPP)
+#define TEST_MF_HAS_TEMPLATE_HPP
+
+#include "TestStructs.hpp"
+#include <boost/tti/TTIntrospection.hpp>
+
+TTI_TRAIT_HAS_TEMPLATE(HaveMStr,MStrMemberTemplate)
+TTI_HAS_TEMPLATE(TemplateNotExist)
+TTI_HAS_TEMPLATE(ATPMemberTemplate)
+TTI_TRAIT_HAS_TEMPLATE(HaveCL,CLMemberTemplate)
+TTI_HAS_TEMPLATE(SimpleTMP)
+TTI_TRAIT_HAS_TEMPLATE(AMT,AnotherMemberTemplate)
+TTI_HAS_TEMPLATE(SomeMemberTemplate)
+
+TTI_MEMBER_TYPE(AStructType)
+TTI_TRAIT_MEMBER_TYPE(MT_BType,BType)
+
+#endif // TEST_MF_HAS_TEMPLATE_HPP

Added: sandbox/tti/libs/tti/test/TestMFHasTemplateCompile.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplateCompile.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,53 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/mpl/assert.hpp>
+
+int main()
+ {
+
+ // You can always instantiate without compiler errors
+
+ tti::mf_has_template
+ <
+ tti::has_template_TemplateNotExist,
+ tti::MT_BType<AType>
+ > aVar;
+
+ tti::mf_has_template
+ <
+ tti::has_template_ATPMemberTemplate,
+ boost::mpl::identity<AnotherType>
+ > aVar2;
+
+ // Compile time asserts
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::HaveMStr,
+ tti::member_type_AStructType<AType>
+ >
+ ));
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::has_template_ATPMemberTemplate,
+ boost::mpl::identity<AType>
+ >
+ ));
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::HaveCL,
+ boost::mpl::identity<AType>
+ >
+ ));
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::has_template_SimpleTMP,
+ boost::mpl::identity<AnotherType>
+ >
+ ));
+
+ return 0;
+
+ }

Added: sandbox/tti/libs/tti/test/TestMFHasTemplateFail.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplateFail.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,18 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/mpl/assert.hpp>
+
+int main()
+ {
+
+ // TemplateNotExist does not exist at all
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::has_template_TemplateNotExist,
+ tti::MT_BType<AType>
+ >
+ ));
+
+ return 0;
+
+ }

Added: sandbox/tti/libs/tti/test/TestMFHasTemplateFail2.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplateFail2.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,18 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/mpl/assert.hpp>
+
+int main()
+ {
+
+ // Wrong enclosing type
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::HaveMStr,
+ tti::member_type_AStructType<AnotherType>
+ >
+ ));
+
+ return 0;
+
+ }

Added: sandbox/tti/libs/tti/test/TestMFHasTemplateFail3.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplateFail3.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,18 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/mpl/assert.hpp>
+
+int main()
+ {
+
+ // Too many 'typename' parameters
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::has_template_SomeMemberTemplate,
+ boost::mpl::identity<AnotherType>
+ >
+ ));
+
+ return 0;
+
+ }

Added: sandbox/tti/libs/tti/test/TestMFHasTemplateFail4.cpp
==============================================================================
--- (empty file)
+++ sandbox/tti/libs/tti/test/TestMFHasTemplateFail4.cpp 2011-01-03 21:03:57 EST (Mon, 03 Jan 2011)
@@ -0,0 +1,18 @@
+#include "TestMFHasTemplate.hpp"
+#include <boost/mpl/assert.hpp>
+
+int main()
+ {
+
+ // Not all 'typename' parameters
+
+ BOOST_MPL_ASSERT((tti::mf_has_template
+ <
+ tti::AMT,
+ boost::mpl::identity<AType>
+ >
+ ));
+
+ return 0;
+
+ }


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