OKlibrary  0.2.1.6
ConceptsMetafunctions_Tests.hpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 25.5.2005 (Swansea)
00002 /* Copyright 2005 - 2007 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00008 #ifndef CONCEPTSMETAFUNCTIONSTESTS_719GbWq
00009 #define CONCEPTSMETAFUNCTIONSTESTS_719GbWq
00010 
00011 #include <OKlib/Concepts/ConceptsBase.hpp>
00012 
00013 #include <boost/static_assert.hpp>
00014 #include <boost/type_traits.hpp>
00015 
00016 namespace OKlib {
00017 
00018   namespace Concepts {
00019 
00020     template <template <class T> class ConceptTag>
00021     class Test_ConceptTag_T {
00022       struct c {};
00023       struct test {
00024         typedef c concept_tag;
00025       };
00026       BOOST_STATIC_ASSERT((::boost::is_same<c, typename ConceptTag<test>::type>::value));
00027     };
00028 
00029     // --------------------------------------------------------------------------------------------------------------------------
00030 
00031     template <template <class T, class concept_tag> class IsTagModel>
00032     class Test_IsTagModel_T_concept_tag {
00033       struct basis {};
00034       struct test1 {
00035         typedef basis concept_tag;
00036       };
00037       struct derived : basis {};
00038       struct test2 {
00039         typedef derived concept_tag;
00040       };
00041       BOOST_STATIC_ASSERT((IsTagModel<test1, basis>::value));
00042       BOOST_STATIC_ASSERT((IsTagModel<test2, basis>::value));
00043       BOOST_STATIC_ASSERT((IsTagModel<test2, derived>::value));
00044       BOOST_STATIC_ASSERT(not (IsTagModel<test1, derived>::value));
00045     };
00046 
00047     // --------------------------------------------------------------------------------------------------------------------------
00048 
00049     template <template <class Tag> class IsConceptTag>
00050     class Test_IsConceptTag_Tag {
00051       struct t1 {};
00052       struct t2 : virtual ::OKlib::Concepts::ConceptsBase_tag {};
00053       BOOST_STATIC_ASSERT(not IsConceptTag<t1>::value);
00054       BOOST_STATIC_ASSERT(not IsConceptTag< ::OKlib::Concepts::ConceptsBase_tag >::value);
00055       BOOST_STATIC_ASSERT(IsConceptTag<t2>::value);
00056     };
00057 
00058     // --------------------------------------------------------------------------------------------------------------------------
00059 
00060 
00061     template <template <class T> class HasConceptTag>
00062     class Test_HasConceptTag_T {
00063       struct c1 {};
00064       struct c2 : virtual ::OKlib::Concepts::ConceptsBase_tag {};
00065       struct test1 {
00066         typedef c1 concept_tag;
00067       };
00068       struct test2 {
00069         typedef c2 concept_tag;
00070       };
00071       struct test3 {
00072         typedef ::OKlib::Concepts::ConceptsBase_tag concept_tag;
00073       };
00074       BOOST_STATIC_ASSERT(not HasConceptTag<c1>::value);
00075       BOOST_STATIC_ASSERT(not HasConceptTag<c2>::value);
00076       BOOST_STATIC_ASSERT(HasConceptTag<test2>::value);
00077       BOOST_STATIC_ASSERT(not HasConceptTag<test1>::value);
00078       BOOST_STATIC_ASSERT(not HasConceptTag<test3>::value);
00079     };
00080 
00081   }
00082 
00083 }
00084 
00085 #endif