blob: f6ebd253ddcb3faca5766393c689159c7a2e89e7 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// (C) Copyright Tobias Schwinger
3//
4// Use modification and distribution are subject to the boost Software License,
5// Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
6
7//------------------------------------------------------------------------------
8
Jeff Thompson3d613fd2013-10-15 15:39:04 -07009#ifndef NDNBOOST_FT_DETAIL_CLASSIFIER_HPP_INCLUDED
10#define NDNBOOST_FT_DETAIL_CLASSIFIER_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070011
12#include <ndnboost/type.hpp>
13#include <ndnboost/config.hpp>
14#include <ndnboost/type_traits/config.hpp>
15#include <ndnboost/type_traits/is_reference.hpp>
16#include <ndnboost/type_traits/add_reference.hpp>
17
18#include <ndnboost/function_types/config/config.hpp>
19#include <ndnboost/function_types/property_tags.hpp>
20
21namespace ndnboost { namespace function_types { namespace detail {
22
23template<typename T> struct classifier;
24
25template<std::size_t S> struct char_array { typedef char (&type)[S]; };
26
27template<bits_t Flags, bits_t CCID, std::size_t Arity> struct encode_charr
28{
29 typedef typename char_array<
30 ::ndnboost::function_types::detail::encode_charr_impl<Flags,CCID,Arity>::value
31 >::type type;
32};
33
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034char NDNBOOST_TT_DECL classifier_impl(...);
Jeff Thompsona28eed82013-08-22 16:21:10 -070035
Jeff Thompson3d613fd2013-10-15 15:39:04 -070036#define NDNBOOST_FT_variations NDNBOOST_FT_function|NDNBOOST_FT_pointer|\
37 NDNBOOST_FT_member_pointer
Jeff Thompsona28eed82013-08-22 16:21:10 -070038
Jeff Thompson3d613fd2013-10-15 15:39:04 -070039#define NDNBOOST_FT_type_function(cc,name) NDNBOOST_FT_SYNTAX( \
40 R NDNBOOST_PP_EMPTY,NDNBOOST_PP_LPAREN,cc,* NDNBOOST_PP_EMPTY,name,NDNBOOST_PP_RPAREN)
Jeff Thompsona28eed82013-08-22 16:21:10 -070041
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042#define NDNBOOST_FT_type_function_pointer(cc,name) NDNBOOST_FT_SYNTAX( \
43 R NDNBOOST_PP_EMPTY,NDNBOOST_PP_LPAREN,cc,** NDNBOOST_PP_EMPTY,name,NDNBOOST_PP_RPAREN)
Jeff Thompsona28eed82013-08-22 16:21:10 -070044
Jeff Thompson3d613fd2013-10-15 15:39:04 -070045#define NDNBOOST_FT_type_member_function_pointer(cc,name) NDNBOOST_FT_SYNTAX( \
46 R NDNBOOST_PP_EMPTY,NDNBOOST_PP_LPAREN,cc,T0::** NDNBOOST_PP_EMPTY,name,NDNBOOST_PP_RPAREN)
Jeff Thompsona28eed82013-08-22 16:21:10 -070047
Jeff Thompson3d613fd2013-10-15 15:39:04 -070048#define NDNBOOST_FT_al_path ndnboost/function_types/detail/classifier_impl
Jeff Thompsona28eed82013-08-22 16:21:10 -070049#include <ndnboost/function_types/detail/pp_loop.hpp>
50
51template<typename T> struct classifier_bits
52{
53 static typename ndnboost::add_reference<T>::type tester;
54
Jeff Thompson3d613fd2013-10-15 15:39:04 -070055 NDNBOOST_STATIC_CONSTANT(bits_t,value = (bits_t)sizeof(
Jeff Thompsona28eed82013-08-22 16:21:10 -070056 ndnboost::function_types::detail::classifier_impl(& tester)
57 )-1);
58};
59
60template<typename T> struct classifier
61{
62 typedef detail::constant<
63 ::ndnboost::function_types::detail::decode_bits<
64 ::ndnboost::function_types::detail::classifier_bits<T>::value
65 >::tag_bits >
66 bits;
67
68 typedef detail::full_mask mask;
69
70 typedef detail::constant<
71 ::ndnboost::function_types::detail::decode_bits<
72 ::ndnboost::function_types::detail::classifier_bits<T>::value
73 >::arity >
74 function_arity;
75};
76
77
78
79} } } // namespace ::ndnboost::function_types::detail
80
81#endif
82