mirror of
https://github.com/boostorg/typeof.git
synced 2025-07-30 21:07:24 +02:00
binding workarounds added
[SVN r33045]
This commit is contained in:
43
include/boost/typeof/binding_workaround.hpp
Executable file
43
include/boost/typeof/binding_workaround.hpp
Executable file
@ -0,0 +1,43 @@
|
||||
#ifndef BOOST_TYPEOF_BINDING_WORKAROUND_HPP_INCLUDED
|
||||
#define BOOST_TYPEOF_BINDING_WORKAROUND_HPP_INCLUDED
|
||||
|
||||
// workarounds related to inability to bind to const T&
|
||||
|
||||
/*
|
||||
MSVC 7.1-, from inside a template,
|
||||
can't bind a function pointer to const T&
|
||||
*/
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,==1310) && defined(BOOST_TYPEOF_EMULATION)
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
template<class T>
|
||||
sizer<typename encode_type<BOOST_TYPEOF_VECTOR(0)<>, T*>::type> encode(T*,
|
||||
typename enable_if<typename is_function<T>::type>::type* = 0);
|
||||
|
||||
}}
|
||||
|
||||
#elif BOOST_WORKAROUND(BOOST_MSVC,<=1310) && defined(BOOST_TYPEOF_NATIVE)
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace type_of {
|
||||
|
||||
template<typename T>
|
||||
char (*encode_start(T*,
|
||||
typename enable_if<typename is_function<T>::type>::type* = 0))[encode_type<T*>::value];
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
#endif//BOOST_TYPEOF_BINDING_WORKAROUND_HPP_INCLUDED
|
@ -145,6 +145,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/typeof/message.hpp>
|
||||
#include <boost/typeof/binding_workaround.hpp>
|
||||
|
||||
// auto
|
||||
#define BOOST_AUTO(Var, Expr) BOOST_TYPEOF(Expr) Var = Expr
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
void f()
|
||||
{}
|
||||
@ -6,5 +8,7 @@ void f()
|
||||
template<class T>
|
||||
class x
|
||||
{
|
||||
typedef BOOST_TYPEOF(&f) type;
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<BOOST_TYPEOF_TPL(&f), void(*)()>::value
|
||||
));
|
||||
};
|
||||
|
Reference in New Issue
Block a user