<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 18, 2014 at 2:21 AM,  <span dir="ltr"><<a href="mailto:sebastian@theophil.net" target="_blank">sebastian@theophil.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I recently filed <a href="http://llvm.org/bugs/show_bug.cgi?id=21574" target="_blank">http://llvm.org/bugs/show_bug.<u></u>cgi?id=21574</a> because I think the library implementation of std::is_constructible is broken.<br>
<br>
For a type<br>
<br>
struct S {<br>
    template <typename T> explicit operator T() const;<br>
    explicit operator int const&() const;<br>
};<br>
<br>
both std::is_constructible< int, S > and std::is_constructible< int const&, S > report false despite the explicit cast operators and  although<br>
<br>
T t;<br>
int const& i1(t);<br>
int i2(t);<br>
<br>
compile fine.<br>
<br>
What was the rationale for specializing std::is_constructible for scalar and reference types at all? Without this entire special-cased branch, std::is_constructible<S, Args...> simply forwards to the SFINAE expression decltype(std::move(S(std::<u></u>declval<Args>()...))). Isn't that what should always be evaluated because it tests that S(Args...) is a valid expression, just like the standard demands?<br></blockquote><div><br></div><div>That's not quite what the standard demands;</div><div><br></div><div>  T t(args...);</div><div><br></div><div>and</div><div><br></div><div>  T(args...)</div><div><br></div><div>are not valid in the same set of circumstances. In particular, they can differ when args contains exactly one expression (or zero). T(arg) is equivalent to (T)arg, which can perform a superset of the conversions performed by T t(arg), and I would imagine this is what libc++ is trying to handle.</div><div><br></div><div>I think that something like:</div><div><br></div><div>  decltype(::new S(std::declval<Args>()...))</div><div><br></div><div>... would cover all cases other than when S is a reference type.</div></div></div></div>