Agreed, thanks for the bug report.
Update
Related question: What's the expected value of:
std::is_constructible<int&>::value
? It's not perfectly clear to me from reading the standard.
What the standard says:
For a referenceable type
T
, the same result asis_constructible<T, const T&>::value
, otherwisefalse
.
A "referenceable type" is basically anything but a void
. I'm paraphrasing. This is not an exact definition. It is meant to be understandable as opposed to precise. A language lawyer (including myself) can tear it apart. But for ease in understanding, "anything but a void
" is close enough.
So your question becomes, what is:
std::is_constructible<int&, const (int&)&>::value // I've used pseudo code
const
applied to references is a no-op (). And lvalue references applied to lvalue references is a no-op (due to reference collapsing). For example consider this non-portable type_name
facility:
#include <type_traits>
#include <memory>
#include <iostream>
#include <cxxabi.h>
#include <cstdlib>
template <typename T>
std::string
type_name()
{
typedef typename std::remove_reference<T>::type TR;
std::unique_ptr<char, void(*)(void*)> own
(
abi::__cxa_demangle(typeid(TR).name(), nullptr,
nullptr, nullptr),
std::free
);
std::string r = own != nullptr ? own.get() : typeid(TR).name();
if (std::is_const<TR>::value)
r += " const";
if (std::is_volatile<TR>::value)
r += " volatile";
if (std::is_lvalue_reference<T>::value)
r += "&";
else if (std::is_rvalue_reference<T>::value)
r += "&&";
return r;
}
int
main()
{
typedef int& T;
std::cout << type_name<const T&>() << '\n';
}
For me this prints out:
int&
So the above simplifies to:
std::is_constructible<int&, int&>::value // true
which should answer true
since an lvalue int
should be constructible from a non-const lvalue int
.