Help needed debugging std::is_convertible problem (PR 65760)
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Apr 16 12:33:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65760
I don't understand why commenting out *any one* of the lines marked
(1), (2), (3), (4) causes this to compile:
#include <functional>
struct C {
C() = default;
C(std::function<C(int)>); // (1)
C(std::function<C(int, int)>); // (2)
template <class T> C operator () (T&&); // (3)
template <class T> C operator () (T&&, T&&); // (4)
};
int main() {
C c = C();
}
My understanding is that the SFINAE constraint on the std::function
constructor needs to check std::is_convertible<C, C> which requires C
to be complete, but why does it only complain that C is incomplete
when all of (1) - (4) are present?
G++, Clang and EDG all agree on this behaviour, so I don't think it's
a compiler bug. The libc++ std::function works fine in this case, I
don't know what it does differently so that it works.
To fix it I am considering short-circuiting the constraint to not use
is_convertible<C, C>, by doing:
__or_<is_same<From, To>, is_convertible<From, To>>
which doesn't require the types to be complete when they're the same.
Before doing that I'd really like to understand the problem properly.
I've attached a reduced version with no header dependencies, based on
the relevant parts of <type_traits> and <functional> from 4.9.2.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: func.cc
Type: text/x-c++src
Size: 10895 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20150416/8e3ac2f4/attachment.bin>
More information about the Libstdc++
mailing list