forked from boostorg/typeof
Apply variadic functions patch from Sergey Zubkovsky.
[SVN r59579]
This commit is contained in:
2
test/function.cpp
Executable file → Normal file
2
test/function.cpp
Executable file → Normal file
@ -6,3 +6,5 @@
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void()>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<double(bool)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(...)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<float(int, ...)>::value);
|
||||
|
16
test/function_binding.cpp
Executable file → Normal file
16
test/function_binding.cpp
Executable file → Normal file
@ -7,8 +7,16 @@
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
int foo(double);
|
||||
typedef int(&FREF)(double);
|
||||
FREF fref = *foo;
|
||||
int foo1(double);
|
||||
int foo2(...);
|
||||
int foo3(int, ...);
|
||||
typedef int(&FREF1)(double);
|
||||
typedef int(&FREF2)(...);
|
||||
typedef int(&FREF3)(int, ...);
|
||||
FREF1 fref1 = *foo1;
|
||||
FREF2 fref2 = *foo2;
|
||||
FREF3 fref3 = *foo3;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref), int(double)>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref1), int(double)>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref2), int(...)>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(fref3), int(int,...)>::value));
|
||||
|
17
test/function_ptr.cpp
Executable file → Normal file
17
test/function_ptr.cpp
Executable file → Normal file
@ -8,12 +8,19 @@ BOOST_STATIC_ASSERT(boost::type_of::test<double(*)()>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<double(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)()>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(...)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(*)(int, double, short, char*, bool, char, float, long, unsigned short, ...)>::value);
|
||||
|
||||
// check that const gets stripped from function pointer
|
||||
|
||||
int foo(double);
|
||||
typedef int(*PTR)(double);
|
||||
typedef const PTR CPTR;
|
||||
CPTR cptr = foo;
|
||||
int foo1(double);
|
||||
int foo2(...);
|
||||
typedef int(*PTR1)(double);
|
||||
typedef int(*PTR2)(...);
|
||||
typedef const PTR1 CPTR1;
|
||||
typedef const PTR2 CPTR2;
|
||||
CPTR1 cptr1 = foo1;
|
||||
CPTR2 cptr2 = foo2;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr), PTR>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr1), PTR1>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(cptr2), PTR2>::value));
|
||||
|
20
test/function_ptr_from_tpl.cpp
Executable file → Normal file
20
test/function_ptr_from_tpl.cpp
Executable file → Normal file
@ -6,15 +6,23 @@
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
void f()
|
||||
{}
|
||||
void f1() {}
|
||||
void f2(...) {}
|
||||
|
||||
template<class T>
|
||||
struct tpl
|
||||
struct tpl1
|
||||
{
|
||||
typedef BOOST_TYPEOF_TPL(&f) type;
|
||||
typedef BOOST_TYPEOF_TPL(&f1) type;
|
||||
};
|
||||
|
||||
typedef void(*fun_type)();
|
||||
template<class T>
|
||||
struct tpl2
|
||||
{
|
||||
typedef BOOST_TYPEOF_TPL(&f2) type;
|
||||
};
|
||||
|
||||
typedef void(*fun1_type)();
|
||||
typedef void(*fun2_type)(...);
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<tpl<void>::type, fun_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<tpl1<void>::type, fun1_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<tpl2<void>::type, fun2_type>::value));
|
||||
|
2
test/function_ref.cpp
Executable file → Normal file
2
test/function_ref.cpp
Executable file → Normal file
@ -6,3 +6,5 @@
|
||||
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<void(&)()>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(int, short)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(...)>::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<int(&)(int,...)>::value);
|
||||
|
Reference in New Issue
Block a user