In C ++ 11 and later standards, is it guaranteed that a (possibly throwing exception) copy of ctor is not called when a class object returns by value from a function - provided that ctor movement is defined for this class? Prerequisites: suppose
struct X { X() {} X(const X&) {/* code that might throw exceptions */} X(X&&) {/* code that never throws exceptions */} ... };
and
X my_func(some_type& t) { X x; // code that modifies t and x but never throws exceptions return x; }
Now, for example, an expression such as
some_other_func(my_func(t));
never throw exceptions (i.e. is this guaranteed?) if the function some_other_func(const X&)does not throw exceptions? And what if the signature some_other_funcwas some_other_func(X)?
some_other_func(const X&)
some_other_func
some_other_func(X)
: , , , . , . , , noexcept.
noexcept
( ) : noexcept , , , noexcept.
++, .
, , , , , (), , t .
noexcept, , ( ). , , ( , , ).
, X(X&&) X() noexcept, .
X(X&&)
X()
, , some_other_function X, , X, , some_other_function .
some_other_function
X
Source: https://habr.com/ru/post/1687360/More articles:Bulk insertion in MongoDB with mongoose for multiple collections - node.jsDoes Qt's best practice include precompiled headers? - c ++Mass increase in MongoDB using mongoose - javascriptHow to open jenkins file in subfolders - jenkins-pipelineHow to provide a service that uses generics in Angular4? - angularUse LinqKit PredicateBuilder for a sibling model (EF Core) - c #Cannot execute https request in ssr - node.jsЧто конкретно представляет собой библиотека времени выполнения? - c++How to separate "\ n" from user input? - javaHow to use predicate builder using linq2sql and OR operator - c #All Articles