Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6461

Are all CopyConstructible types MoveConstructible types?

$
0
0

According to the working draft N3337 (the most similar draft to the published ISOC++11 standard) and cppreference.com, the answer is yes.

N3337:

Table 21 — CopyConstructible requirements (in addition toMoveConstructible) [copyconstructible] [...]

cppreference.com:

The type T satisfies CopyConstructible if

  • The type T satisfies MoveConstructible, and [...]

But according to the result of compiling main.cpp with gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 and running a.out with the quoted statements in Ubuntu 14.04.3 LTS, the answer is not.

main.cpp:

#include <iostream>#include <type_traits>struct As{    As()=default;    As(As&&)=delete;    As(const As&)=default;    As& operator=(As&&)=delete;    As& operator=(const As&)=delete;    ~As()=default;};int main(){    std::cout<<std::is_move_constructible<As>::value<<std::endl;    std::cout<<std::is_copy_constructible<As>::value<<std::endl;    return 0;}

compiling and running from terminal:

$ g++ -std=c++11 main.cpp$ ./a.out

the result (output):

01

Did I misunderstand something or is N3337 and cppreference.com wrong, or does gcc contains a bug?


Viewing all articles
Browse latest Browse all 6461

Trending Articles