Go to the documentation of this file.
20 #include <unordered_map>
21 #include <unordered_set>
25 #if defined(PYBIND11_HAS_OPTIONAL)
27 #elif defined(PYBIND11_HAS_EXP_OPTIONAL)
28 # include <experimental/optional>
31 #if defined(PYBIND11_HAS_VARIANT)
38 template <
typename T,
typename U>
47 template <
typename T,
typename U>
49 return std::forward<detail::forwarded_type<T, U>>(std::forward<U>(u));
57 template <
typename Type,
typename Key>
71 if (!isinstance<anyset>(src)) {
74 auto s = reinterpret_borrow<anyset>(src);
77 for (
auto entry :
s) {
82 value.insert(cast_op<Key &&>(std::move(
conv)));
93 for (
auto &&
value : src) {
94 auto value_ = reinterpret_steal<object>(
96 if (!value_ || !
s.add(std::move(value_))) {
106 template <
typename Type,
typename Key,
typename Value>
120 if (!isinstance<dict>(src)) {
123 auto d = reinterpret_borrow<dict>(src);
132 value.emplace(cast_op<Key &&>(std::move(kconv)), cast_op<Value &&>(std::move(vconv)));
137 template <
typename T>
146 for (
auto &&kv : src) {
147 auto key = reinterpret_steal<object>(
148 key_conv::cast(detail::forward_like<T>(kv.first), policy_key, parent));
149 auto value = reinterpret_steal<object>(
150 value_conv::cast(detail::forward_like<T>(kv.second), policy_value, parent));
164 template <
typename Type,
typename Value>
169 if (!isinstance<sequence>(src) || isinstance<bytes>(src) || isinstance<str>(src)) {
172 auto s = reinterpret_borrow<sequence>(src);
175 for (
const auto &it :
s) {
180 value.push_back(cast_op<Value &&>(std::move(
conv)));
193 template <
typename T>
200 for (
auto &&
value : src) {
201 auto value_ = reinterpret_steal<object>(
206 PyList_SET_ITEM(
l.ptr(), index++, value_.release().ptr());
214 template <
typename Type,
typename Alloc>
217 template <
typename Type,
typename Alloc>
220 template <
typename Type,
typename Alloc>
223 template <
typename ArrayType,
typename Value,
bool Resizable,
size_t Size = 0>
228 template <
bool R = Resizable>
235 template <
bool R = Resizable>
242 if (!isinstance<sequence>(src)) {
245 auto l = reinterpret_borrow<sequence>(src);
250 for (
const auto &it :
l) {
255 value[ctr++] = cast_op<Value &&>(std::move(
conv));
260 template <
typename T>
264 for (
auto &&
value : src) {
265 auto value_ = reinterpret_steal<object>(
270 PyList_SET_ITEM(
l.ptr(), index++, value_.release().ptr());
283 template <
typename Type,
size_t Size>
285 :
array_caster<std::array<Type, Size>, Type, false, Size> {};
287 template <
typename Type>
290 template <
typename Key,
typename Compare,
typename Alloc>
292 :
set_caster<std::set<Key, Compare, Alloc>, Key> {};
294 template <
typename Key,
typename Hash,
typename Equal,
typename Alloc>
296 :
set_caster<std::unordered_set<Key, Hash, Equal, Alloc>, Key> {};
298 template <
typename Key,
typename Value,
typename Compare,
typename Alloc>
300 :
map_caster<std::map<Key, Value, Compare, Alloc>, Key, Value> {};
302 template <
typename Key,
typename Value,
typename Hash,
typename Equal,
typename Alloc>
304 :
map_caster<std::unordered_map<Key, Value, Hash, Equal, Alloc>, Key, Value> {};
307 template <
typename Type,
typename Value =
typename Type::value_type>
311 template <
typename T>
335 value.emplace(cast_op<Value &&>(std::move(inner_caster)));
342 #if defined(PYBIND11_HAS_OPTIONAL)
343 template <
typename T>
350 #if defined(PYBIND11_HAS_EXP_OPTIONAL)
351 template <
typename T>
357 :
public void_caster<std::experimental::nullopt_t> {};
367 template <
typename T>
377 template <
template <
typename...>
class Variant>
379 template <
typename... Args>
380 static auto call(Args &&...
args) -> decltype(visit(std::forward<Args>(
args)...)) {
381 return visit(std::forward<Args>(
args)...);
386 template <
typename Variant>
389 template <
template <
typename...>
class V,
typename... Ts>
391 static_assert(
sizeof...(Ts) > 0,
"Variant must consist of at least one alternative.");
393 template <
typename U,
typename... Us>
396 if (caster.load(src,
convert)) {
397 value = cast_op<U>(std::move(caster));
416 template <
typename Variant>
419 std::forward<Variant>(src));
429 #if defined(PYBIND11_HAS_VARIANT)
430 template <
typename... Ts>
440 #ifdef PYBIND11_HAS_STRING_VIEW
441 os <<
str(obj).cast<std::string_view>();
443 os << (std::string)
str(obj);
PyObject * conv(PyObject *o)
void reserve_maybe(const sequence &s, Type *)
bool load_alternative(handle, bool, type_list<>)
std::is_same< decltype(std::declval< C >().reserve(0)), void > has_reserve_method
bool load(handle src, bool convert)
constexpr descr< N - 1 > const_name(char const (&text)[N])
static const double d[K][N]
static handle cast(T &&src, return_value_policy policy, handle parent)
void reserve_maybe(const dict &d, Type *)
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
constexpr forwarded_type< T, U > forward_like(U &&u)
#define PYBIND11_NAMESPACE_END(name)
void reserve_maybe(const anyset &, void *)
#define PYBIND11_NAMESPACE_BEGIN(name)
ofstream os("timeSchurFactors.csv")
bool load(handle src, bool convert)
static handle cast(T &&src, return_value_policy policy, handle parent)
typename std::conditional< B, T, F >::type conditional_t
Helper template which holds a list of types.
bool load_alternative(handle src, bool convert, type_list< U, Us... >)
static handle cast(const itype &src, return_value_policy policy, handle parent)
static handle cast(T &&src, return_value_policy policy, handle parent)
static return_value_policy policy(return_value_policy p)
PYBIND11_TYPE_CASTER(ArrayType, const_name< Resizable >(const_name(""), const_name("Annotated["))+const_name("list[")+value_conv::name+const_name("]")+const_name< Resizable >(const_name(""), const_name(", FixedSize(")+const_name< Size >()+const_name(")]")))
void reserve_maybe(const anyset &s, Type *)
static const Line3 l(Rot3(), 1, 1)
bool require_size(enable_if_t< R, size_t > size)
static handle cast(T &&src, return_value_policy policy, handle parent)
void reserve_maybe(const sequence &, void *)
constexpr descr< 0 > concat()
result_type operator()(T &&src) const
const gtsam::Symbol key('X', 0)
void set(Container &c, Position position, const Value &value)
#define PYBIND11_TYPE_CASTER(type, py_name)
conditional_t< std::is_lvalue_reference< T >::value, remove_reference_t< U > &, remove_reference_t< U > && > forwarded_type
void reserve_maybe(const dict &, void *)
bool load(handle src, bool convert)
PYBIND11_TYPE_CASTER(Type, const_name("list[")+value_conv::name+const_name("]"))
return_value_policy policy
bool require_size(enable_if_t<!R, size_t > size)
static auto call(Args &&...args) -> decltype(visit(std::forward< Args >(args)...))
bool load(handle src, bool convert)
bool load(handle src, bool convert)
static handle cast(T &&src, return_value_policy policy, handle parent)
PYBIND11_TYPE_CASTER(Type, const_name("dict[")+key_conv::name+const_name(", ")+value_conv::name+const_name("]"))
bool load(handle src, bool convert)
static BinaryMeasurement< Rot3 > convert(const BetweenFactor< Pose3 >::shared_ptr &f)
static constexpr auto name
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
static handle cast(Variant &&src, return_value_policy policy, handle parent)
Visit a variant and cast any found type to Python.
typename std::remove_reference< T >::type remove_reference_t
bool load(handle src, bool convert)
PYBIND11_TYPE_CASTER(type, const_name("set[")+key_conv::name+const_name("]"))
PYBIND11_TYPE_CASTER(Type, const_name("Optional[")+value_conv::name+const_name("]"))
gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:03:50