Boost logo

Boost :

Subject: Re: [boost] [type trait extension] I hate volatile...
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-07-22 13:48:31


2011/7/22 Frédéric Bron <frederic.bron_at_[hidden]>

> > What does your code look like that detects void types? I use the
> following
> > EXPR_IS_VOID macro myself (which is not originally mine, but I think I
> have
> > modified it from the original after some testing); feel free to pilfer.
> The
> > double comma operator thingy is intended to work even if the type of (
> Expr
> > ) has an overloaded comma operator, but I've found that GCC has issues
> with
> > this construct, hence the two versions.
>
> Thank you for help. I have tested your code for void detection which
> GNUC version gives identical results to the one I use (on msvc, g++
> and intel):
>
> namespace detail {\
> struct returns_void_t {};
> static ::boost::type_traits::yes_type returns_void(returns_void_t);\
> static ::boost::type_traits::no_type returns_void(int);\
> }
> template <typename T> int operator,(const T&, ::detail::returns_void_t);
> template <typename T> int operator,(const volatile T&,
> ::detail::returns_void_t);
>
> #define RETURNS_VOID_IMPL(Expr)\
> sizeof(::boost::type_traits::yes_type)\
> ==\
> sizeof(::detail::returns_void(((Expr),
> ::detail::returns_void_t())))
>
[...]

I wonder, does the double comma trick I had for MSVC also work for GCC >
4.4.1 and/or Intel? And, if so, does it change the results?

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk