blob: 0d3d9dfb23ea473a7ea241c12bc9a609f9be7aec [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// Copyright (C) 2004 Arkadiy Vertleyb
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5#include <ndnboost/typeof/encode_decode_params.hpp>
6
7#define n BOOST_PP_ITERATION()
8
9// function pointers
10
11template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
12struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P))>
13{
14 typedef R BOOST_PP_CAT(P, n);
15 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_PTR_ID + n) type;
16};
17
18template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
19struct encode_type_impl<V, R(*)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
20{
21 typedef R BOOST_PP_CAT(P, n);
22 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type;
23};
24
25template<class Iter>
26struct decode_type_impl<ndnboost::mpl::size_t<FUN_PTR_ID + n>, Iter>
27{
28 typedef Iter iter0;
29 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
30 typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p));
31 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
32};
33
34template<class Iter>
35struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_PTR_ID + n>, Iter>
36{
37 typedef Iter iter0;
38 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
39 typedef BOOST_PP_CAT(p, n)(*type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
40 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
41};
42
43#ifndef BOOST_TYPEOF_NO_FUNCTION_TYPES
44
45 // function references
46
47 template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
48 struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P))>
49 {
50 typedef R BOOST_PP_CAT(P, n);
51 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_REF_ID + n) type;
52 };
53
54 template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
55 struct encode_type_impl<V, R(&)(BOOST_PP_ENUM_PARAMS(n, P) ...)>
56 {
57 typedef R BOOST_PP_CAT(P, n);
58 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_REF_ID + n) type;
59 };
60
61 template<class Iter>
62 struct decode_type_impl<ndnboost::mpl::size_t<FUN_REF_ID + n>, Iter>
63 {
64 typedef Iter iter0;
65 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
66 typedef BOOST_PP_CAT(p, n)(&type)(BOOST_PP_ENUM_PARAMS(n, p));
67 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
68 };
69
70 template<class Iter>
71 struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_REF_ID + n>, Iter>
72 {
73 typedef Iter iter0;
74 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
75 typedef BOOST_PP_CAT(p, n)(&type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
76 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
77 };
78
79 // functions
80
81 template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
82 struct encode_type_impl<V, R(BOOST_PP_ENUM_PARAMS(n, P))>
83 {
84 typedef R BOOST_PP_CAT(P, n);
85 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_ID + n) type;
86 };
87
88 template<class V, class R BOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
89 struct encode_type_impl<V, R(BOOST_PP_ENUM_PARAMS(n, P) ...)>
90 {
91 typedef R BOOST_PP_CAT(P, n);
92 typedef BOOST_TYPEOF_ENCODE_PARAMS(BOOST_PP_INC(n), FUN_VAR_ID + n) type;
93 };
94
95 template<class Iter>
96 struct decode_type_impl<ndnboost::mpl::size_t<FUN_ID + n>, Iter>
97 {
98 typedef Iter iter0;
99 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
100 typedef BOOST_PP_CAT(p, n)(type)(BOOST_PP_ENUM_PARAMS(n, p));
101 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
102 };
103
104 template<class Iter>
105 struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_ID + n>, Iter>
106 {
107 typedef Iter iter0;
108 BOOST_TYPEOF_DECODE_PARAMS(BOOST_PP_INC(n))
109 typedef BOOST_PP_CAT(p, n)(type)(BOOST_PP_ENUM_PARAMS(n, p) ...);
110 typedef BOOST_PP_CAT(iter, BOOST_PP_INC(n)) iter;
111 };
112
113#endif//BOOST_TYPEOF_NO_FUNCTION_TYPES
114
115#ifndef BOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
116// member functions
117
118#define BOOST_TYPEOF_qualifier
119#define BOOST_TYPEOF_id MEM_FUN_ID
120#include <ndnboost/typeof/register_mem_functions.hpp>
121
122#define BOOST_TYPEOF_qualifier const
123#define BOOST_TYPEOF_id CONST_MEM_FUN_ID
124#include <ndnboost/typeof/register_mem_functions.hpp>
125
126#define BOOST_TYPEOF_qualifier volatile
127#define BOOST_TYPEOF_id VOLATILE_MEM_FUN_ID
128#include <ndnboost/typeof/register_mem_functions.hpp>
129
130#define BOOST_TYPEOF_qualifier volatile const
131#define BOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
132#include <ndnboost/typeof/register_mem_functions.hpp>
133
134#undef n
135#endif