2
0
mirror of https://github.com/boostorg/typeof.git synced 2026-01-19 04:42:14 +00:00
Files
typeof/test/nested_typedef.cpp
Arkadiy Vertleyb 64ba3be86f merged inspection report fixes
[SVN r35053]
2006-09-09 17:43:02 +00:00

38 lines
1012 B
C++

// Copyright (C) 2006 Peder Holt
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
void do_int(int) {}
struct {
template<typename T>
T operator[](const T& n) {return n;}
} int_p;
template<typename T> struct wrap
{
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[& do_int])
typedef typename nested::type type;
};
BOOST_TYPEOF_REGISTER_TEMPLATE(wrap,1)
template<typename T> struct parser
{
struct __rule {
static T & a_placeholder;
BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[a_placeholder])
typedef typename nested::type type;
};
};
BOOST_STATIC_ASSERT((boost::is_same<wrap<double>::type,void(*)(int)>::value));
BOOST_STATIC_ASSERT((boost::is_same<parser<wrap<double> >::__rule::type,wrap<double> >::value));