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:
Peder Holt
2006-03-16 17:10:19 +00:00
parent e2d492bb49
commit dbfa74603c
12 changed files with 198 additions and 31 deletions

View File

@ -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
View 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));