]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (C) 2006 Peder Holt |
2 | // Use, modification and distribution is subject to the Boost Software | |
3 | // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) | |
4 | ||
5 | #include <boost/typeof/typeof.hpp> | |
6 | #include <boost/type_traits/is_same.hpp> | |
7 | #include <boost/static_assert.hpp> | |
8 | #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() | |
9 | ||
10 | ||
11 | void do_int(int) {} | |
12 | ||
13 | struct { | |
14 | template<typename T> | |
15 | T operator[](const T& n) {return n;} | |
16 | } int_p; | |
17 | ||
18 | ||
19 | template<typename T> struct wrap | |
20 | { | |
21 | BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[& do_int]) | |
22 | typedef typename nested::type type; | |
23 | }; | |
24 | ||
25 | BOOST_TYPEOF_REGISTER_TEMPLATE(wrap,1) | |
26 | ||
27 | template<typename T> struct parser | |
28 | { | |
29 | struct __rule { | |
30 | static T & a_placeholder; | |
31 | BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[a_placeholder]) | |
32 | typedef typename nested::type type; | |
33 | }; | |
34 | }; | |
35 | ||
36 | BOOST_STATIC_ASSERT((boost::is_same<wrap<double>::type,void(*)(int)>::value)); | |
37 | BOOST_STATIC_ASSERT((boost::is_same<parser<wrap<double> >::__rule::type,wrap<double> >::value)); |