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

             Bug #: 50641
           Summary: [c++0x] is_convertible and is_constructible
                    incorrectly require copy constructibility
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: l...@mit.edu


is_convertible and is_constructible seem to either spew errors or return false
when the To type is not CopyConstructible.  (errors happen if the copy
constructor is private; false happens if it's deleted.)

Here's a test case:

#include <type_traits>

struct From
{
};

struct To
{
  To(const From &&);
  To(const To &) = delete;
};

template <class T>
typename std::add_rvalue_reference<T>::type create();

void test()
{
  /* From N3242 [meta.unary.prop], with the ... removed, in reference to
is_constructible. */
  To t(create<From>());
}

static_assert(std::is_constructible<From, To>::value, "not constructible");

static_assert(std::is_convertible<From, To>::value, "not convertible");

>From my reading of N3242, is_constructible should certainly return true, and
I'm having a hard time understanding the definition of is_convertible.

This causes the fancy new map::insert function to be less useful if the
mapped_type is not CopyConstructible.  That usage seems to be the whole point,
according to [map.modifiers], which says:

If P is instantiated as a reference type, then the argument x is copied from.
Otherwise x is con-sidered to be an rvalue as it is converted to value_type and
inserted into the map. Specifically, in such cases CopyConstructible is not
required of key_type or mapped_type unless the conversion from P specifically
requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type
must be CopyConstructible). The signature taking InputIterator parameters does
not require CopyConstructible of either key_type or mapped_type if the
dereferenced InputIterator returns a non-const rvalue
pair<key_type,mapped_type>. Otherwise CopyConstructible is required for both
key_type and mapped_type.

Reply via email to