Considerably simplified is_reference for MSVC

is_reference and is_enum now works with ABCs!


[SVN r13186]
This commit is contained in:
Dave Abrahams
2002-03-13 22:16:06 +00:00
parent 4fe73d6f02
commit 4f7c036ba9
2 changed files with 9 additions and 34 deletions

View File

@@ -280,7 +280,6 @@ template <typename T> struct is_reference<T&const volatile>
# pragma warning(disable: 4181)
#endif // BOOST_MSVC
namespace detail
{
template <typename T> struct is_reference_or_const_volatile
@@ -298,42 +297,22 @@ namespace detail
>::value));
};
no_type non_array_is_reference_helper(...);
template <typename T>
yes_type non_array_is_reference_helper(T&(*)());
template <class T> struct wrap {};
template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
char is_reference_helper1(...);
template <bool isarray_>
struct is_reference_helper
{
template <class T>
struct apply
{
typedef T (*pf_t)();
static pf_t pf;
BOOST_STATIC_CONSTANT(
bool, value = (1 == sizeof(::boost::detail::non_array_is_reference_helper(pf))));
};
};
template <>
struct is_reference_helper<true>
{
template <class T>
struct apply
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};
template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
yes_type is_reference_helper2(...);
}
template <typename T>
struct is_reference
{
BOOST_STATIC_CONSTANT(
bool, value = ::boost::detail::is_reference_helper<
is_array<T>::value
>::template apply<T>::value);
bool, value = sizeof(
::boost::detail::is_reference_helper2(
::boost::detail::is_reference_helper1(::boost::detail::wrap<T>()))) == 1
);
};
template <> struct is_reference<void>

View File

@@ -94,9 +94,7 @@ int cpp_main(int argc, char* argv[])
value_test(true, boost::is_reference<cr_type>::value)
value_test(true, boost::is_reference<const UDT&>::value)
value_test(false, boost::is_reference<void>::value)
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC)
value_test(false, boost::is_reference<test_abc1>::value)
#endif
value_test(false, boost::is_member_pointer<f1>::value)
value_test(false, boost::is_member_pointer<f2>::value)
@@ -133,9 +131,7 @@ int cpp_main(int argc, char* argv[])
value_test(false, boost::is_enum<int_convertible>::value)
//value_test(false, boost::is_enum<int&>::value)
value_test(false, boost::is_enum<void>::value)
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC)
value_test(false, boost::is_enum<test_abc1>::value)
#endif
return check_result(argc, argv);
}