22 #ifndef ICE_OPTIONAL_H
23 #define ICE_OPTIONAL_H
25 #ifdef ICE_CPP11_MAPPING
28 # include <type_traits>
29 # include <initializer_list>
31 # include <functional>
35 # define TR2_OPTIONAL_REQUIRES(...) typename enable_if<__VA_ARGS__::value, bool>::type = false
37 # if defined __GNUC__ // NOTE: GNUC is also defined for Clang
38 # if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)
39 # define TR2_OPTIONAL_GCC_4_8_AND_HIGHER___
41 # define TR2_OPTIONAL_GCC_4_8_AND_HIGHER___
44 # if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)
45 # define TR2_OPTIONAL_GCC_4_7_AND_HIGHER___
47 # define TR2_OPTIONAL_GCC_4_7_AND_HIGHER___
50 # if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ >= 1)
51 # define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___
52 # elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)
53 # define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___
55 # define TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___
59 # if defined __clang_major__
60 # if (__clang_major__ == 3 && __clang_minor__ >= 5)
61 # define TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_
62 # elif (__clang_major__ > 3)
63 # define TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_
65 # if defined TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_
66 # define TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_
67 # elif (__clang_major__ == 3 && __clang_minor__ == 4 && __clang_patchlevel__ >= 2)
68 # define TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_
73 # if (_MSC_VER >= 1900)
74 # define TR2_OPTIONAL_MSVC_2015_AND_HIGHER___
78 # if defined __clang__
79 # if (__clang_major__ > 2) || (__clang_major__ == 2) && (__clang_minor__ >= 9)
80 # define OPTIONAL_HAS_THIS_RVALUE_REFS 1
82 # define OPTIONAL_HAS_THIS_RVALUE_REFS 0
84 # elif defined TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___
85 # define OPTIONAL_HAS_THIS_RVALUE_REFS 1
86 # elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___
87 # define OPTIONAL_HAS_THIS_RVALUE_REFS 1
89 # define OPTIONAL_HAS_THIS_RVALUE_REFS 0
92 # if defined TR2_OPTIONAL_GCC_4_8_1_AND_HIGHER___
93 # define OPTIONAL_HAS_CONSTEXPR_INIT_LIST 1
94 # define OPTIONAL_CONSTEXPR_INIT_LIST constexpr
96 # define OPTIONAL_HAS_CONSTEXPR_INIT_LIST 0
97 # define OPTIONAL_CONSTEXPR_INIT_LIST
100 # if defined TR2_OPTIONAL_CLANG_3_5_AND_HIGHTER_ && (defined __cplusplus) && (__cplusplus != 201103L)
101 # define OPTIONAL_HAS_MOVE_ACCESSORS 1
103 # define OPTIONAL_HAS_MOVE_ACCESSORS 0
106 # // In C++11 constexpr implies const, so we need to make non-const members also non-constexpr
107 # if (defined __cplusplus) && (__cplusplus == 201103L)
108 # define OPTIONAL_MUTABLE_CONSTEXPR
110 # define OPTIONAL_MUTABLE_CONSTEXPR constexpr
115 namespace experimental{
124 # if defined TR2_OPTIONAL_GCC_4_8_AND_HIGHER___
126 # elif defined TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_
128 # elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___
130 # elif defined TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS
133 template <
typename T>
134 using is_trivially_destructible = std::has_trivial_destructor<T>;
138 # if (defined TR2_OPTIONAL_GCC_4_7_AND_HIGHER___)
140 # elif defined TR2_OPTIONAL_CLANG_3_4_2_AND_HIGHER_
142 # elif defined TR2_OPTIONAL_MSVC_2015_AND_HIGHER___
144 # elif defined TR2_OPTIONAL_DISABLE_EMULATION_OF_TYPE_TRAITS
150 struct is_nothrow_move_constructible
152 constexpr
static bool value = std::is_nothrow_constructible<T, T&&>::value;
155 template <
class T,
class U>
158 template <
class X,
class Y>
159 constexpr
static bool has_assign(...) {
return false; }
161 template <class X, class Y, size_t S = sizeof((std::declval<X>() = std::declval<Y>(),
true)) >
163 constexpr
static bool has_assign(
bool) {
return true; }
165 constexpr
static bool value = has_assign<T, U>(
true);
169 struct is_nothrow_move_assignable
171 template <
class X,
bool has_any_move_assign>
172 struct has_nothrow_move_assign {
173 constexpr
static bool value =
false;
177 struct has_nothrow_move_assign<X, true> {
178 constexpr
static bool value = noexcept( std::declval<X&>() = std::declval<X&&>() );
181 constexpr
static bool value = has_nothrow_move_assign<T, is_assignable<T&, T&&>::value>::value;
191 template <
class T>
class optional<T&>;
194 template <
class T>
inline constexpr T&& constexpr_forward(
typename std::remove_reference<T>::type& t) noexcept
196 return static_cast<T&&
>(t);
199 template <
class T>
inline constexpr T&& constexpr_forward(
typename std::remove_reference<T>::type&& t) noexcept
201 static_assert(!std::is_lvalue_reference<T>::value,
"!!");
202 return static_cast<T&&
>(t);
205 template <
class T>
inline constexpr
typename std::remove_reference<T>::type&& constexpr_move(T&& t) noexcept
207 return static_cast<typename std::remove_reference<T>::type&&
>(t);
211 # define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR)
213 # define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : ([]{assert(false && #CHECK);}(), (EXPR)))
220 template <
typename T>
221 struct has_overloaded_addressof
224 constexpr
static bool has_overload(...) {
return false; }
226 template <class X, size_t S = sizeof(std::declval<X&>().operator&()) >
227 constexpr
static bool has_overload(
bool) {
return true; }
229 constexpr
static bool value = has_overload<T>(
true);
232 template <
typename T, TR2_OPTIONAL_REQUIRES(!has_overloaded_addressof<T>)>
233 constexpr T* static_addressof(T& ref)
238 template <
typename T, TR2_OPTIONAL_REQUIRES(has_overloaded_addressof<T>)>
239 T* static_addressof(T& ref)
241 return std::addressof(ref);
246 constexpr U convert(U v) {
return v; }
250 constexpr
struct trivial_init_t{} trivial_init{};
261 constexpr
nullopt_t nullopt{nullopt_t::init()};
273 unsigned char dummy_;
276 constexpr storage_t( trivial_init_t ) noexcept : dummy_() {}
278 template <
class... Args>
279 constexpr storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {}
285 union constexpr_storage_t
287 unsigned char dummy_;
290 constexpr constexpr_storage_t( trivial_init_t ) noexcept : dummy_() {}
292 template <
class... Args>
293 constexpr constexpr_storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {}
295 ~constexpr_storage_t() =
default;
302 storage_t<T> storage_;
304 constexpr optional_base() noexcept : init_(false), storage_(trivial_init) {}
306 explicit constexpr optional_base(
const T& v) : init_(true), storage_(v) {}
308 explicit constexpr optional_base(T&& v) : init_(true), storage_(constexpr_move(v)) {}
310 template <
class... Args>
explicit optional_base(
in_place_t, Args&&... args)
311 : init_(true), storage_(constexpr_forward<Args>(args)...) {}
313 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(is_constructible<T, std::initializer_list<U>>)>
314 explicit optional_base(
in_place_t, std::initializer_list<U> il, Args&&... args)
315 : init_(true), storage_(il, std::forward<Args>(args)...) {}
317 ~optional_base() {
if (init_) storage_.value_.T::~T(); }
321 struct constexpr_optional_base
324 constexpr_storage_t<T> storage_;
326 constexpr constexpr_optional_base() noexcept : init_(false), storage_(trivial_init) {}
328 explicit constexpr constexpr_optional_base(
const T& v) : init_(true), storage_(v) {}
330 explicit constexpr constexpr_optional_base(T&& v) : init_(true), storage_(constexpr_move(v)) {}
332 template <
class... Args>
explicit constexpr constexpr_optional_base(
in_place_t, Args&&... args)
333 : init_(true), storage_(constexpr_forward<Args>(args)...) {}
335 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(is_constructible<T, std::initializer_list<U>>)>
337 : init_(true), storage_(il, std::forward<Args>(args)...) {}
339 ~constexpr_optional_base() =
default;
343 using OptionalBase =
typename std::conditional<
344 is_trivially_destructible<T>::value,
345 constexpr_optional_base<typename std::remove_const<T>::type>,
346 optional_base<typename std::remove_const<T>::type>
350 class optional :
private OptionalBase<T>
352 static_assert( !std::is_same<
typename std::decay<T>::type,
nullopt_t>::value,
"bad T" );
353 static_assert( !std::is_same<
typename std::decay<T>::type,
in_place_t>::value,
"bad T" );
355 constexpr
bool initialized() const noexcept {
return OptionalBase<T>::init_; }
356 typename std::remove_const<T>::type* dataptr() {
return std::addressof(OptionalBase<T>::storage_.value_); }
357 constexpr
const T* dataptr()
const {
return detail_::static_addressof(OptionalBase<T>::storage_.value_); }
359 # if OPTIONAL_HAS_THIS_RVALUE_REFS == 1
360 constexpr
const T& contained_val() const& {
return OptionalBase<T>::storage_.value_; }
361 # if OPTIONAL_HAS_MOVE_ACCESSORS == 1
365 T& contained_val() & {
return OptionalBase<T>::storage_.value_; }
366 T&& contained_val() && {
return std::move(OptionalBase<T>::storage_.value_); }
369 constexpr
const T& contained_val()
const {
return OptionalBase<T>::storage_.value_; }
370 T& contained_val() {
return OptionalBase<T>::storage_.value_; }
373 void clear() noexcept {
374 if (initialized()) dataptr()->T::~T();
375 OptionalBase<T>::init_ =
false;
378 template <
class... Args>
379 void initialize(Args&&... args) noexcept(noexcept(T(std::forward<Args>(args)...)))
381 assert(!OptionalBase<T>::init_);
382 ::new (
static_cast<void*
>(dataptr())) T(std::forward<Args>(args)...);
383 OptionalBase<T>::init_ = true;
386 template <class U, class... Args>
387 void initialize(std::initializer_list<U> il, Args&&... args) noexcept(noexcept(T(il, std::forward<Args>(args)...)))
389 assert(!OptionalBase<T>::init_);
390 ::new (
static_cast<void*
>(dataptr())) T(il, std::forward<Args>(args)...);
391 OptionalBase<T>::init_ = true;
395 typedef T value_type;
398 constexpr
optional() noexcept : OptionalBase<T>() {}
404 if (rhs.initialized()) {
405 ::new (
static_cast<void*
>(dataptr())) T(*rhs);
406 OptionalBase<T>::init_ = true;
413 if (rhs.initialized()) {
414 ::new (
static_cast<void*
>(dataptr())) T(std::move(*rhs));
415 OptionalBase<T>::init_ = true;
419 constexpr
optional(const T& v) : OptionalBase<T>(v) {}
421 constexpr
optional(T&& v) : OptionalBase<T>(constexpr_move(v)) {}
423 template <
class... Args>
425 : OptionalBase<T>(
in_place_t{}, constexpr_forward<Args>(args)...) {}
427 template <
class U,
class... Args,
TR2_OPTIONAL_REQUIRES(is_constructible<T, std::initializer_list<U>>)>
429 : OptionalBase<T>(
in_place_t{}, il, constexpr_forward<Args>(args)...) {}
443 if (initialized() ==
true && rhs.initialized() ==
false) clear();
444 else if (initialized() ==
false && rhs.initialized() ==
true)
initialize(*rhs);
445 else if (initialized() ==
true && rhs.initialized() ==
true) contained_val() = *rhs;
450 noexcept(is_nothrow_move_assignable<T>::value && is_nothrow_move_constructible<T>::value)
452 if (initialized() ==
true && rhs.initialized() ==
false) clear();
453 else if (initialized() ==
false && rhs.initialized() ==
true)
initialize(std::move(*rhs));
454 else if (initialized() ==
true && rhs.initialized() ==
true) contained_val() = std::move(*rhs);
459 auto operator=(U&& v)
460 ->
typename enable_if
462 is_same<typename decay<U>::type, T>::value,
466 if (initialized()) { contained_val() = std::forward<U>(v); }
471 template <
class... Args>
472 void emplace(Args&&... args)
478 template <
class U,
class... Args>
479 void emplace(initializer_list<U> il, Args&&... args)
482 initialize<U, Args...>(il, std::forward<Args>(args)...);
486 void swap(optional<T>& rhs) noexcept(is_nothrow_move_constructible<T>::value && noexcept(swap(declval<T&>(), declval<T&>())))
488 if (initialized() ==
true && rhs.initialized() ==
false) { rhs.initialize(std::move(**
this)); clear(); }
489 else if (initialized() ==
false && rhs.initialized() ==
true) {
initialize(std::move(*rhs)); rhs.clear(); }
490 else if (initialized() ==
true && rhs.initialized() ==
true) {
using std::swap; swap(**
this, *rhs); }
495 explicit constexpr
operator bool() const noexcept {
return initialized(); }
496 constexpr
bool has_value() const noexcept {
return initialized(); }
498 constexpr T
const* operator ->()
const {
502 # if OPTIONAL_HAS_MOVE_ACCESSORS == 1
505 assert (initialized());
509 constexpr T
const& operator *() const& {
514 assert (initialized());
515 return contained_val();
519 assert (initialized());
520 return constexpr_move(contained_val());
523 constexpr T
const& value() const& {
524 return initialized() ? contained_val() : (throw
bad_optional_access(
"bad optional access"), contained_val());
528 return initialized() ? contained_val() : (throw
bad_optional_access(
"bad optional access"), contained_val());
533 return std::move(contained_val());
539 assert (initialized());
546 #if defined(__clang__)
547 # pragma clang diagnostic push
548 # pragma clang diagnostic ignored "-Wconversion"
550 constexpr T
const& operator *()
const {
554 #if defined(__clang__)
555 # pragma clang diagnostic pop
559 assert (initialized());
560 return contained_val();
564 # pragma warning(push)
565 # pragma warning(disable:4702) // unreachable code
567 constexpr T
const& value()
const {
568 return initialized() ? contained_val() : (throw
bad_optional_access(
"bad optional access"), contained_val());
572 return initialized() ? contained_val() : (throw
bad_optional_access(
"bad optional access"), contained_val());
576 # pragma warning(pop)
581 # if OPTIONAL_HAS_THIS_RVALUE_REFS == 1
584 constexpr T value_or(V&& v)
const&
586 return *
this ? **this : detail_::convert<T>(constexpr_forward<V>(v));
589 # if OPTIONAL_HAS_MOVE_ACCESSORS == 1
594 return *
this ? constexpr_move(
const_cast<optional<T>&
>(*this).contained_val()) : detail_::convert<T>(constexpr_forward<V>(v));
602 return *
this ? constexpr_move(
const_cast<optional<T>&
>(*this).contained_val()) : detail_::convert<T>(constexpr_forward<V>(v));
610 constexpr T value_or(V&& v)
const
612 return *
this ? **this : detail_::convert<T>(constexpr_forward<V>(v));
618 void reset() noexcept { clear(); }
624 static_assert( !std::is_same<T, nullopt_t>::value,
"bad T" );
625 static_assert( !std::is_same<T, in_place_t>::value,
"bad T" );
631 constexpr
optional() noexcept : ref(
nullptr) {}
635 constexpr
optional(T& v) noexcept : ref(detail_::static_addressof(v)) {}
641 explicit constexpr
optional(
in_place_t, T& v) noexcept : ref(detail_::static_addressof(v)) {}
663 template <
typename U>
664 auto operator=(U&& rhs) noexcept
665 ->
typename enable_if
667 is_same<typename decay<U>::type, optional<T&>>::value,
675 template <
typename U>
676 auto operator=(U&& rhs) noexcept
677 ->
typename enable_if
679 !is_same<typename decay<U>::type, optional<T&>>::value,
684 void emplace(T& v) noexcept {
685 ref = detail_::static_addressof(v);
688 void emplace(T&&) =
delete;
690 void swap(optional<T&>& rhs) noexcept
692 std::swap(ref, rhs.ref);
696 constexpr T* operator->()
const {
700 constexpr T& operator*()
const {
704 constexpr T& value()
const {
708 explicit constexpr
operator bool() const noexcept {
709 return ref !=
nullptr;
712 constexpr
bool has_value() const noexcept {
713 return ref !=
nullptr;
717 constexpr
typename decay<T>::type value_or(V&& v)
const
719 return *
this ? **this : detail_::convert<typename decay<T>::type>(constexpr_forward<V>(v));
723 void reset() noexcept { ref =
nullptr; }
729 static_assert(
sizeof(T) == 0,
"optional rvalue references disallowed" );
733 template <
class T> constexpr
bool operator==(
const optional<T>& x,
const optional<T>& y)
735 return bool(x) != bool(y) ? false : bool(x) ==
false ? true : *x == *y;
738 template <
class T> constexpr
bool operator!=(
const optional<T>& x,
const optional<T>& y)
743 template <
class T> constexpr
bool operator<(
const optional<T>& x,
const optional<T>& y)
745 return (!y) ? false : (!x) ?
true : *x < *y;
748 template <
class T> constexpr
bool operator>(
const optional<T>& x,
const optional<T>& y)
753 template <
class T> constexpr
bool operator<=(
const optional<T>& x,
const optional<T>& y)
758 template <
class T> constexpr
bool operator>=(
const optional<T>& x,
const optional<T>& y)
825 template <
class T> constexpr
bool operator==(
const optional<T>& x,
const T& v)
827 return bool(x) ? *x == v :
false;
830 template <
class T> constexpr
bool operator==(
const T& v,
const optional<T>& x)
832 return bool(x) ? v == *x :
false;
835 template <
class T> constexpr
bool operator!=(
const optional<T>& x,
const T& v)
837 return bool(x) ? *x != v :
true;
840 template <
class T> constexpr
bool operator!=(
const T& v,
const optional<T>& x)
842 return bool(x) ? v != *x :
true;
845 template <
class T> constexpr
bool operator<(
const optional<T>& x,
const T& v)
847 return bool(x) ? *x < v :
true;
850 template <
class T> constexpr
bool operator>(
const T& v,
const optional<T>& x)
852 return bool(x) ? v > *x :
true;
855 template <
class T> constexpr
bool operator>(
const optional<T>& x,
const T& v)
857 return bool(x) ? *x > v :
false;
860 template <
class T> constexpr
bool operator<(
const T& v,
const optional<T>& x)
862 return bool(x) ? v < *x :
false;
865 template <
class T> constexpr
bool operator>=(
const optional<T>& x,
const T& v)
867 return bool(x) ? *x >= v :
false;
870 template <
class T> constexpr
bool operator<=(
const T& v,
const optional<T>& x)
872 return bool(x) ? v <= *x :
false;
875 template <
class T> constexpr
bool operator<=(
const optional<T>& x,
const T& v)
877 return bool(x) ? *x <= v :
true;
880 template <
class T> constexpr
bool operator>=(
const T& v,
const optional<T>& x)
882 return bool(x) ? v >= *x :
true;
886 template <
class T> constexpr
bool operator==(
const optional<T&>& x,
const T& v)
888 return bool(x) ? *x == v :
false;
891 template <
class T> constexpr
bool operator==(
const T& v,
const optional<T&>& x)
893 return bool(x) ? v == *x :
false;
896 template <
class T> constexpr
bool operator!=(
const optional<T&>& x,
const T& v)
898 return bool(x) ? *x != v :
true;
901 template <
class T> constexpr
bool operator!=(
const T& v,
const optional<T&>& x)
903 return bool(x) ? v != *x :
true;
906 template <
class T> constexpr
bool operator<(
const optional<T&>& x,
const T& v)
908 return bool(x) ? *x < v :
true;
911 template <
class T> constexpr
bool operator>(
const T& v,
const optional<T&>& x)
913 return bool(x) ? v > *x :
true;
916 template <
class T> constexpr
bool operator>(
const optional<T&>& x,
const T& v)
918 return bool(x) ? *x > v :
false;
921 template <
class T> constexpr
bool operator<(
const T& v,
const optional<T&>& x)
923 return bool(x) ? v < *x :
false;
926 template <
class T> constexpr
bool operator>=(
const optional<T&>& x,
const T& v)
928 return bool(x) ? *x >= v :
false;
931 template <
class T> constexpr
bool operator<=(
const T& v,
const optional<T&>& x)
933 return bool(x) ? v <= *x :
false;
936 template <
class T> constexpr
bool operator<=(
const optional<T&>& x,
const T& v)
938 return bool(x) ? *x <= v :
true;
941 template <
class T> constexpr
bool operator>=(
const T& v,
const optional<T&>& x)
943 return bool(x) ? v >= *x :
true;
947 template <
class T> constexpr
bool operator==(
const optional<const T&>& x,
const T& v)
949 return bool(x) ? *x == v :
false;
952 template <
class T> constexpr
bool operator==(
const T& v,
const optional<const T&>& x)
954 return bool(x) ? v == *x :
false;
957 template <
class T> constexpr
bool operator!=(
const optional<const T&>& x,
const T& v)
959 return bool(x) ? *x != v :
true;
962 template <
class T> constexpr
bool operator!=(
const T& v,
const optional<const T&>& x)
964 return bool(x) ? v != *x :
true;
967 template <
class T> constexpr
bool operator<(
const optional<const T&>& x,
const T& v)
969 return bool(x) ? *x < v :
true;
972 template <
class T> constexpr
bool operator>(
const T& v,
const optional<const T&>& x)
974 return bool(x) ? v > *x :
true;
977 template <
class T> constexpr
bool operator>(
const optional<const T&>& x,
const T& v)
979 return bool(x) ? *x > v :
false;
982 template <
class T> constexpr
bool operator<(
const T& v,
const optional<const T&>& x)
984 return bool(x) ? v < *x :
false;
987 template <
class T> constexpr
bool operator>=(
const optional<const T&>& x,
const T& v)
989 return bool(x) ? *x >= v :
false;
992 template <
class T> constexpr
bool operator<=(
const T& v,
const optional<const T&>& x)
994 return bool(x) ? v <= *x :
false;
997 template <
class T> constexpr
bool operator<=(
const optional<const T&>& x,
const T& v)
999 return bool(x) ? *x <= v :
true;
1002 template <
class T> constexpr
bool operator>=(
const T& v,
const optional<const T&>& x)
1004 return bool(x) ? v >= *x :
true;
1009 void swap(optional<T>& x, optional<T>& y) noexcept(noexcept(x.swap(y)))
1015 constexpr optional<typename decay<T>::type> make_optional(T&& v)
1017 return optional<typename decay<T>::type>(constexpr_forward<T>(v));
1021 constexpr optional<X&> make_optional(reference_wrapper<X> v)
1023 return optional<X&>(v.get());
1032 template <
typename T>
1035 typedef typename hash<T>::result_type result_type;
1036 typedef std::experimental::Ice::optional<T> argument_type;
1038 constexpr result_type operator()(argument_type
const& arg)
const {
1039 return arg ? std::hash<T>{}(*arg) : result_type{};
1043 template <
typename T>
1046 typedef typename hash<T>::result_type result_type;
1047 typedef std::experimental::Ice::optional<T&> argument_type;
1049 constexpr result_type operator()(argument_type
const& arg)
const {
1050 return arg ? std::hash<T>{}(*arg) : result_type{};
1055 # undef TR2_OPTIONAL_REQUIRES
1056 # undef TR2_OPTIONAL_ASSERTED_EXPRESSION
1065 template<
class T>
using optional = std::experimental::Ice::optional<T>;
1067 using std::experimental::Ice::operator==;
1068 using std::experimental::Ice::operator!=;
1069 using std::experimental::Ice::operator<;
1070 using std::experimental::Ice::operator<=;
1071 using std::experimental::Ice::operator>;
1072 using std::experimental::Ice::operator>=;
1075 using std::experimental::Ice::make_optional;
1077 using std::experimental::Ice::swap;
1082 using std::experimental::Ice::nullopt;
1090 using std::experimental::Ice::in_place;
1100 template<
class T>
using Optional = std::experimental::Ice::optional<T>;
1108 #else // C++98 mapping