Drake
drake_optional.h
Go to the documentation of this file.
1 #pragma once
2 
3 // As of our currently supported platforms (Ubuntu 16.04 Xenial and macOS 10.13
4 // High Sierra), the std::experimental::optional implementations for libstdc++
5 // and libc++ lack some C++17 features, such as std::optional::has_value() or
6 // std::bad_optional_acces. Thus, we'll force-enable the STX implementation
7 // for now. In the future if some new platform has C++17 support, we'll want
8 // to allow this to fallback to use it.
9 #define STX_NO_STD_OPTIONAL
10 
11 #include <stx/optional.hpp>
12 
13 /// @file
14 /// Provides drake::optional as an alias for the appropriate implementation of
15 /// std::optional or std::experimental::optional or stx::optional for the C++
16 /// toolchain being used. (The alias is selected preferentially in that order,
17 /// so the most widely-compatible implementation will always be used.)
18 
19 namespace drake {
20 
21 template <typename T>
22 using optional = stx::optional<T>;
23 
24 constexpr auto nullopt = stx::nullopt;
25 
26 } // namespace drake
Definition: automotive_demo.cc:90
stx::optional< T > optional
Definition: drake_optional.h:22
constexpr auto nullopt
Definition: drake_optional.h:24