test_stl.cpp
Go to the documentation of this file.
1 /*
2  tests/test_stl.cpp -- STL type casters
3 
4  Copyright (c) 2017 Wenzel Jakob <wenzel.jakob@epfl.ch>
5 
6  All rights reserved. Use of this source code is governed by a
7  BSD-style license that can be found in the LICENSE file.
8 */
9 
10 #include <pybind11/stl.h>
11 
12 #include "constructor_stats.h"
13 #include "pybind11_tests.h"
14 
15 #ifndef PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
16 # define PYBIND11_HAS_FILESYSTEM_IS_OPTIONAL
17 #endif
19 
20 #include <string>
21 #include <vector>
22 
23 #if defined(PYBIND11_TEST_BOOST)
24 # include <boost/optional.hpp>
25 
26 namespace PYBIND11_NAMESPACE {
27 namespace detail {
28 template <typename T>
29 struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
30 
31 template <>
32 struct type_caster<boost::none_t> : void_caster<boost::none_t> {};
33 } // namespace detail
34 } // namespace PYBIND11_NAMESPACE
35 #endif
36 
37 // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14
38 #if defined(PYBIND11_HAS_VARIANT)
39 using std::variant;
40 # define PYBIND11_TEST_VARIANT 1
41 #elif defined(PYBIND11_TEST_BOOST)
42 # include <boost/variant.hpp>
43 # define PYBIND11_TEST_VARIANT 1
44 using boost::variant;
45 
46 namespace PYBIND11_NAMESPACE {
47 namespace detail {
48 template <typename... Ts>
49 struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
50 
51 template <>
52 struct visit_helper<boost::variant> {
53  template <typename... Args>
54  static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) {
55  return boost::apply_visitor(args...);
56  }
57 };
58 } // namespace detail
59 } // namespace PYBIND11_NAMESPACE
60 #endif
61 
62 PYBIND11_MAKE_OPAQUE(std::vector<std::string, std::allocator<std::string>>);
63 
65 struct TplCtorClass {
66  template <typename T>
67  explicit TplCtorClass(const T &) {}
68  bool operator==(const TplCtorClass &) const { return true; }
69 };
70 
71 namespace std {
72 template <>
73 struct hash<TplCtorClass> {
74  size_t operator()(const TplCtorClass &) const { return 0; }
75 };
76 } // namespace std
77 
78 template <template <typename> class OptionalImpl, typename T>
80  // NOLINTNEXTLINE(modernize-use-equals-default): breaks GCC 4.8
82  bool member_initialized() const { return member && member->initialized; }
83  OptionalImpl<T> member = T{};
84 };
85 
86 enum class EnumType {
87  kSet = 42,
88  kUnset = 85,
89 };
90 
91 // This is used to test that return-by-ref and return-by-copy policies are
92 // handled properly for optional types. This is a regression test for a dangling
93 // reference issue. The issue seemed to require the enum value type to
94 // reproduce - it didn't seem to happen if the value type is just an integer.
95 template <template <typename> class OptionalImpl>
97 public:
98  using OptionalEnumValue = OptionalImpl<EnumType>;
99 
102  // Reset value to detect use-after-destruction.
103  // This is set to a specific value rather than nullopt to ensure that
104  // the memory that contains the value gets re-written.
106  }
107 
110 
111 private:
113 };
114 
115 // This type mimics aspects of boost::optional from old versions of Boost,
116 // which exposed a dangling reference bug in Pybind11. Recent versions of
117 // boost::optional, as well as libstdc++'s std::optional, don't seem to be
118 // affected by the same issue. This is meant to be a minimal implementation
119 // required to reproduce the issue, not fully standard-compliant.
120 // See issue #3330 for more details.
121 template <typename T>
123 public:
124  using value_type = T;
125 
126  ReferenceSensitiveOptional() = default;
127  // NOLINTNEXTLINE(google-explicit-constructor)
129  // NOLINTNEXTLINE(google-explicit-constructor)
132  storage = {value};
133  return *this;
134  }
136  storage = {std::move(value)};
137  return *this;
138  }
139 
140  template <typename... Args>
141  T &emplace(Args &&...args) {
142  storage.clear();
143  storage.emplace_back(std::forward<Args>(args)...);
144  return storage.back();
145  }
146 
147  const T &value() const noexcept {
148  assert(!storage.empty());
149  return storage[0];
150  }
151 
152  const T &operator*() const noexcept { return value(); }
153 
154  const T *operator->() const noexcept { return &value(); }
155 
156  explicit operator bool() const noexcept { return !storage.empty(); }
157 
158 private:
159  std::vector<T> storage;
160 };
161 
162 namespace PYBIND11_NAMESPACE {
163 namespace detail {
164 template <typename T>
166  : optional_caster<ReferenceSensitiveOptional<T>> {};
167 } // namespace detail
168 } // namespace PYBIND11_NAMESPACE
169 
171  // test_vector
172  m.def("cast_vector", []() { return std::vector<int>{1}; });
173  m.def("load_vector", [](const std::vector<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
174  // `std::vector<bool>` is special because it returns proxy objects instead of references
175  m.def("cast_bool_vector", []() { return std::vector<bool>{true, false}; });
176  m.def("load_bool_vector",
177  [](const std::vector<bool> &v) { return v.at(0) == true && v.at(1) == false; });
178  // Unnumbered regression (caused by #936): pointers to stl containers aren't castable
179  m.def(
180  "cast_ptr_vector",
181  []() {
182  // Using no-destructor idiom to side-step warnings from overzealous compilers.
183  static auto *v = new std::vector<RValueCaster>{2};
184  return v;
185  },
186  py::return_value_policy::reference);
187 
188  // test_deque
189  m.def("cast_deque", []() { return std::deque<int>{1}; });
190  m.def("load_deque", [](const std::deque<int> &v) { return v.at(0) == 1 && v.at(1) == 2; });
191 
192  // test_array
193  m.def("cast_array", []() { return std::array<int, 2>{{1, 2}}; });
194  m.def("load_array", [](const std::array<int, 2> &a) { return a[0] == 1 && a[1] == 2; });
195 
196  // test_valarray
197  m.def("cast_valarray", []() { return std::valarray<int>{1, 4, 9}; });
198  m.def("load_valarray", [](const std::valarray<int> &v) {
199  return v.size() == 3 && v[0] == 1 && v[1] == 4 && v[2] == 9;
200  });
201 
202  // test_map
203  m.def("cast_map", []() { return std::map<std::string, std::string>{{"key", "value"}}; });
204  m.def("load_map", [](const std::map<std::string, std::string> &map) {
205  return map.at("key") == "value" && map.at("key2") == "value2";
206  });
207 
208  // test_set
209  m.def("cast_set", []() { return std::set<std::string>{"key1", "key2"}; });
210  m.def("load_set", [](const std::set<std::string> &set) {
211  return (set.count("key1") != 0u) && (set.count("key2") != 0u) && (set.count("key3") != 0u);
212  });
213 
214  // test_recursive_casting
215  m.def("cast_rv_vector", []() { return std::vector<RValueCaster>{2}; });
216  m.def("cast_rv_array", []() { return std::array<RValueCaster, 3>(); });
217  // NB: map and set keys are `const`, so while we technically do move them (as `const Type &&`),
218  // casters don't typically do anything with that, which means they fall to the `const Type &`
219  // caster.
220  m.def("cast_rv_map", []() {
221  return std::unordered_map<std::string, RValueCaster>{{"a", RValueCaster{}}};
222  });
223  m.def("cast_rv_nested", []() {
224  std::vector<std::array<std::list<std::unordered_map<std::string, RValueCaster>>, 2>> v;
225  v.emplace_back(); // add an array
226  v.back()[0].emplace_back(); // add a map to the array
227  v.back()[0].back().emplace("b", RValueCaster{});
228  v.back()[0].back().emplace("c", RValueCaster{});
229  v.back()[1].emplace_back(); // add a map to the array
230  v.back()[1].back().emplace("a", RValueCaster{});
231  return v;
232  });
233  static std::array<RValueCaster, 2> lva;
234  static std::unordered_map<std::string, RValueCaster> lvm{{"a", RValueCaster{}},
235  {"b", RValueCaster{}}};
236  static std::unordered_map<std::string, std::vector<std::list<std::array<RValueCaster, 2>>>>
237  lvn;
238  lvn["a"].emplace_back(); // add a list
239  lvn["a"].back().emplace_back(); // add an array
240  lvn["a"].emplace_back(); // another list
241  lvn["a"].back().emplace_back(); // add an array
242  lvn["b"].emplace_back(); // add a list
243  lvn["b"].back().emplace_back(); // add an array
244  lvn["b"].back().emplace_back(); // add another array
245  static std::vector<RValueCaster> lvv{2};
246  m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
247  m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
248  m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });
249  m.def("cast_lv_nested", []() -> const decltype(lvn) & { return lvn; });
250  // #853:
251  m.def("cast_unique_ptr_vector", []() {
252  std::vector<std::unique_ptr<UserType>> v;
253  v.emplace_back(new UserType{7});
254  v.emplace_back(new UserType{42});
255  return v;
256  });
257 
258  pybind11::enum_<EnumType>(m, "EnumType")
259  .value("kSet", EnumType::kSet)
260  .value("kUnset", EnumType::kUnset);
261 
262  // test_move_out_container
263  struct MoveOutContainer {
264  struct Value {
265  int value;
266  };
267  std::list<Value> move_list() const { return {{0}, {1}, {2}}; }
268  };
269  py::class_<MoveOutContainer::Value>(m, "MoveOutContainerValue")
270  .def_readonly("value", &MoveOutContainer::Value::value);
271  py::class_<MoveOutContainer>(m, "MoveOutContainer")
272  .def(py::init<>())
273  .def_property_readonly("move_list", &MoveOutContainer::move_list);
274 
275  // Class that can be move- and copy-constructed, but not assigned
276  struct NoAssign {
277  int value;
278 
279  explicit NoAssign(int value = 0) : value(value) {}
280  NoAssign(const NoAssign &) = default;
281  NoAssign(NoAssign &&) = default;
282 
283  NoAssign &operator=(const NoAssign &) = delete;
284  NoAssign &operator=(NoAssign &&) = delete;
285  };
286  py::class_<NoAssign>(m, "NoAssign", "Class with no C++ assignment operators")
287  .def(py::init<>())
288  .def(py::init<int>());
289 
290  struct MoveOutDetector {
291  MoveOutDetector() = default;
292  MoveOutDetector(const MoveOutDetector &) = default;
293  MoveOutDetector(MoveOutDetector &&other) noexcept : initialized(other.initialized) {
294  // steal underlying resource
295  other.initialized = false;
296  }
297  bool initialized = true;
298  };
299  py::class_<MoveOutDetector>(m, "MoveOutDetector", "Class with move tracking")
300  .def(py::init<>())
301  .def_readonly("initialized", &MoveOutDetector::initialized);
302 
303 #ifdef PYBIND11_HAS_OPTIONAL
304  // test_optional
305  m.attr("has_optional") = true;
306 
307  using opt_int = std::optional<int>;
308  using opt_no_assign = std::optional<NoAssign>;
309  m.def("double_or_zero", [](const opt_int &x) -> int { return x.value_or(0) * 2; });
310  m.def("half_or_none", [](int x) -> opt_int { return x != 0 ? opt_int(x / 2) : opt_int(); });
311  m.def(
312  "test_nullopt",
313  [](opt_int x) { return x.value_or(42); },
314  py::arg_v("x", std::nullopt, "None"));
315  m.def(
316  "test_no_assign",
317  [](const opt_no_assign &x) { return x ? x->value : 42; },
318  py::arg_v("x", std::nullopt, "None"));
319 
320  m.def("nodefer_none_optional", [](std::optional<int>) { return true; });
321  m.def("nodefer_none_optional", [](const py::none &) { return false; });
322 
324  py::class_<opt_holder>(m, "OptionalHolder", "Class with optional member")
325  .def(py::init<>())
326  .def_readonly("member", &opt_holder::member)
327  .def("member_initialized", &opt_holder::member_initialized);
328 
329  using opt_props = OptionalProperties<std::optional>;
330  pybind11::class_<opt_props>(m, "OptionalProperties")
331  .def(pybind11::init<>())
332  .def_property_readonly("access_by_ref", &opt_props::access_by_ref)
333  .def_property_readonly("access_by_copy", &opt_props::access_by_copy);
334 #endif
335 
336 #ifdef PYBIND11_HAS_EXP_OPTIONAL
337  // test_exp_optional
338  m.attr("has_exp_optional") = true;
339 
340  using exp_opt_int = std::experimental::optional<int>;
341  using exp_opt_no_assign = std::experimental::optional<NoAssign>;
342  m.def("double_or_zero_exp", [](const exp_opt_int &x) -> int { return x.value_or(0) * 2; });
343  m.def("half_or_none_exp",
344  [](int x) -> exp_opt_int { return x ? exp_opt_int(x / 2) : exp_opt_int(); });
345  m.def(
346  "test_nullopt_exp",
347  [](exp_opt_int x) { return x.value_or(42); },
348  py::arg_v("x", std::experimental::nullopt, "None"));
349  m.def(
350  "test_no_assign_exp",
351  [](const exp_opt_no_assign &x) { return x ? x->value : 42; },
352  py::arg_v("x", std::experimental::nullopt, "None"));
353 
355  py::class_<opt_exp_holder>(m, "OptionalExpHolder", "Class with optional member")
356  .def(py::init<>())
357  .def_readonly("member", &opt_exp_holder::member)
358  .def("member_initialized", &opt_exp_holder::member_initialized);
359 
361  pybind11::class_<opt_exp_props>(m, "OptionalExpProperties")
362  .def(pybind11::init<>())
363  .def_property_readonly("access_by_ref", &opt_exp_props::access_by_ref)
364  .def_property_readonly("access_by_copy", &opt_exp_props::access_by_copy);
365 #endif
366 
367 #if defined(PYBIND11_TEST_BOOST)
368  // test_boost_optional
369  m.attr("has_boost_optional") = true;
370 
371  using boost_opt_int = boost::optional<int>;
372  using boost_opt_no_assign = boost::optional<NoAssign>;
373  m.def("double_or_zero_boost", [](const boost_opt_int &x) -> int { return x.value_or(0) * 2; });
374  m.def("half_or_none_boost",
375  [](int x) -> boost_opt_int { return x != 0 ? boost_opt_int(x / 2) : boost_opt_int(); });
376  m.def(
377  "test_nullopt_boost",
378  [](boost_opt_int x) { return x.value_or(42); },
379  py::arg_v("x", boost::none, "None"));
380  m.def(
381  "test_no_assign_boost",
382  [](const boost_opt_no_assign &x) { return x ? x->value : 42; },
383  py::arg_v("x", boost::none, "None"));
384 
385  using opt_boost_holder = OptionalHolder<boost::optional, MoveOutDetector>;
386  py::class_<opt_boost_holder>(m, "OptionalBoostHolder", "Class with optional member")
387  .def(py::init<>())
388  .def_readonly("member", &opt_boost_holder::member)
389  .def("member_initialized", &opt_boost_holder::member_initialized);
390 
391  using opt_boost_props = OptionalProperties<boost::optional>;
392  pybind11::class_<opt_boost_props>(m, "OptionalBoostProperties")
393  .def(pybind11::init<>())
394  .def_property_readonly("access_by_ref", &opt_boost_props::access_by_ref)
395  .def_property_readonly("access_by_copy", &opt_boost_props::access_by_copy);
396 #endif
397 
398  // test_refsensitive_optional
399  using refsensitive_opt_int = ReferenceSensitiveOptional<int>;
400  using refsensitive_opt_no_assign = ReferenceSensitiveOptional<NoAssign>;
401  m.def("double_or_zero_refsensitive",
402  [](const refsensitive_opt_int &x) -> int { return (x ? x.value() : 0) * 2; });
403  m.def("half_or_none_refsensitive", [](int x) -> refsensitive_opt_int {
404  return x != 0 ? refsensitive_opt_int(x / 2) : refsensitive_opt_int();
405  });
406  m.def(
407  "test_nullopt_refsensitive",
408  // NOLINTNEXTLINE(performance-unnecessary-value-param)
409  [](refsensitive_opt_int x) { return x ? x.value() : 42; },
410  py::arg_v("x", refsensitive_opt_int(), "None"));
411  m.def(
412  "test_no_assign_refsensitive",
413  [](const refsensitive_opt_no_assign &x) { return x ? x->value : 42; },
414  py::arg_v("x", refsensitive_opt_no_assign(), "None"));
415 
416  using opt_refsensitive_holder = OptionalHolder<ReferenceSensitiveOptional, MoveOutDetector>;
417  py::class_<opt_refsensitive_holder>(
418  m, "OptionalRefSensitiveHolder", "Class with optional member")
419  .def(py::init<>())
420  .def_readonly("member", &opt_refsensitive_holder::member)
421  .def("member_initialized", &opt_refsensitive_holder::member_initialized);
422 
423  using opt_refsensitive_props = OptionalProperties<ReferenceSensitiveOptional>;
424  pybind11::class_<opt_refsensitive_props>(m, "OptionalRefSensitiveProperties")
425  .def(pybind11::init<>())
426  .def_property_readonly("access_by_ref", &opt_refsensitive_props::access_by_ref)
427  .def_property_readonly("access_by_copy", &opt_refsensitive_props::access_by_copy);
428 
429 #ifdef PYBIND11_HAS_FILESYSTEM
430  // test_fs_path
431  m.attr("has_filesystem") = true;
432  m.def("parent_path", [](const std::filesystem::path &p) { return p.parent_path(); });
433 #endif
434 
435 #ifdef PYBIND11_TEST_VARIANT
437  "visitor::result_type is required by boost::variant in C++11 mode");
438 
439  struct visitor {
440  using result_type = const char *;
441 
442  result_type operator()(int) { return "int"; }
443  result_type operator()(const std::string &) { return "std::string"; }
444  result_type operator()(double) { return "double"; }
445  result_type operator()(std::nullptr_t) { return "std::nullptr_t"; }
446 # if defined(PYBIND11_HAS_VARIANT)
447  result_type operator()(std::monostate) { return "std::monostate"; }
448 # endif
449  };
450 
451  // test_variant
452  m.def("load_variant", [](const variant<int, std::string, double, std::nullptr_t> &v) {
453  return py::detail::visit_helper<variant>::call(visitor(), v);
454  });
455  m.def("load_variant_2pass", [](variant<double, int> v) {
456  return py::detail::visit_helper<variant>::call(visitor(), v);
457  });
458  m.def("cast_variant", []() {
459  using V = variant<int, std::string>;
460  return py::make_tuple(V(5), V("Hello"));
461  });
462 
463 # if defined(PYBIND11_HAS_VARIANT)
464  // std::monostate tests.
465  m.def("load_monostate_variant",
466  [](const variant<std::monostate, int, std::string> &v) -> const char * {
467  return py::detail::visit_helper<variant>::call(visitor(), v);
468  });
469  m.def("cast_monostate_variant", []() {
470  using V = variant<std::monostate, int, std::string>;
471  return py::make_tuple(V{}, V(5), V("Hello"));
472  });
473 # endif
474 #endif
475 
476  // #528: templated constructor
477  // (no python tests: the test here is that this compiles)
478  m.def("tpl_ctor_vector", [](std::vector<TplCtorClass> &) {});
479  m.def("tpl_ctor_map", [](std::unordered_map<TplCtorClass, TplCtorClass> &) {});
480  m.def("tpl_ctor_set", [](std::unordered_set<TplCtorClass> &) {});
481 #if defined(PYBIND11_HAS_OPTIONAL)
482  m.def("tpl_constr_optional", [](std::optional<TplCtorClass> &) {});
483 #endif
484 #if defined(PYBIND11_HAS_EXP_OPTIONAL)
485  m.def("tpl_constr_optional_exp", [](std::experimental::optional<TplCtorClass> &) {});
486 #endif
487 #if defined(PYBIND11_TEST_BOOST)
488  m.def("tpl_constr_optional_boost", [](boost::optional<TplCtorClass> &) {});
489 #endif
490 
491  // test_vec_of_reference_wrapper
492  // #171: Can't return STL structures containing reference wrapper
493  m.def("return_vec_of_reference_wrapper", [](std::reference_wrapper<UserType> p4) {
494  static UserType p1{1}, p2{2}, p3{3};
495  return std::vector<std::reference_wrapper<UserType>>{
497  });
498 
499  // test_stl_pass_by_pointer
500  m.def(
501  "stl_pass_by_pointer", [](std::vector<int> *v) { return *v; }, "v"_a = nullptr);
502 
503  // #1258: pybind11/stl.h converts string to vector<string>
504  m.def("func_with_string_or_vector_string_arg_overload",
505  [](const std::vector<std::string> &) { return 1; });
506  m.def("func_with_string_or_vector_string_arg_overload",
507  [](const std::list<std::string> &) { return 2; });
508  m.def("func_with_string_or_vector_string_arg_overload", [](const std::string &) { return 3; });
509 
510  class Placeholder {
511  public:
512  Placeholder() { print_created(this); }
513  Placeholder(const Placeholder &) = delete;
514  ~Placeholder() { print_destroyed(this); }
515  };
516  py::class_<Placeholder>(m, "Placeholder");
517 
519  m.def(
520  "test_stl_ownership",
521  []() {
522  std::vector<Placeholder *> result;
523  result.push_back(new Placeholder());
524  return result;
525  },
526  py::return_value_policy::take_ownership);
527 
528  m.def("array_cast_sequence", [](std::array<int, 3> x) { return x; });
529 
531  struct Issue1561Inner {
532  std::string data;
533  };
534  struct Issue1561Outer {
535  std::vector<Issue1561Inner> list;
536  };
537 
538  py::class_<Issue1561Inner>(m, "Issue1561Inner")
539  .def(py::init<std::string>())
540  .def_readwrite("data", &Issue1561Inner::data);
541 
542  py::class_<Issue1561Outer>(m, "Issue1561Outer")
543  .def(py::init<>())
544  .def_readwrite("list", &Issue1561Outer::list);
545 
546  m.def(
547  "return_vector_bool_raw_ptr",
548  []() { return new std::vector<bool>(4513); },
549  // Without explicitly specifying `take_ownership`, this function leaks.
550  py::return_value_policy::take_ownership);
551 }
OptionalProperties::access_by_copy
OptionalEnumValue access_by_copy()
Definition: test_stl.cpp:109
filesystem.h
EnumType
EnumType
Definition: test_stl.cpp:86
ReferenceSensitiveOptional::ReferenceSensitiveOptional
ReferenceSensitiveOptional()=default
OptionalHolder::member_initialized
bool member_initialized() const
Definition: test_stl.cpp:82
optional_caster
Definition: stl.h:308
ReferenceSensitiveOptional::emplace
T & emplace(Args &&...args)
Definition: test_stl.cpp:141
ReferenceSensitiveOptional::operator->
const T * operator->() const noexcept
Definition: test_stl.cpp:154
std::hash< TplCtorClass >::operator()
size_t operator()(const TplCtorClass &) const
Definition: test_stl.cpp:74
TplCtorClass::TplCtorClass
TplCtorClass(const T &)
Definition: test_stl.cpp:67
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
stl.h
EnumType::kUnset
@ kUnset
OptionalProperties::OptionalProperties
OptionalProperties()
Definition: test_stl.cpp:100
void_caster
Definition: cast.h:246
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
detail
Definition: testSerializationNonlinear.cpp:70
boost
Definition: boostmultiprec.cpp:109
ReferenceSensitiveOptional::operator=
ReferenceSensitiveOptional & operator=(T &&value)
Definition: test_stl.cpp:135
TplCtorClass::operator==
bool operator==(const TplCtorClass &) const
Definition: test_stl.cpp:68
OptionalHolder
Definition: test_stl.cpp:79
constructor_stats.h
result
Values result
Definition: OdometryOptimize.cpp:8
hash
ssize_t hash(handle obj)
Definition: pytypes.h:917
OptionalProperties::access_by_ref
OptionalEnumValue & access_by_ref()
Definition: test_stl.cpp:108
simple::p2
static Point3 p2
Definition: testInitializePose3.cpp:51
OptionalHolder::member
OptionalImpl< T > member
Definition: test_stl.cpp:83
data
int data[]
Definition: Map_placement_new.cpp:1
type_caster
Definition: cast.h:38
make_tuple
tuple make_tuple()
Definition: cast.h:1248
variant_caster
Generic variant caster.
Definition: stl.h:387
operator()
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
Definition: IndexedViewMethods.h:73
RValueCaster
Definition: pybind11_tests.h:57
ReferenceSensitiveOptional::storage
std::vector< T > storage
Definition: test_stl.cpp:159
OptionalProperties::OptionalEnumValue
OptionalImpl< EnumType > OptionalEnumValue
Definition: test_stl.cpp:98
simple::p3
static Point3 p3
Definition: testInitializePose3.cpp:53
PYBIND11_NAMESPACE
Definition: test_custom_type_casters.cpp:24
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Eigen::Triplet< double >
visit_helper
Definition: stl.h:378
p1
Vector3f p1
Definition: MatrixBase_all.cpp:2
p4
KeyInt p4(x4, 4)
matlab_wrap.path
path
Definition: matlab_wrap.py:66
set
void set(Container &c, Position position, const Value &value)
Definition: stdlist_overload.cpp:37
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
TplCtorClass
Issue #528: templated constructor.
Definition: test_stl.cpp:65
ReferenceSensitiveOptional::operator*
const T & operator*() const noexcept
Definition: test_stl.cpp:152
ReferenceSensitiveOptional
Definition: test_stl.cpp:122
OptionalProperties::~OptionalProperties
~OptionalProperties()
Definition: test_stl.cpp:101
PYBIND11_MAKE_OPAQUE
PYBIND11_MAKE_OPAQUE(std::vector< std::string, std::allocator< std::string >>)
pybind11_tests.h
std
Definition: BFloat16.h:88
OptionalProperties
Definition: test_stl.cpp:96
args
Definition: pytypes.h:2163
print_destroyed
void print_destroyed(T *inst, Values &&...values)
Definition: constructor_stats.h:314
p
float * p
Definition: Tutorial_Map_using.cpp:9
EnumType::kSet
@ kSet
ReferenceSensitiveOptional::value
const T & value() const noexcept
Definition: test_stl.cpp:147
OptionalProperties::value
OptionalEnumValue value
Definition: test_stl.cpp:112
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
TEST_SUBMODULE
TEST_SUBMODULE(stl, m)
Definition: test_stl.cpp:170
V
MatrixXcd V
Definition: EigenSolver_EigenSolver_MatrixType.cpp:15
ReferenceSensitiveOptional::ReferenceSensitiveOptional
ReferenceSensitiveOptional(const T &value)
Definition: test_stl.cpp:128
ReferenceSensitiveOptional::ReferenceSensitiveOptional
ReferenceSensitiveOptional(T &&value)
Definition: test_stl.cpp:130
ReferenceSensitiveOptional::operator=
ReferenceSensitiveOptional & operator=(const T &value)
Definition: test_stl.cpp:131
test_callbacks.value
value
Definition: test_callbacks.py:158
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
print_created
void print_created(T *inst, Values &&...values)
Definition: constructor_stats.h:309
OptionalHolder::OptionalHolder
OptionalHolder()
Definition: test_stl.cpp:81
test_eigen.ref
ref
Definition: test_eigen.py:9


gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:31