$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-23 13:05:18
Ah good, that avoids using inheritance to distinguish these babies...
but is char really guaranteed to be smaller than double (half-joking only).
-Dave
----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
> I use the same thing in Boost.Function. From
boost/function/function_base.hpp
>
>       // Determine if the incoming argument is a reference_wrapper
> #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
>       template<typename T>
>       struct is_ref
>       {
>         BOOST_STATIC_CONSTANT(bool, value = false);
>       };
>
>       template<typename T>
>       struct is_ref<reference_wrapper<T> >
>       {
>         BOOST_STATIC_CONSTANT(bool, value = true);
>       };
> #else // no partial specialization
>       typedef char yes_type;
>       typedef double no_type;
>
>       no_type is_ref_tester(...);
>
>       template<typename T>
>       yes_type is_ref_tester(reference_wrapper<T>*);
>
>       template<typename T>
>       struct is_ref
>       {
>         static T* t;
>         BOOST_STATIC_CONSTANT(bool,
>           value = (sizeof(is_ref_tester(t)) == sizeof(yes_type)));
>       };
> #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
>
> I'd be glad to have any form of this code in ref.hpp, and get it out of
> detail::function.
>
> Doug