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  m.def("cast_rv_nested", []() {
223  std::vector<std::array<std::list<std::unordered_map<std::string, RValueCaster>>, 2>> v;
224  v.emplace_back(); // add an array
225  v.back()[0].emplace_back(); // add a map to the array
226  v.back()[0].back().emplace("b", RValueCaster{});
227  v.back()[0].back().emplace("c", RValueCaster{});
228  v.back()[1].emplace_back(); // add a map to the array
229  v.back()[1].back().emplace("a", RValueCaster{});
230  return v;
231  });
232  static std::array<RValueCaster, 2> lva;
233  static std::unordered_map<std::string, RValueCaster> lvm{{"a", RValueCaster{}},
234  {"b", RValueCaster{}}};
235  static std::unordered_map<std::string, std::vector<std::list<std::array<RValueCaster, 2>>>>
236  lvn;
237  lvn["a"].emplace_back(); // add a list
238  lvn["a"].back().emplace_back(); // add an array
239  lvn["a"].emplace_back(); // another list
240  lvn["a"].back().emplace_back(); // add an array
241  lvn["b"].emplace_back(); // add a list
242  lvn["b"].back().emplace_back(); // add an array
243  lvn["b"].back().emplace_back(); // add another array
244  static std::vector<RValueCaster> lvv{2};
245  m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
246  m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
247  m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });
248  m.def("cast_lv_nested", []() -> const decltype(lvn) & { return lvn; });
249  // #853:
250  m.def("cast_unique_ptr_vector", []() {
251  std::vector<std::unique_ptr<UserType>> v;
252  v.emplace_back(new UserType{7});
253  v.emplace_back(new UserType{42});
254  return v;
255  });
256 
257  pybind11::enum_<EnumType>(m, "EnumType")
258  .value("kSet", EnumType::kSet)
259  .value("kUnset", EnumType::kUnset);
260 
261  // test_move_out_container
262  struct MoveOutContainer {
263  struct Value {
264  int value;
265  };
266  std::list<Value> move_list() const { return {{0}, {1}, {2}}; }
267  };
268  py::class_<MoveOutContainer::Value>(m, "MoveOutContainerValue")
269  .def_readonly("value", &MoveOutContainer::Value::value);
270  py::class_<MoveOutContainer>(m, "MoveOutContainer")
271  .def(py::init<>())
272  .def_property_readonly("move_list", &MoveOutContainer::move_list);
273 
274  // Class that can be move- and copy-constructed, but not assigned
275  struct NoAssign {
276  int value;
277 
278  explicit NoAssign(int value = 0) : value(value) {}
279  NoAssign(const NoAssign &) = default;
280  NoAssign(NoAssign &&) = default;
281 
282  NoAssign &operator=(const NoAssign &) = delete;
283  NoAssign &operator=(NoAssign &&) = delete;
284  };
285  py::class_<NoAssign>(m, "NoAssign", "Class with no C++ assignment operators")
286  .def(py::init<>())
287  .def(py::init<int>());
288 
289  struct MoveOutDetector {
290  MoveOutDetector() = default;
291  MoveOutDetector(const MoveOutDetector &) = default;
292  MoveOutDetector(MoveOutDetector &&other) noexcept : initialized(other.initialized) {
293  // steal underlying resource
294  other.initialized = false;
295  }
296  bool initialized = true;
297  };
298  py::class_<MoveOutDetector>(m, "MoveOutDetector", "Class with move tracking")
299  .def(py::init<>())
300  .def_readonly("initialized", &MoveOutDetector::initialized);
301 
302 #ifdef PYBIND11_HAS_OPTIONAL
303  // test_optional
304  m.attr("has_optional") = true;
305 
306  using opt_int = std::optional<int>;
307  using opt_no_assign = std::optional<NoAssign>;
308  m.def("double_or_zero", [](const opt_int &x) -> int { return x.value_or(0) * 2; });
309  m.def("half_or_none", [](int x) -> opt_int { return x != 0 ? opt_int(x / 2) : opt_int(); });
310  m.def(
311  "test_nullopt",
312  [](opt_int x) { return x.value_or(42); },
313  py::arg_v("x", std::nullopt, "None"));
314  m.def(
315  "test_no_assign",
316  [](const opt_no_assign &x) { return x ? x->value : 42; },
317  py::arg_v("x", std::nullopt, "None"));
318 
319  m.def("nodefer_none_optional", [](std::optional<int>) { return true; });
320  m.def("nodefer_none_optional", [](const py::none &) { return false; });
321 
323  py::class_<opt_holder>(m, "OptionalHolder", "Class with optional member")
324  .def(py::init<>())
325  .def_readonly("member", &opt_holder::member)
326  .def("member_initialized", &opt_holder::member_initialized);
327 
328  using opt_props = OptionalProperties<std::optional>;
329  pybind11::class_<opt_props>(m, "OptionalProperties")
330  .def(pybind11::init<>())
331  .def_property_readonly("access_by_ref", &opt_props::access_by_ref)
332  .def_property_readonly("access_by_copy", &opt_props::access_by_copy);
333 #endif
334 
335 #ifdef PYBIND11_HAS_EXP_OPTIONAL
336  // test_exp_optional
337  m.attr("has_exp_optional") = true;
338 
339  using exp_opt_int = std::experimental::optional<int>;
340  using exp_opt_no_assign = std::experimental::optional<NoAssign>;
341  m.def("double_or_zero_exp", [](const exp_opt_int &x) -> int { return x.value_or(0) * 2; });
342  m.def("half_or_none_exp",
343  [](int x) -> exp_opt_int { return x ? exp_opt_int(x / 2) : exp_opt_int(); });
344  m.def(
345  "test_nullopt_exp",
346  [](exp_opt_int x) { return x.value_or(42); },
347  py::arg_v("x", std::experimental::nullopt, "None"));
348  m.def(
349  "test_no_assign_exp",
350  [](const exp_opt_no_assign &x) { return x ? x->value : 42; },
351  py::arg_v("x", std::experimental::nullopt, "None"));
352 
354  py::class_<opt_exp_holder>(m, "OptionalExpHolder", "Class with optional member")
355  .def(py::init<>())
356  .def_readonly("member", &opt_exp_holder::member)
357  .def("member_initialized", &opt_exp_holder::member_initialized);
358 
360  pybind11::class_<opt_exp_props>(m, "OptionalExpProperties")
361  .def(pybind11::init<>())
362  .def_property_readonly("access_by_ref", &opt_exp_props::access_by_ref)
363  .def_property_readonly("access_by_copy", &opt_exp_props::access_by_copy);
364 #endif
365 
366 #if defined(PYBIND11_TEST_BOOST)
367  // test_boost_optional
368  m.attr("has_boost_optional") = true;
369 
370  using boost_opt_int = boost::optional<int>;
371  using boost_opt_no_assign = boost::optional<NoAssign>;
372  m.def("double_or_zero_boost", [](const boost_opt_int &x) -> int { return x.value_or(0) * 2; });
373  m.def("half_or_none_boost",
374  [](int x) -> boost_opt_int { return x != 0 ? boost_opt_int(x / 2) : boost_opt_int(); });
375  m.def(
376  "test_nullopt_boost",
377  [](boost_opt_int x) { return x.value_or(42); },
378  py::arg_v("x", boost::none, "None"));
379  m.def(
380  "test_no_assign_boost",
381  [](const boost_opt_no_assign &x) { return x ? x->value : 42; },
382  py::arg_v("x", boost::none, "None"));
383 
384  using opt_boost_holder = OptionalHolder<boost::optional, MoveOutDetector>;
385  py::class_<opt_boost_holder>(m, "OptionalBoostHolder", "Class with optional member")
386  .def(py::init<>())
387  .def_readonly("member", &opt_boost_holder::member)
388  .def("member_initialized", &opt_boost_holder::member_initialized);
389 
390  using opt_boost_props = OptionalProperties<boost::optional>;
391  pybind11::class_<opt_boost_props>(m, "OptionalBoostProperties")
392  .def(pybind11::init<>())
393  .def_property_readonly("access_by_ref", &opt_boost_props::access_by_ref)
394  .def_property_readonly("access_by_copy", &opt_boost_props::access_by_copy);
395 #endif
396 
397  // test_refsensitive_optional
398  using refsensitive_opt_int = ReferenceSensitiveOptional<int>;
399  using refsensitive_opt_no_assign = ReferenceSensitiveOptional<NoAssign>;
400  m.def("double_or_zero_refsensitive",
401  [](const refsensitive_opt_int &x) -> int { return (x ? x.value() : 0) * 2; });
402  m.def("half_or_none_refsensitive", [](int x) -> refsensitive_opt_int {
403  return x != 0 ? refsensitive_opt_int(x / 2) : refsensitive_opt_int();
404  });
405  m.def(
406  "test_nullopt_refsensitive",
407  // NOLINTNEXTLINE(performance-unnecessary-value-param)
408  [](refsensitive_opt_int x) { return x ? x.value() : 42; },
409  py::arg_v("x", refsensitive_opt_int(), "None"));
410  m.def(
411  "test_no_assign_refsensitive",
412  [](const refsensitive_opt_no_assign &x) { return x ? x->value : 42; },
413  py::arg_v("x", refsensitive_opt_no_assign(), "None"));
414 
415  using opt_refsensitive_holder = OptionalHolder<ReferenceSensitiveOptional, MoveOutDetector>;
416  py::class_<opt_refsensitive_holder>(
417  m, "OptionalRefSensitiveHolder", "Class with optional member")
418  .def(py::init<>())
419  .def_readonly("member", &opt_refsensitive_holder::member)
420  .def("member_initialized", &opt_refsensitive_holder::member_initialized);
421 
422  using opt_refsensitive_props = OptionalProperties<ReferenceSensitiveOptional>;
423  pybind11::class_<opt_refsensitive_props>(m, "OptionalRefSensitiveProperties")
424  .def(pybind11::init<>())
425  .def_property_readonly("access_by_ref", &opt_refsensitive_props::access_by_ref)
426  .def_property_readonly("access_by_copy", &opt_refsensitive_props::access_by_copy);
427 
428 #ifdef PYBIND11_HAS_FILESYSTEM
429  // test_fs_path
430  m.attr("has_filesystem") = true;
431  m.def("parent_path", [](const std::filesystem::path &p) { return p.parent_path(); });
432 #endif
433 
434 #ifdef PYBIND11_TEST_VARIANT
436  "visitor::result_type is required by boost::variant in C++11 mode");
437 
438  struct visitor {
439  using result_type = const char *;
440 
441  result_type operator()(int) { return "int"; }
442  result_type operator()(const std::string &) { return "std::string"; }
443  result_type operator()(double) { return "double"; }
444  result_type operator()(std::nullptr_t) { return "std::nullptr_t"; }
445 # if defined(PYBIND11_HAS_VARIANT)
446  result_type operator()(std::monostate) { return "std::monostate"; }
447 # endif
448  };
449 
450  // test_variant
451  m.def("load_variant", [](const variant<int, std::string, double, std::nullptr_t> &v) {
452  return py::detail::visit_helper<variant>::call(visitor(), v);
453  });
454  m.def("load_variant_2pass", [](variant<double, int> v) {
455  return py::detail::visit_helper<variant>::call(visitor(), v);
456  });
457  m.def("cast_variant", []() {
458  using V = variant<int, std::string>;
459  return py::make_tuple(V(5), V("Hello"));
460  });
461 
462 # if defined(PYBIND11_HAS_VARIANT)
463  // std::monostate tests.
464  m.def("load_monostate_variant",
465  [](const variant<std::monostate, int, std::string> &v) -> const char * {
466  return py::detail::visit_helper<variant>::call(visitor(), v);
467  });
468  m.def("cast_monostate_variant", []() {
469  using V = variant<std::monostate, int, std::string>;
470  return py::make_tuple(V{}, V(5), V("Hello"));
471  });
472 # endif
473 #endif
474 
475  // #528: templated constructor
476  // (no python tests: the test here is that this compiles)
477  m.def("tpl_ctor_vector", [](std::vector<TplCtorClass> &) {});
478  m.def("tpl_ctor_map", [](std::unordered_map<TplCtorClass, TplCtorClass> &) {});
479  m.def("tpl_ctor_set", [](std::unordered_set<TplCtorClass> &) {});
480 #if defined(PYBIND11_HAS_OPTIONAL)
481  m.def("tpl_constr_optional", [](std::optional<TplCtorClass> &) {});
482 #endif
483 #if defined(PYBIND11_HAS_EXP_OPTIONAL)
484  m.def("tpl_constr_optional_exp", [](std::experimental::optional<TplCtorClass> &) {});
485 #endif
486 #if defined(PYBIND11_TEST_BOOST)
487  m.def("tpl_constr_optional_boost", [](boost::optional<TplCtorClass> &) {});
488 #endif
489 
490  // test_vec_of_reference_wrapper
491  // #171: Can't return STL structures containing reference wrapper
492  m.def("return_vec_of_reference_wrapper", [](std::reference_wrapper<UserType> p4) {
493  static UserType p1{1}, p2{2}, p3{3};
494  return std::vector<std::reference_wrapper<UserType>>{
496  });
497 
498  // test_stl_pass_by_pointer
499  m.def("stl_pass_by_pointer", [](std::vector<int> *v) { return *v; }, "v"_a = nullptr);
500 
501  // #1258: pybind11/stl.h converts string to vector<string>
502  m.def("func_with_string_or_vector_string_arg_overload",
503  [](const std::vector<std::string> &) { return 1; });
504  m.def("func_with_string_or_vector_string_arg_overload",
505  [](const std::list<std::string> &) { return 2; });
506  m.def("func_with_string_or_vector_string_arg_overload", [](const std::string &) { return 3; });
507 
508  class Placeholder {
509  public:
510  Placeholder() { print_created(this); }
511  Placeholder(const Placeholder &) = delete;
512  ~Placeholder() { print_destroyed(this); }
513  };
514  py::class_<Placeholder>(m, "Placeholder");
515 
517  m.def(
518  "test_stl_ownership",
519  []() {
520  std::vector<Placeholder *> result;
521  result.push_back(new Placeholder());
522  return result;
523  },
524  py::return_value_policy::take_ownership);
525 
526  m.def("array_cast_sequence", [](std::array<int, 3> x) { return x; });
527 
529  struct Issue1561Inner {
530  std::string data;
531  };
532  struct Issue1561Outer {
533  std::vector<Issue1561Inner> list;
534  };
535 
536  py::class_<Issue1561Inner>(m, "Issue1561Inner")
537  .def(py::init<std::string>())
538  .def_readwrite("data", &Issue1561Inner::data);
539 
540  py::class_<Issue1561Outer>(m, "Issue1561Outer")
541  .def(py::init<>())
542  .def_readwrite("list", &Issue1561Outer::list);
543 
544  m.def(
545  "return_vector_bool_raw_ptr",
546  []() { return new std::vector<bool>(4513); },
547  // Without explicitly specifying `take_ownership`, this function leaks.
548  py::return_value_policy::take_ownership);
549 }
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:248
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:934
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:1383
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:70
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:2210
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:160
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 Sat Nov 16 2024 04:07:08