OKlibrary  0.2.1.6
LibraryBasics.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 
00022 #ifndef LIBRARYBASICS_oLkG5675
00023 #define LIBRARYBASICS_oLkG5675
00024 
00025 #include <tr1/type_traits>
00026 
00027 #include <boost/concept_check.hpp>
00028 #include <boost/static_assert.hpp>
00029 #include <boost/type_traits.hpp>
00030 // This file is guaranteed to include the last four files, so that OKLIB_HAS_CONCEPT_TAG and OKLIB_MODELS_CONCEPT always works.
00031 
00032 #include <OKlib/Concepts/ConceptsBase.hpp>
00033 #include <OKlib/Concepts/ConceptsMetafunctions.hpp>
00034 #include <OKlib/Concepts/Basics.hpp>
00035 // This file is guaranteed to include the last three files.
00036 
00037 namespace OKlib {
00038   namespace Concepts {
00039 
00045     template <typename T>
00046     struct WithConceptTag {
00047       BOOST_STATIC_ASSERT(HasConceptTag<T>::value);
00048       void constraints() {}
00049     };
00050     struct WithConceptTag_tag : virtual ConceptsBase_tag {};
00051 
00052     class WithConceptTag_Archetype {
00053       WithConceptTag_Archetype();
00054       WithConceptTag_Archetype(const WithConceptTag_Archetype&);
00055       WithConceptTag_Archetype& operator=(const WithConceptTag_Archetype&);
00056       ~WithConceptTag_Archetype();
00057       struct concept_tag_ : virtual ConceptsBase_tag {};
00058     public :
00059       typedef concept_tag_ concept_tag;
00060     };
00061 
00067     template <typename T>
00068     struct BasicRequirements {
00069       void constraints() {
00070         ::boost::function_requires<WithConceptTag<T> >();
00071         ::boost::function_requires<ConstCorrect<T> >();
00072       }
00073     };
00074     struct BasicRequirements_tag : virtual WithConceptTag_tag, virtual ConstCorrect_tag {};
00075 
00076     class BasicRequirements_Archetype : public WithConceptTag_Archetype {};
00077 
00078     // -------------------------------------------------------------------------------------------------------------------------------
00079 
00088 #define OKLIB_MODELS_CONCEPT_REQUIRES(C, concept) ::boost::function_requires<concept<C> >();
00089 
00098 #define OKLIB_MODELS_CONCEPT_TAG(C, concept) BOOST_STATIC_ASSERT((::OKlib::Concepts::IsTagModel< C, concept ## _tag >::value));
00099 
00109 #define OKLIB_MODELS_CONCEPT_TAG_T(Tag, concept) BOOST_STATIC_ASSERT((std::tr1::is_base_of<concept ## _tag, Tag>::value));
00110 
00111     // ----------------------------------------------------------------------------------------------------------------------------------
00112     // Types for archetype definitions
00113     // ----------------------------------------------------------------------------------------------------------------------------------
00114 
00124     struct convertible_to_bool {
00125       operator bool() { return bool(); }
00126     };
00127 
00128   }
00129 
00130 }
00131 
00132 #endif