[Bug c++/49058] [C++0x] Bind no-arguments functor failed using std::bind with -pedantic option.

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 19 12:04:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49058

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-19 10:47:15 UTC ---
Jason, this works without -pedantic but fails with:

template<typename T> T val();

struct F1
{
    void operator()();
};

template<typename... T> struct tuple { };

template<typename T, typename... V>
T
call(T&& t, tuple<V...>)
{ return t; }

template<typename F, typename... T>
struct Bind
{
    template<typename... A, typename R
      = decltype( val<F>()( call(val<T>(), tuple<A...>())... ) )>
    R f(A&&...);

    template<typename... A, typename R
      = decltype( val<const F>()( call(val<T>(), tuple<A...>())... ) )>
    R f(A&&...) const;
};

int main()
{
    Bind<F1>().f();
}

Is this code relying on a G++ extension?

The parameter pack T has zero elements so the expansion:
    call(val<T>(), tuple<A...>())... )
expands to nothing, and in -pedantic mode that seems to prevent the parameter
pack A from participating in type deduction, so SFINAE doesn't remove the
overload.



More information about the Gcc-bugs mailing list