Boost logo

Boost :

Subject: Re: [boost] [type_traits] has_member_function_callable_with
From: Daniel James (dnljms_at_[hidden])
Date: 2011-09-15 19:32:54


2011/9/15 Ion Gaztañaga <igaztanaga_at_[hidden]>:
> Hi to all,
>
> Trying to port C++11 code (allocator_traits) to C++03 (without decltype
> support), I needed to check at compile time if a member function can be
> called with some given parameters.

Take a look at:

http://svn.boost.org/svn/boost/trunk/boost/unordered/detail/allocator_helpers.hpp

It contains an incomplete implementation of allocator_traits. I just
used sizeof instead of decltype for compilers which support SFINAE
expressions - gcc 4.4+, clang, and visual studio 2008+ (sort of). Look
for the line:

#if !defined(BOOST_NO_SFINAE_EXPR) || BOOST_WORKAROUND(BOOST_MSVC, >= 1500)

If you can decipher it you might notice some apparently superfluous
code which is required to use SFINAE expressions with Visual C++. I'll
write some more when I get a chance.

I'll have a look at your trait implementation as it might be better
for other compilers.


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