Boost logo

Boost Users :

Subject: Re: [Boost-users] [Concepts & EnableIf] Is void special?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2012-03-28 04:57:30


Hi All

Ok, I should probably have started this thread with this self contained
code example.

What's wrong with this?

#include <vector>
#include <boost/concept/requires.hpp>
#include <boost/range/concepts.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>

template <typename T>
    BOOST_CONCEPT_REQUIRES(
            (( boost::SinglePassRangeConcept<T> )),
// ( void ))
            ( typename boost::enable_if<boost::is_same<typename
boost::range_value<T>::type, int>, void>::type ))
    f( const T & ) { }

int main( )
{
    std::vector<int> v;
    f( v );
}

g++ -c -o enable_if.o enable_if.cpp
enable_if.cpp: In function ‘int main()’:
enable_if.cpp:17: error: no matching function for call to
‘f(std::vector<int, std::allocator<int> >&)’

If I comment out the enable_if line and comment in the void line it's fine.

TIA, Rob.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net