Home Missing something on SFINAE (dummy template argument form)
Reply: 0

Missing something on SFINAE (dummy template argument form)

user1442 Published in April 25, 2018, 6:03 pm

I’m using Visual Studio 17.7 preview 3, and including Boost 1.67.0b1.

I’m an old hand at using enable_if, but today I’m trying to use the new way of doing things — a dummy extra template parameter.

Boost.Range does not provide a “is this a range” check, so I’m using range_value<X>::value as the dependent type does not exist if the nominated type is not a range. That’s exactly what SFINAE is all about! The template can’t parse the declaration when I give it a double, so it should drop out of the overload set with no error.

#include <boost/range/value_type.hpp>

class Fizzer_t {
    using itemdef_t = std::pair<int, std::string_view>;
    std::vector<itemdef_t> playdef;
    template<typename R,
        typename = typename boost::range_value<R>::type>  // only call if R is a "range"
    Fizzer_t (const R & range_of_itemdefs);
    Fizzer_t (double);  // dummy

void play2 {
    Fizzer_t player3{ 3.14 };

When I give it a valid parameter, it does compile.
When I give it a double, rather than matching the other constructor it complains that

'type': is not a member of 'boost::range_iterator'

which is most decidedly not SFINAE.

What am I missing here?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315366 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO