This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/59969] std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Apr 2015 16:10:34 +0000
- Subject: [Bug libstdc++/59969] std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object
- Auto-submitted: auto-generated
- References: <bug-59969-4 at http dot gcc dot gnu dot org/bugzilla/>
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.