forked from boostorg/typeof
Implemented BOOST_TYPEOF_NESTED_TYPEDEF.
This macro works around known bugs in VC7.1 and VC8.0 concerning the use of BOOST_TYPEOF inside templates. It also eliminates the limitation imposed by BOOST_TYPEOF_LIMIT_SIZE. [SVN r33355]
This commit is contained in:
@ -73,4 +73,7 @@ test-suite "typeof"
|
||||
|
||||
[ compile function_ptr_from_tpl.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : function_ptr_from_tpl_native ]
|
||||
[ compile function_ptr_from_tpl.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : function_ptr_from_tpl_emulation ]
|
||||
|
||||
[ compile nested_typedef.cpp : <define>BOOST_TYPEOF_NATIVE special-requirements : nested_typedef_native ]
|
||||
[ compile nested_typedef.cpp : <define>BOOST_TYPEOF_COMPLIANT special-requirements : nested_typedef_emulation ]
|
||||
;
|
||||
|
34
test/nested_typedef.cpp
Normal file
34
test/nested_typedef.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#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&) {}
|
||||
} 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));
|
Reference in New Issue
Block a user