28
28
#include " logger.hpp"
29
29
#include " exception.hpp"
30
30
#include " cassert.hpp"
31
+ #include " static_assert.hpp"
31
32
32
33
#include < cstddef>
33
34
#include < new>
34
35
#include < algorithm> // swap(), C++98
35
36
#include < utility> // swap(), C++11
37
+ #include CPPDEVTK_TR1_HEADER(type_traits)
36
38
37
39
38
40
namespace cppdevtk {
@@ -69,7 +71,7 @@ static const NullOptT kNullOpt = (static_cast<NullOptT>(NULL)) ;
69
71
// / - C++ 17 std says that if an ::std::optional<T> contains a value, the value is guaranteed to be allocated
70
72
// / as part of the optional object footprint, i.e. no dynamic memory allocation ever takes place.
71
73
// / Our implementation currently use dynamic memory allocation (need for public API and no time for proper implementation...)!
72
- // / - Reference types are not supported!
74
+ // / - Reference types are not supported (C++ 17 ::std::optional does not support references, ::boost::optional does) !
73
75
// / \sa
74
76
// / - <a href="http://en.cppreference.com/w/cpp/utility/optional">C++17 optional</a>
75
77
// / - <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4562.html#optional.object">C++ Extensions for Library Fundamentals, Version 2, 5.3 optional for object types</a>
@@ -78,6 +80,10 @@ static const NullOptT kNullOpt = (static_cast<NullOptT>(NULL)) ;
78
80
template <typename TValue>
79
81
class Optional {
80
82
public:
83
+ CPPDEVTK_STATIC_ASSERT (!CPPDEVTK_TR1_NS::is_reference<TValue>::value);
84
+ CPPDEVTK_STATIC_ASSERT ((!CPPDEVTK_TR1_NS::is_same<TValue, NullOptT>::value));
85
+
86
+
81
87
typedef TValue ValueType;
82
88
typedef void (*UnspecifiedBoolType)();
83
89
@@ -361,6 +367,7 @@ void Optional<TValue>::Reset() CPPDEVTK_NOEXCEPT {
361
367
CPPDEVTK_LOG_FATAL (" Optional::Reset(): destructor of TValue (" << typeid (TValue).name ()
362
368
<< " ) threw exception: " << Exception::GetDetailedInfo (exc));
363
369
CPPDEVTK_ASSERT (0 && " Optional::Reset(): destructor of TValue threw exception" );
370
+ SuppressUnusedWarning (exc);
364
371
terminate ();
365
372
}
366
373
catch (...) {
0 commit comments