From 361d945b5ca65894e056fdcdde11554b89a9b13f Mon Sep 17 00:00:00 2001
From: Fredrik Blomqvist Consider these functions which should return a value but which might not have
a value to return: There are different approaches to the issue of not having a value to return.(A) double sqrt(double n );
+
(A) double sqrt( double n );
(B) char get_async_input();
(C) point polygon::get_any_point_effectively_inside();
struct X { - X ( int, std:::string ) ; + X ( int, std::string ) ; } ;
class W { @@ -1222,7 +1222,7 @@ public: { // Wrapped object constructed in-place via a TypedInPlaceFactory. // No temporary created. - W ( TypedInPlaceFactory2<X,int,std::string&rt;(123,"hello")) ; + W ( TypedInPlaceFactory2<X,int,std::string>(123,"hello")) ; }
The factories are divided in two groups:
template<class TypedInPlaceFactory> optional<T>::operator= (
TypedInPlaceFactory const& )
optional<T>:::reset ( T const&)
optional<T>::reset ( T const& )
Can only guarantee the basic exception safety: The lvalue optional is left uninitialized if an exception is thrown (any previous value is first destroyed using T::~T())
@@ -1320,11 +1320,11 @@ for T::T ( T const& ), you know that optional's assignment and reset has the // Case 1: Exception thrown during assignment. // T v0(123); -optional<T> opt0(v0); +optional<T> opt0(v0); try { T v1(456); - optional<T> opt1(v1); + optional<T> opt1(v1); opt0 = opt1 ; // If no exception was thrown, assignment succeeded. @@ -1340,7 +1340,7 @@ catch(...) // Case 2: Exception thrown during reset(v) // T v0(123); -optional<T> opt(v0); +optional<T> opt(v0); try { T v1(456);