blob: ab8102a7619accc2a41c15ce7f31be0e43031808 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// Copyright David Abrahams 2006. Distributed under the Boost
2// Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Jeff Thompson2491bd62013-10-15 17:10:24 -07004#ifndef NDNBOOST_CONCEPT_DETAIL_CONCEPT_DEF_NDNBOOST_DWA200651_HPP
5# define NDNBOOST_CONCEPT_DETAIL_CONCEPT_DEF_NDNBOOST_DWA200651_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07006# include <ndnboost/preprocessor/seq/for_each_i.hpp>
7# include <ndnboost/preprocessor/seq/enum.hpp>
8# include <ndnboost/preprocessor/comma_if.hpp>
9# include <ndnboost/preprocessor/cat.hpp>
Jeff Thompson2491bd62013-10-15 17:10:24 -070010#endif // NDNBOOST_CONCEPT_DETAIL_CONCEPT_DEF_NDNBOOST_DWA200651_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070011
Jeff Thompson3d613fd2013-10-15 15:39:04 -070012// NDNBOOST_concept(SomeName, (p1)(p2)...(pN))
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070013//
14// Expands to "template <class p1, class p2, ...class pN> struct SomeName"
15//
16// Also defines an equivalent SomeNameConcept for backward compatibility.
17// Maybe in the next release we can kill off the "Concept" suffix for good.
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018#if NDNBOOST_WORKAROUND(__GNUC__, <= 3)
19# define NDNBOOST_concept(name, params) \
20 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070021 struct name; /* forward declaration */ \
22 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070023 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
24 struct NDNBOOST_PP_CAT(name,Concept) \
25 : name< NDNBOOST_PP_SEQ_ENUM(params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070026 { \
27 /* at least 2.96 and 3.4.3 both need this */ \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070028 NDNBOOST_PP_CAT(name,Concept)(); \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070029 }; \
30 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070031 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070032 struct name
33#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034# define NDNBOOST_concept(name, params) \
35 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070036 struct name; /* forward declaration */ \
37 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
39 struct NDNBOOST_PP_CAT(name,Concept) \
40 : name< NDNBOOST_PP_SEQ_ENUM(params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070041 { \
42 }; \
43 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044 template < NDNBOOST_PP_SEQ_FOR_EACH_I(NDNBOOST_CONCEPT_typename,~,params) > \
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070045 struct name
46#endif
47
Jeff Thompson3d613fd2013-10-15 15:39:04 -070048// Helper for NDNBOOST_concept, above.
49# define NDNBOOST_CONCEPT_typename(r, ignored, index, t) \
50 NDNBOOST_PP_COMMA_IF(index) typename t
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070051