proxsuite
0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
optional.hpp
Go to the documentation of this file.
1
//
2
// Copyright (c) 2022 INRIA
3
//
8
#ifndef PROXSUITE_HELPERS_OPTIONAL_HPP
9
#define PROXSUITE_HELPERS_OPTIONAL_HPP
10
11
#include <
proxsuite/fwd.hpp
>
12
13
#ifdef PROXSUITE_WITH_CPP_17
14
#include <optional>
15
#else
16
#include <
proxsuite/helpers/tl-optional.hpp
>
17
#endif
18
19
namespace
proxsuite
{
20
#ifdef PROXSUITE_WITH_CPP_17
21
template
<
class
T>
22
using
optional
= std::optional<T>;
23
using
nullopt_t
= std::nullopt_t;
24
inline
constexpr
nullopt_t
nullopt
= std::nullopt;
25
#else
26
namespace
detail {
27
// Source boost: https://www.boost.org/doc/libs/1_74_0/boost/none.hpp
28
// the trick here is to make instance defined once as a global but in a header
29
// file
30
template
<
typename
T>
31
struct
nullopt_instance
32
{
33
static
const
T
instance
;
34
};
35
template
<
typename
T>
36
const
T
nullopt_instance<T>::instance
=
37
T(
tl::nullopt
);
// global, but because 'tis a template, no cpp file required
38
}
// namespace detail
39
template
<
class
T>
40
using
optional
=
tl::optional<T>
;
41
using
nullopt_t
=
tl::nullopt_t
;
42
constexpr
nullopt_t
nullopt
=
detail::nullopt_instance<tl::nullopt_t>::instance
;
43
#endif
44
}
// namespace proxsuite
45
46
#endif
/* end of include guard PROXSUITE_HELPERS_OPTIONAL_HPP */
tl::optional
Definition
tl-optional.hpp:815
fwd.hpp
proxsuite
Definition
common.hpp:14
proxsuite::nullopt
constexpr nullopt_t nullopt
Definition
optional.hpp:42
proxsuite::nullopt_t
tl::nullopt_t nullopt_t
Definition
optional.hpp:41
proxsuite::optional
tl::optional< T > optional
Definition
optional.hpp:40
tl::nullopt
static constexpr nullopt_t nullopt
Represents an empty optional.
Definition
tl-optional.hpp:794
proxsuite::detail::nullopt_instance
Definition
optional.hpp:32
proxsuite::detail::nullopt_instance::instance
static const T instance
Definition
optional.hpp:33
tl::nullopt_t
A tag type to represent an empty optional.
Definition
tl-optional.hpp:788
tl-optional.hpp
include
proxsuite
helpers
optional.hpp
Generated by
1.10.0