This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/59969] std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59969

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The attached example builds fine, I think you mean this:

#include <map>

struct A
{
    int bla;
    A(int blub):bla(blub){}
    A(A&&) = delete;
    A(const A&) = delete;
    A& operator=(A&&) = delete;
    A& operator=(const A&) = delete;
};

int main()
{
    std::map<int, A> map;
    map.emplace(1, 1);
}

That code isn't valid.

(In reply to gcc.gnu.org.49489419 from comment #0)
>  is preferred over the standard constructor
> 
> template<class _U1, class _U2,
>          class = typename enable_if<__and_<is_convertible<_U1, _T1>,
>                                            is_convertible<_U2, _T2>
>                                           >::value
>                                    >::type>
> constexpr pair(_U1&& __x, _U2&& __y)
> : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { }

That constructor isn't valid because is_convertible<int, A> is false, because
is_convertible is always false for non-movable types.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]