public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/59969] New: std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object
@ 2014-01-28 14:43 gcc.gnu.org.49489419@oli-obk.de
  2015-04-08 16:10 ` [Bug libstdc++/59969] " redi at gcc dot gnu.org
  2015-04-08 16:16 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gcc.gnu.org.49489419@oli-obk.de @ 2014-01-28 14:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59969
           Summary: std::pair nonstandard constructor interferes when
                    calling map::emplace with noncopyable nonmovable
                    object
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc.gnu.org.49489419@oli-obk.de

Created attachment 31968
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31968&action=edit
example that cannot be built due to the bug

see also:
http://stackoverflow.com/questions/21405674/why-do-i-need-to-use-piecewise-construct-in-mapemplace-for-single-arg-construc

the issue is that on construction of the pair, the nonstandard constructor

// DR 811.
template<class _U1,
         class = typename enable_if<is_convertible<_U1, _T1>::value>::type>
constexpr pair(_U1&& __x, const _T2& __y)
: first(std::forward<_U1>(__x)), second(__y) { }

 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)) { }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/59969] std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object
  2014-01-28 14:43 [Bug libstdc++/59969] New: std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object gcc.gnu.org.49489419@oli-obk.de
@ 2015-04-08 16:10 ` redi at gcc dot gnu.org
  2015-04-08 16:16 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-08 16:10 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/59969] std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object
  2014-01-28 14:43 [Bug libstdc++/59969] New: std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object gcc.gnu.org.49489419@oli-obk.de
  2015-04-08 16:10 ` [Bug libstdc++/59969] " redi at gcc dot gnu.org
@ 2015-04-08 16:16 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-08 16:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
P.S. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4064.html will
improve things in this area, but isn't implemented yet.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-08 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-28 14:43 [Bug libstdc++/59969] New: std::pair nonstandard constructor interferes when calling map::emplace with noncopyable nonmovable object gcc.gnu.org.49489419@oli-obk.de
2015-04-08 16:10 ` [Bug libstdc++/59969] " redi at gcc dot gnu.org
2015-04-08 16:16 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).