Boost logo

Boost :

Subject: [boost] Boost iterators are not SFINAE-friendly
From: pfultz2 (pfultz2_at_[hidden])
Date: 2014-05-17 18:21:21

Boost iterators aren't SFINAE-friendly. This is a problem when building
that detect certain behavior. Heres a simple example:

    #include <vector>
    #include <type_traits>
    #include <boost/iterator/filter_iterator.hpp>

    struct holder
        typedef void type;

    template<class Iterator, class=void>
    struct is_advanceable
    : std::false_type

    template<class Iterator>
    struct is_advanceable<Iterator, typename holder&lt;
        decltype(std::declval&lt;Iterator>() += std::declval<int>())
    : std::true_type

"This will pass");

    struct predicate
        template<class T>
        bool operator()(T&&) const;

    static_assert(not is_advanceable<boost::filter_iterator&lt;predicate,
std::vector&lt;int>::iterator>>::value, "This won't pass");

Although, it doesn't always lead to a compile error(rather than subtitution
failure), it does lead some very erroneous errors.


View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at