//remove_reference.h
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
#ifndef _REMOVE_REFERENCE_H_
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
#define _REMOVE_REFERENCE_H_
namespace boost {
namespace type_traits {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template <
class T>
struct wrap {};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef
char yes_type;
struct no_type
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
char padding[8];
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
}
// namespace boost::type_traits
namespace detail {
using ::boost::type_traits::yes_type;
using ::boost::type_traits::no_type;
using ::boost::type_traits::wrap;
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
#define BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(trait,sp,C) \
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<>
struct trait##_impl< sp > \
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{ \
enum {value = (C)}; \
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template <
class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
char is_reference_helper1(...);
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template <
class T> no_type is_reference_helper2(T&(*)(wrap<T>));
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
yes_type is_reference_helper2(...);
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template <typename T>
struct is_reference_impl
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
enum{
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
value =
sizeof(
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
::boost::detail::is_reference_helper2(
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
// BOOST_STATIC_CONSTANT(
// bool, value = sizeof(
// ::boost::detail::is_reference_helper2(
// ::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
// );
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,
void,
false)
// VC6用这一个就可以了,void const等也解决了
// #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
// BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const,false)
// BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void volatile,false)
// BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const volatile,false)
// #endif
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
}
// namespace detail
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template <typename T>
struct is_reference
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
enum{
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
value = detail::is_reference_impl<T>::value
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
namespace detail {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename ID>
struct msvc_extract_type
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
struct id2type;
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename T, typename ID>
struct msvc_register_type : msvc_extract_type<ID>
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef msvc_extract_type<ID> base_type;
struct base_type::id2type
// This uses nice VC6.5 and VC7.1 bugfeature
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
{
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef T type;
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<
bool IsReference>
struct remove_reference_impl_typeof {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename T,typename ID>
struct inner {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef T type;
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<>
struct remove_reference_impl_typeof<
true> {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename T,typename ID>
struct inner {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename U>
static msvc_register_type<U,ID> test(U&(*)());
static msvc_register_type<T,ID> test(...);
//BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
enum {register_test=
sizeof(test( (T(*)())(NULL) ) )};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef typename msvc_extract_type<ID>::id2type::type type;
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
}
//namespace detail
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
template<typename T>
struct remove_reference {
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
typedef typename detail::remove_reference_impl_typeof<
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
boost::is_reference<T>::value
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
>::template inner<T,remove_reference<T> >::type type;
//BOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_reference,T)
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
};
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
}
![InBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/93f07565306fc40ca9581b2cf53949c8.png)
#endif