Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to assign from std::make_pair if type is not movable

dhaneyMay 1 2014 — edited Jul 4 2014

I'm attempting to compile the following code with the -std=c++11 flag:

#include <utility>

struct Y

{

    Y();

    Y(const Y&);

};

int main(void) {

    Y y;

    std::pair<int, Y> p = std::make_pair(0, y);

    return 0;

};

This works fine when compiled with:

CC -std=c++03 -m64 -c

or on Linux (GCC 4.7.3/GCC 4.9) with:

g++ -std=c++11 -m64 -c

However when compiled with:

CC -std=c++11 -m64 -c

It produces the following error:

"pair.cpp", line 11: Error: Using deleted function 'std::pair<int, Y>::pair(std::pair<int, Y>&&)'.

1 Error(s) detected.

I suspect this is a compiler bug, but wanted to confirm there wasn't a clause in the standard that would explain this.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2014
Added on May 1 2014
4 comments
2,342 views