About: Copy elision     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : yago:YagoPermanentlyLocatedEntity, within Data Space : dbpedia.demo.openlinksw.com associated with source document(s)
QRcode icon
http://dbpedia.demo.openlinksw.com/describe/?url=http%3A%2F%2Fdbpedia.org%2Fresource%2FCopy_elision

In C++ computer programming, copy elision refers to a compiler optimization technique that eliminates unnecessary copying of objects. The C++ language standard generally allows implementations to perform any optimization, provided the resulting program's observable behavior is the same as if, i.e. pretending, the program were executed exactly as mandated by the standard. Beyond that, the standard also describes a few situations where copying can be eliminated even if this would alter the program's behavior, the most common being the return value optimization (see ). Another widely implemented optimization, described in the C++ standard, is when a temporary object of class type is copied to an object of the same type. As a result, copy-initialization is usually equivalent to direct-initiali

AttributesValues
rdf:type
rdfs:label
  • Copy elision (en)
  • コピーの省略 (ja)
  • 复制省略 (zh)
rdfs:comment
  • In C++ computer programming, copy elision refers to a compiler optimization technique that eliminates unnecessary copying of objects. The C++ language standard generally allows implementations to perform any optimization, provided the resulting program's observable behavior is the same as if, i.e. pretending, the program were executed exactly as mandated by the standard. Beyond that, the standard also describes a few situations where copying can be eliminated even if this would alter the program's behavior, the most common being the return value optimization (see ). Another widely implemented optimization, described in the C++ standard, is when a temporary object of class type is copied to an object of the same type. As a result, copy-initialization is usually equivalent to direct-initiali (en)
  • C++プログラミングにおけるコピーの省略(コピーのしょうりゃく)とは、不必要なを除去するコンパイラ最適化技術のことである。C++言語標準は基本的に、出来上がったプログラムの表面上の動作が言語標準が義務付けた通りであれば、実装はどのような最適化を施しても良いとしている。() しかし、プログラムの動作が変更され得るにもかかわらず、それでもコピーが省略されうる状況を言語標準は幾つか挙げている。その中で最も有名なのがであり、もう一つは、クラス型のが、同じ型のオブジェクトへとコピーされるときの最適化である。これも広く実装されており、C++言語標準で挙げられている。 結果的に、コピー初期化と直接初期化の間にパフォーマンス上の違いはないが、セマンティクス上ではそうではなく、コピー初期化にはアクセス可能なが未だに必要である。 なお、参照に束縛されている一時オブジェクトは最適化されない。例: 言語標準によると、例外として投げられるオブジェクトにも、同じような最適化が適用される。 しかし、投げられたオブジェクトから例外オブジェクトへのコピー、そして例外オブジェクトから例外宣言のcatch節へのコピーのどちらも、最適化されるかもしれないし、されないかもしれない。これは、でも、名前付きオブジェクトでも同様である。 例: (ja)
  • 复制省略或者译作“省略不必要的复制”(copy elision),是C++语言标准中定义的编译优化技术。 当一个class类型的的临时对象用于初始化同类型的对象时,复制初始化通常优化为直接初始化;但在语义上仍然需要复制构造函数是可访问的。 例如: #include struct C { explicit C(int) {} C(const C&) { std::cout<<"copy constructor"<<std::endl; } // the copy constructor has a visible side effect}; // it modifies an object with static storage durationint main { C c1(42); // direct-initialization, calls C::C(42) C c2 = C(42); // copy-initialization elision as direct-initialization, so as to call C::C(42) return 0;} 上例,在g++与Visual C++默认都是复制省略。 throw语句抛出一个异常对象,catch语句匹配一个异常对象,默认是要执行复制构造函数的。如下例: (zh)
dcterms:subject
Wikipage page ID
Wikipage revision ID
Link from a Wikipage to another Wikipage
Link from a Wikipage to an external page
sameAs
dbp:wikiPageUsesTemplate
has abstract
  • In C++ computer programming, copy elision refers to a compiler optimization technique that eliminates unnecessary copying of objects. The C++ language standard generally allows implementations to perform any optimization, provided the resulting program's observable behavior is the same as if, i.e. pretending, the program were executed exactly as mandated by the standard. Beyond that, the standard also describes a few situations where copying can be eliminated even if this would alter the program's behavior, the most common being the return value optimization (see ). Another widely implemented optimization, described in the C++ standard, is when a temporary object of class type is copied to an object of the same type. As a result, copy-initialization is usually equivalent to direct-initialization in terms of performance, but not in semantics; copy-initialization still requires an accessible copy constructor. The optimization can not be applied to a temporary object that has been bound to a reference. (en)
  • C++プログラミングにおけるコピーの省略(コピーのしょうりゃく)とは、不必要なを除去するコンパイラ最適化技術のことである。C++言語標準は基本的に、出来上がったプログラムの表面上の動作が言語標準が義務付けた通りであれば、実装はどのような最適化を施しても良いとしている。() しかし、プログラムの動作が変更され得るにもかかわらず、それでもコピーが省略されうる状況を言語標準は幾つか挙げている。その中で最も有名なのがであり、もう一つは、クラス型のが、同じ型のオブジェクトへとコピーされるときの最適化である。これも広く実装されており、C++言語標準で挙げられている。 結果的に、コピー初期化と直接初期化の間にパフォーマンス上の違いはないが、セマンティクス上ではそうではなく、コピー初期化にはアクセス可能なが未だに必要である。 なお、参照に束縛されている一時オブジェクトは最適化されない。例: #include int n = 0;struct C { explicit C(int) {} C(const C&) { ++n; } // 目に見える副作用を持つコピーコンストラクタ}; // 静的な記憶時間を持つオブジェクトを書き換えるint main { C c1(42); // 直接初期化。 C::C(42) を呼ぶ C c2 = C(42); // コピー初期化。 C::C( C(42) ) を呼ぶ std::cout << n << std::endl; // コピーが省略されたなら 0 、そうでなければ 1 を出力する return 0;} 言語標準によると、例外として投げられるオブジェクトにも、同じような最適化が適用される。 しかし、投げられたオブジェクトから例外オブジェクトへのコピー、そして例外オブジェクトから例外宣言のcatch節へのコピーのどちらも、最適化されるかもしれないし、されないかもしれない。これは、でも、名前付きオブジェクトでも同様である。 例: #include struct C { C {} C(const C&) { std::cout << "Hello World! "; }};void f { C c; throw c; // 名前付きオブジェクト c を例外オブジェクトにコピー。} // このコピーが省略されるかどうかは不確かである。int main { try { f; } catch(C c) { // 例外オブジェクトを例外宣言内の一時領域にコピー。 } // このコピーも省略されるかどうかは不確かである。} 言語標準に準拠したコンパイラは、上記のコードから"Hello World!"と二度出力するプログラムを生成しなければならなかった。C++11では、名前付きオブジェクトの例外オブジェクトへのコピーと、例外ハンドラで宣言されたオブジェクトへのコピーを省略することを本質的に許したことで、その問題は対処された。 GCCは-fno-elide-constructorsオプションを提供して、コピーの省略を無効化できるようにしている。このオプションは戻り値最適化の効果を発見(あるいは見逃し!)するのに有用である。平時にこの重要な最適化を無効化することは推奨しない。 (ja)
  • 复制省略或者译作“省略不必要的复制”(copy elision),是C++语言标准中定义的编译优化技术。 当一个class类型的的临时对象用于初始化同类型的对象时,复制初始化通常优化为直接初始化;但在语义上仍然需要复制构造函数是可访问的。 例如: #include struct C { explicit C(int) {} C(const C&) { std::cout<<"copy constructor"<<std::endl; } // the copy constructor has a visible side effect}; // it modifies an object with static storage durationint main { C c1(42); // direct-initialization, calls C::C(42) C c2 = C(42); // copy-initialization elision as direct-initialization, so as to call C::C(42) return 0;} 上例,在g++与Visual C++默认都是复制省略。 throw语句抛出一个异常对象,catch语句匹配一个异常对象,默认是要执行复制构造函数的。如下例: #include struct C { C {} C(const C&) { std::cout << "Hello World! "; }};void f { C c; throw c; // copying the named object c into the exception object.} // 由于异常对象保存在线程信息块TIB中,这里的复制构造不可省略. 这使得调用栈上压栈保存的函数都有机会处理这个异常对象int main { try { f; } catch(C c) { // copying the exception object into the temporary in the exception declaration. } // 由于这里是传值的catch批配,因此复制初始化不可省略. 通常用于catch块可能会修改异常对象的内容,但又需要把原来的异常对象重新抛出(re-throw)} 上例默认应该打印输出两次"Hello World!" GCC的编译选项-fno-elide-constructors关闭复制省略。 (zh)
prov:wasDerivedFrom
page length (characters) of wiki page
foaf:isPrimaryTopicOf
is Link from a Wikipage to another Wikipage of
is Wikipage redirect of
is Wikipage disambiguates of
is foaf:primaryTopic of
Faceted Search & Find service v1.17_git139 as of Feb 29 2024


Alternative Linked Data Documents: ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3330 as of Mar 19 2024, on Linux (x86_64-generic-linux-glibc212), Single-Server Edition (378 GB total memory, 59 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software