[過去ログ] C++相談室 part164 (1002レス)
前次1-
抽出解除 レス栞

このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
936
(2): デフォルトの名無しさん (ワッチョイ 8e3b-xUKY) [] 2023/10/23(月) 01:32:53.76 ID:sueaiNV30(1) AAS
>>935
https://wandbox.org/permlink/n0KXbXrmLzHDl6KU

次のコードがコンパイルできない

struct A {
 A(int) {}
 A(const A&) = delete;
};

int main()
{
 std::vector<A> v = { 1, 2, 3 };
}
938: デフォルトの名無しさん (ワッチョイ 5d01-46Vy) [sage] 2023/10/23(月) 09:29:50.40 ID:9KLj8HWs0(1/2) AAS
>>936,937
あれ?
$ cat test.cpp
#include <iostream>
using namespace std;
struct A {
A () {cout << "construct" << endl;}
A (const A &p) = delete;
A (A &&p) {cout << "move" << endl;}
};
void func (initializer_list <A> p) {
cout << "func" << endl;
}
int main () {
A a0;
A a1;
func ({move (a0), move (a1)});
return 0;
}
$ g++ test.cpp
$ ./a.out
construct
construct
move
move
func
940: デフォルトの名無しさん (ワッチョイ 4eda-CTkJ) [sage] 2023/10/23(月) 11:36:11.62 ID:OKLUF2xV0(1) AAS
>>936
コピコン消したいなら代入オペレータ用意してやらんとダメだろ
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.036s