Drake
drake_optional_pybind.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "pybind11/stl.h"
4 
5 // TODO(eric.cousineau): Merge this with `pydrake_pybind` when it is available
6 // (#7829).
8 
9 #ifdef STX_NO_STD_OPTIONAL
10 
11 namespace pybind11 {
12 namespace detail {
13 
14 // Ensure that we expose a type_caster for `stx::optional`.
15 // @see pybind11/stl.h, `optional_caster`.
16 
17 template <typename T>
18 struct type_caster<stx::optional<T>> :
19  public optional_caster<stx::optional<T>> {};
20 
21 template<>
22 struct type_caster<stx::nullopt_t> :
23  public void_caster<stx::nullopt_t> {};
24 
25 } // namespace detail
26 } // namespace pybind11
27 
28 #endif // STX_NO_STD_OPTIONAL
Definition: eigen_geometry_pybind.h:106
stx::optional< T > optional
Definition: drake_optional.h:22
Provides drake::optional as an alias for the appropriate implementation of std::optional or std::expe...