μHAL (v2.8.5)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Macros | Typedefs | Functions
cast.h File Reference
#include "pytypes.h"
#include "detail/typeid.h"
#include "detail/descr.h"
#include "detail/internals.h"
#include <array>
#include <limits>
#include <tuple>
#include <type_traits>
Include dependency graph for cast.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  loader_life_support
 A life support system for temporary objects created by type_caster::load(). More...
 
struct  value_and_holder
 
struct  values_and_holders
 
struct  values_and_holders::iterator
 
class  type_caster_generic
 
struct  is_copy_constructible< T, SFINAE >
 
struct  is_copy_constructible< Container, enable_if_t< all_of< std::is_copy_constructible< Container >, std::is_same< typename Container::value_type &, typename Container::reference >, negation< std::is_same< Container, typename Container::value_type > > >::value > >
 
struct  is_copy_constructible< std::pair< T1, T2 > >
 
struct  is_copy_assignable< T, SFINAE >
 
struct  is_copy_assignable< Container, enable_if_t< all_of< std::is_copy_assignable< Container >, std::is_same< typename Container::value_type &, typename Container::reference > >::value > >
 
struct  is_copy_assignable< std::pair< T1, T2 > >
 
struct  polymorphic_type_hook_base< itype, SFINAE >
 
struct  polymorphic_type_hook_base< itype, detail::enable_if_t< std::is_polymorphic< itype >::value > >
 
struct  polymorphic_type_hook< itype, SFINAE >
 
class  type_caster_base< type >
 Generic type caster for objects stored on the heap. More...
 
class  type_caster< type, SFINAE >
 
class  type_caster< std::reference_wrapper< type > >
 
struct  type_caster< T, enable_if_t< std::is_arithmetic< T >::value &&!is_std_char_type< T >::value > >
 
struct  void_caster< T >
 
class  type_caster< void_type >
 
class  type_caster< void >
 
class  type_caster< std::nullptr_t >
 
class  type_caster< bool >
 
struct  string_caster< StringType, IsView >
 
struct  type_caster< std::basic_string< CharT, Traits, Allocator >, enable_if_t< is_std_char_type< CharT >::value > >
 
struct  type_caster< CharT, enable_if_t< is_std_char_type< CharT >::value > >
 
class  tuple_caster< Tuple, Ts >
 
class  type_caster< std::pair< T1, T2 > >
 
class  type_caster< std::tuple< Ts... > >
 
struct  holder_helper< T >
 Helper class which abstracts away certain actions. More...
 
struct  copyable_holder_caster< type, holder_type >
 Type caster for holder types like std::shared_ptr, etc. More...
 
class  type_caster< std::shared_ptr< T > >
 Specialize for the common std::shared_ptr, so users don't need to. More...
 
struct  move_only_holder_caster< type, holder_type >
 
class  type_caster< std::unique_ptr< type, deleter > >
 
struct  always_construct_holder< T, Value >
 
struct  is_holder_type< base, holder >
 
struct  is_holder_type< base, std::unique_ptr< base, deleter > >
 
struct  handle_type_name< T >
 
struct  handle_type_name< bytes >
 
struct  handle_type_name< int_ >
 
struct  handle_type_name< iterable >
 
struct  handle_type_name< iterator >
 
struct  handle_type_name< none >
 
struct  handle_type_name< args >
 
struct  handle_type_name< kwargs >
 
struct  pyobject_caster< type >
 
class  type_caster< T, enable_if_t< is_pyobject< T >::value > >
 
struct  move_always< T, SFINAE >
 
struct  move_always< T, enable_if_t< all_of< move_is_plain_type< T >, negation< is_copy_constructible< T > >, std::is_move_constructible< T >, std::is_same< decltype(std::declval< make_caster< T >>().operator T&()), T & >>::value > >
 
struct  move_if_unreferenced< T, SFINAE >
 
struct  move_if_unreferenced< T, enable_if_t< all_of< move_is_plain_type< T >, negation< move_always< T > >, std::is_move_constructible< T >, std::is_same< decltype(std::declval< make_caster< T >>().operator T&()), T & >>::value > >
 
struct  return_value_policy_override< Return, SFINAE >
 
struct  return_value_policy_override< Return, detail::enable_if_t< std::is_base_of< type_caster_generic, make_caster< Return > >::value, void > >
 
struct  override_unused
 
struct  arg
 
struct  arg_v
 
struct  kw_only
 
struct  pos_only
 
struct  function_call
 Internal data associated with a single function call. More...
 
class  argument_loader< Args >
 Helper class which loads arguments for C++ functions called from Python. More...
 
class  simple_collector< policy >
 Helper class which collects only positional arguments for a Python function call. More...
 
class  unpacking_collector< policy >
 Helper class which collects positional, keyword, * and ** arguments for a Python function call. More...
 

Namespaces

 literals
 

Macros

#define PYBIND11_TYPE_CASTER(type, py_name)
 
#define PYBIND11_DECLARE_HOLDER_TYPE(type, holder_type, ...)
 Create a specialization for custom holder types (silently ignores std::shared_ptr) More...
 
#define PYBIND11_MAKE_OPAQUE(...)
 
#define PYBIND11_TYPE(...)   __VA_ARGS__
 Lets you pass a type containing a , through a macro parameter without needing a separate typedef, e.g. More...
 

Typedefs

template<typename T >
using cast_op_type = conditional_t< std::is_pointer< remove_reference_t< T > >::value, typename std::add_pointer< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type >
 Determine suitable casting operator for pointer-or-lvalue-casting type casters. More...
 
template<typename T >
using movable_cast_op_type = conditional_t< std::is_pointer< typename std::remove_reference< T >::type >::value, typename std::add_pointer< intrinsic_t< T > >::type, conditional_t< std::is_rvalue_reference< T >::value, typename std::add_rvalue_reference< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type > >
 Determine suitable casting operator for a type caster with a movable value. More...
 
template<typename type >
using make_caster = type_caster< intrinsic_t< type > >
 
template<typename CharT >
using is_std_char_type = any_of< std::is_same< CharT, char >, std::is_same< CharT, char16_t >, std::is_same< CharT, char32_t >, std::is_same< CharT, wchar_t > >
 
template<typename type , typename holder_type >
using type_caster_holder = conditional_t< is_copy_constructible< holder_type >::value, copyable_holder_caster< type, holder_type >, move_only_holder_caster< type, holder_type > >
 
template<typename T >
using move_is_plain_type = satisfies_none_of< T, std::is_void, std::is_pointer, std::is_reference, std::is_const >
 
template<typename T >
using move_never = none_of< move_always< T >, move_if_unreferenced< T > >
 
template<typename type >
using cast_is_temporary_value_reference = bool_constant<(std::is_reference< type >::value||std::is_pointer< type >::value) &&!std::is_base_of< type_caster_generic, make_caster< type > >::value &&!std::is_same< intrinsic_t< type >, void >::value >
 
template<typename ret_type >
using override_caster_t = conditional_t< cast_is_temporary_value_reference< ret_type >::value, make_caster< ret_type >, override_unused >
 
template<typename >
using arg_t = arg_v
 Alias for backward compatibility – to be removed in version 2.0. More...
 

Functions

std::pair< decltype(internals::registered_types_py)::iterator, bool > all_type_info_get_cache (PyTypeObject *type)
 
PYBIND11_NOINLINE void all_type_info_populate (PyTypeObject *t, std::vector< type_info * > &bases)
 
const std::vector< detail::type_info * > & all_type_info (PyTypeObject *type)
 Extracts vector of type_info pointers of pybind-registered roots of the given Python type. More...
 
PYBIND11_NOINLINE detail::type_info * get_type_info (PyTypeObject *type)
 Gets a single pybind11 type info for a python type. More...
 
detail::type_info * get_local_type_info (const std::type_index &tp)
 
detail::type_info * get_global_type_info (const std::type_index &tp)
 
PYBIND11_NOINLINE detail::type_info * get_type_info (const std::type_index &tp, bool throw_if_missing=false)
 Return the type info for a given C++ type; on lookup failure can either throw or return nullptr. More...
 
PYBIND11_NOINLINE handle get_type_handle (const std::type_info &tp, bool throw_if_missing)
 
PYBIND11_NOINLINE bool isinstance_generic (handle obj, const std::type_info &tp)
 
PYBIND11_NOINLINE std::string error_string ()
 
PYBIND11_NOINLINE handle get_object_handle (const void *ptr, const detail::type_info *type)
 
PyThreadState * get_thread_state_unchecked ()
 
void keep_alive_impl (handle nurse, handle patient)
 
PyObject * make_new_instance (PyTypeObject *type)
 Instance creation function for all pybind11 types. More...
 
template<typename T >
make_caster< T >::template cast_op_type< T > cast_op (make_caster< T > &caster)
 
template<typename T >
make_caster< T >::template cast_op_type< typename std::add_rvalue_reference< T >::typecast_op (make_caster< T > &&caster)
 
template<typename T , typename SFINAE >
type_caster< T, SFINAE > & load_type (type_caster< T, SFINAE > &conv, const handle &handle)
 
template<typename T >
make_caster< T > load_type (const handle &handle)
 
template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0>
cast (const handle &handle)
 
template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0>
object cast (T &&value, return_value_policy policy=return_value_policy::automatic_reference, handle parent=handle())
 
template<typename T >
detail::enable_if_t<!detail::move_never< T >::value, T > move (object &&obj)
 
template<typename T >
detail::enable_if_t< detail::move_always< T >::value, T > cast (object &&object)
 
template<typename T >
detail::enable_if_t< detail::move_if_unreferenced< T >::value, T > cast (object &&object)
 
template<typename T >
detail::enable_if_t< detail::move_never< T >::value, T > cast (object &&object)
 
template<typename T , enable_if_t<!is_pyobject< T >::value, int > >
object object_or_cast (T &&o)
 
template<typename T >
enable_if_t< cast_is_temporary_value_reference< T >::value, T > cast_ref (object &&o, make_caster< T > &caster)
 
template<typename T >
enable_if_t<!cast_is_temporary_value_reference< T >::value, T > cast_ref (object &&, override_unused &)
 
template<typename T >
enable_if_t<!cast_is_temporary_value_reference< T >::value, T > cast_safe (object &&o)
 
template<typename T >
enable_if_t< cast_is_temporary_value_reference< T >::value, T > cast_safe (object &&)
 
template<>
void cast_safe< void > (object &&)
 
template<return_value_policy policy = return_value_policy::automatic_reference>
tuple make_tuple ()
 
template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
tuple make_tuple (Args &&... args_)
 
constexpr arg literals::operator""_a (const char *name, size_t)
 \rst String literal version of arg \endrst More...
 
template<return_value_policy policy, typename... Args, typename = enable_if_t<all_of<is_positional<Args>...>::value>>
simple_collector< policy > collect_arguments (Args &&...args)
 Collect only positional arguments for a Python function call. More...
 
template<return_value_policy policy, typename... Args, typename = enable_if_t<!all_of<is_positional<Args>...>::value>>
unpacking_collector< policy > collect_arguments (Args &&...args)
 Collect all arguments, including keywords and unpacking (only instantiated when needed) More...
 

Macro Definition Documentation

◆ PYBIND11_DECLARE_HOLDER_TYPE

#define PYBIND11_DECLARE_HOLDER_TYPE (   type,
  holder_type,
  ... 
)
Value:
namespace pybind11 { namespace detail { \
template <typename type> \
template <typename type> \
}}

Create a specialization for custom holder types (silently ignores std::shared_ptr)

Definition at line 1595 of file cast.h.

◆ PYBIND11_MAKE_OPAQUE

#define PYBIND11_MAKE_OPAQUE (   ...)
Value:
namespace pybind11 { namespace detail { \
template<> class type_caster<__VA_ARGS__> : public type_caster_base<__VA_ARGS__> { }; \
}}

Definition at line 2211 of file cast.h.

◆ PYBIND11_TYPE

#define PYBIND11_TYPE (   ...)    __VA_ARGS__

Lets you pass a type containing a , through a macro parameter without needing a separate typedef, e.g.

: PYBIND11_OVERRIDE(PYBIND11_TYPE(ReturnType<A, B>), PYBIND11_TYPE(Parent<C, D>), f, arg)

Definition at line 2218 of file cast.h.

◆ PYBIND11_TYPE_CASTER

#define PYBIND11_TYPE_CASTER (   type,
  py_name 
)
Value:
protected: \
type value; \
public: \
static constexpr auto name = py_name; \
template <typename T_, enable_if_t<std::is_same<type, remove_cv_t<T_>>::value, int> = 0> \
static handle cast(T_ *src, return_value_policy policy, handle parent) { \
if (!src) return none().release(); \
auto h = cast(std::move(*src), policy, parent); delete src; return h; \
} else { \
return cast(*src, policy, parent); \
} \
} \
operator type*() { return &value; } \
operator type&() { return value; } \
operator type&&() && { return std::move(value); } \
template <typename T_> using cast_op_type = pybind11::detail::movable_cast_op_type<T_>

Definition at line 980 of file cast.h.

Typedef Documentation

◆ arg_t

template<typename >
using arg_t = arg_v

Alias for backward compatibility – to be removed in version 2.0.

Definition at line 1916 of file cast.h.

◆ cast_is_temporary_value_reference

template<typename type >
using cast_is_temporary_value_reference = bool_constant< (std::is_reference<type>::value || std::is_pointer<type>::value) && !std::is_base_of<type_caster_generic, make_caster<type> >::value && !std::is_same<intrinsic_t<type>, void>::value >

Definition at line 1673 of file cast.h.

◆ cast_op_type

template<typename T >
using cast_op_type = conditional_t<std::is_pointer<remove_reference_t<T> >::value, typename std::add_pointer<intrinsic_t<T> >::type, typename std::add_lvalue_reference<intrinsic_t<T> >::type>

Determine suitable casting operator for pointer-or-lvalue-casting type casters.

The type caster needs to provide operator T*() and operator T&() operators.

If the type supports moving the value away via an operator T&&() && method, it should use movable_cast_op_type instead.

Definition at line 770 of file cast.h.

◆ is_std_char_type

template<typename CharT >
using is_std_char_type = any_of< std::is_same<CharT, char>, std::is_same<CharT, char16_t>, std::is_same<CharT, char32_t>, std::is_same<CharT, wchar_t> >

Definition at line 999 of file cast.h.

◆ make_caster

template<typename type >
using make_caster = type_caster<intrinsic_t<type> >

Definition at line 947 of file cast.h.

◆ movable_cast_op_type

template<typename T >
using movable_cast_op_type = conditional_t<std::is_pointer<typename std::remove_reference<T>::type>::value, typename std::add_pointer<intrinsic_t<T> >::type, conditional_t<std::is_rvalue_reference<T>::value, typename std::add_rvalue_reference<intrinsic_t<T> >::type, typename std::add_lvalue_reference<intrinsic_t<T> >::type> >

Determine suitable casting operator for a type caster with a movable value.

Such a type caster needs to provide operator T*(), operator T&(), and operator T&&() &&. The latter will be called in appropriate contexts where the value can be moved rather than copied.

These operator are automatically provided when using the PYBIND11_TYPE_CASTER macro.

Definition at line 783 of file cast.h.

◆ move_is_plain_type

template<typename T >
using move_is_plain_type = satisfies_none_of<T, std::is_void, std::is_pointer, std::is_reference, std::is_const >

Definition at line 1650 of file cast.h.

◆ move_never

template<typename T >
using move_never = none_of<move_always<T>, move_if_unreferenced<T> >

Definition at line 1667 of file cast.h.

◆ override_caster_t

template<typename ret_type >
using override_caster_t = conditional_t< cast_is_temporary_value_reference<ret_type>::value, make_caster<ret_type>, override_unused>

Definition at line 1792 of file cast.h.

◆ type_caster_holder

template<typename type , typename holder_type >
using type_caster_holder = conditional_t<is_copy_constructible<holder_type>::value, copyable_holder_caster<type, holder_type>, move_only_holder_caster<type, holder_type> >

Definition at line 1587 of file cast.h.

Function Documentation

◆ all_type_info()

const std::vector<detail::type_info *>& all_type_info ( PyTypeObject *  type)
inline

Extracts vector of type_info pointers of pybind-registered roots of the given Python type.

Will be just 1 pybind type for the Python type of a pybind-registered class, or for any Python-side derived class that uses single inheritance. Will contain as many types as required for a Python class that uses multiple inheritance to inherit (directly or indirectly) from multiple pybind-registered classes. Will be empty if neither the type nor any base classes are pybind-registered.

The value is cached for the lifetime of the Python type.

Definition at line 150 of file cast.h.

References all_type_info_get_cache(), and all_type_info_populate().

Referenced by instance::allocate_layout(), type_caster_generic::cast(), get_type_info(), keep_alive_impl(), type_caster< void >::load(), and type_caster_generic::load_impl().

◆ all_type_info_get_cache()

std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache ( PyTypeObject *  type)
inline

◆ all_type_info_populate()

PYBIND11_NOINLINE void all_type_info_populate ( PyTypeObject *  t,
std::vector< type_info * > &  bases 
)
inline

Definition at line 95 of file cast.h.

References get_internals(), test_multiple_inheritance::i, and internals::registered_types_py.

Referenced by all_type_info().

◆ cast() [1/5]

template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0>
T cast ( const handle handle)

◆ cast() [2/5]

template<typename T >
detail::enable_if_t<detail::move_always<T>::value, T> cast ( object &&  object)

Definition at line 1767 of file cast.h.

◆ cast() [3/5]

template<typename T >
detail::enable_if_t<detail::move_if_unreferenced<T>::value, T> cast ( object &&  object)

Definition at line 1770 of file cast.h.

◆ cast() [4/5]

template<typename T >
detail::enable_if_t<detail::move_never<T>::value, T> cast ( object &&  object)

Definition at line 1776 of file cast.h.

◆ cast() [5/5]

template<typename T , detail::enable_if_t<!detail::is_pyobject< T >::value, int > = 0>
object cast ( T &&  value,
return_value_policy  policy = return_value_policy::automatic_reference,
handle  parent = handle() 
)

◆ cast_op() [1/2]

template<typename T >
make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type> cast_op ( make_caster< T > &&  caster)

Definition at line 954 of file cast.h.

◆ cast_op() [2/2]

template<typename T >
make_caster<T>::template cast_op_type<T> cast_op ( make_caster< T > &  caster)

Definition at line 950 of file cast.h.

◆ cast_ref() [1/2]

template<typename T >
enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_ref ( object &&  ,
override_unused  
)

Definition at line 1800 of file cast.h.

References pybind11_fail().

◆ cast_ref() [2/2]

template<typename T >
enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_ref ( object &&  o,
make_caster< T > &  caster 
)

Definition at line 1797 of file cast.h.

References load_type().

◆ cast_safe() [1/2]

template<typename T >
enable_if_t<cast_is_temporary_value_reference<T>::value, T> cast_safe ( object &&  )

Definition at line 1808 of file cast.h.

References pybind11_fail().

◆ cast_safe() [2/2]

template<typename T >
enable_if_t<!cast_is_temporary_value_reference<T>::value, T> cast_safe ( object &&  o)

Definition at line 1806 of file cast.h.

◆ cast_safe< void >()

template<>
void cast_safe< void > ( object &&  )
inline

Definition at line 1810 of file cast.h.

◆ collect_arguments() [1/2]

template<return_value_policy policy, typename... Args, typename = enable_if_t<all_of<is_positional<Args>...>::value>>
simple_collector<policy> collect_arguments ( Args &&...  args)

Collect only positional arguments for a Python function call.

Definition at line 2166 of file cast.h.

◆ collect_arguments() [2/2]

template<return_value_policy policy, typename... Args, typename = enable_if_t<!all_of<is_positional<Args>...>::value>>
unpacking_collector<policy> collect_arguments ( Args &&...  args)

Collect all arguments, including keywords and unpacking (only instantiated when needed)

Definition at line 2173 of file cast.h.

◆ error_string()

PYBIND11_NOINLINE std::string error_string ( )
inline

Definition at line 410 of file cast.h.

References handle::cast(), test_numpy_dtypes::scope, and scope::value.

Referenced by make_new_python_type(), and make_object_base_type().

◆ get_global_type_info()

detail::type_info* get_global_type_info ( const std::type_index &  tp)
inline

◆ get_local_type_info()

detail::type_info* get_local_type_info ( const std::type_index &  tp)
inline

Definition at line 173 of file cast.h.

References registered_local_types_cpp().

Referenced by get_type_info(), and generic_type::initialize().

◆ get_object_handle()

PYBIND11_NOINLINE handle get_object_handle ( const void *  ptr,
const detail::type_info *  type 
)
inline

◆ get_thread_state_unchecked()

PyThreadState* get_thread_state_unchecked ( )
inline

Definition at line 469 of file cast.h.

Referenced by TEST_SUBMODULE().

◆ get_type_handle()

PYBIND11_NOINLINE handle get_type_handle ( const std::type_info &  tp,
bool  throw_if_missing 
)
inline

Definition at line 205 of file cast.h.

References get_type_info(), and type_info::type.

Referenced by type::handle_of(), and isinstance_generic().

◆ get_type_info() [1/2]

PYBIND11_NOINLINE detail::type_info* get_type_info ( const std::type_index &  tp,
bool  throw_if_missing = false 
)
inline

Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.

Definition at line 190 of file cast.h.

References clean_type_id(), get_global_type_info(), get_local_type_info(), and pybind11_fail().

◆ get_type_info() [2/2]

PYBIND11_NOINLINE detail::type_info* get_type_info ( PyTypeObject *  type)
inline

Gets a single pybind11 type info for a python type.

Returns nullptr if neither the type nor any ancestors are pybind11-registered. Throws an exception if there are multiple bases–use all_type_info instead if you want to support multiple bases.

Definition at line 164 of file cast.h.

References all_type_info(), and pybind11_fail().

Referenced by type_record::add_base(), bind_map(), bind_vector(), cpp_function::dispatcher(), get_override(), get_type_handle(), implicitly_convertible(), class_< Type >::init_instance(), generic_type::initialize(), cpp_function::initialize_generic(), generic_type::install_buffer_funcs(), make_iterator(), make_key_iterator(), generic_type::mark_parents_nonsimple(), pybind11_getbuffer(), type_caster_generic::src_and_type(), type_caster_base< T >::src_and_type(), and traverse_offset_bases().

◆ isinstance_generic()

PYBIND11_NOINLINE bool isinstance_generic ( handle  obj,
const std::type_info &  tp 
)
inline

Definition at line 403 of file cast.h.

References get_type_handle(), and isinstance().

◆ keep_alive_impl()

void keep_alive_impl ( handle  nurse,
handle  patient 
)
inline

◆ load_type() [1/2]

template<typename T >
make_caster<T> load_type ( const handle handle)

Definition at line 1708 of file cast.h.

References load_type().

◆ load_type() [2/2]

template<typename T , typename SFINAE >
type_caster<T, SFINAE>& load_type ( type_caster< T, SFINAE > &  conv,
const handle handle 
)

Definition at line 1696 of file cast.h.

References type::handle_of(), and type_caster_generic::load().

Referenced by cast_ref(), and load_type().

◆ make_new_instance()

PyObject* make_new_instance ( PyTypeObject *  type)
inline

Instance creation function for all pybind11 types.

It allocates the internal instance layout for holding C++ objects and holders. Allocation is done lazily (the first time the instance is cast to a reference or pointer), and initialization is done by an __init__ function.

Definition at line 329 of file class.h.

References instance::allocate_layout().

Referenced by type_caster_generic::cast(), and pybind11_object_new().

◆ make_tuple() [1/2]

template<return_value_policy policy = return_value_policy::automatic_reference>
tuple make_tuple ( )

◆ make_tuple() [2/2]

template<return_value_policy policy = return_value_policy::automatic_reference, typename... Args>
tuple make_tuple ( Args &&...  args_)

◆ move()

template<typename T >
detail::enable_if_t<!detail::move_never<T>::value, T> move ( object &&  obj)

Definition at line 1747 of file cast.h.

References type::handle_of().

Referenced by TEST_SUBMODULE().

◆ object_or_cast()

template<typename T , enable_if_t<!is_pyobject< T >::value, int > >
object object_or_cast ( T &&  o)

Definition at line 1789 of file cast.h.

name
Annotation for function names.
Definition: attr.h:36
cast
T cast(const handle &handle)
Definition: cast.h:1718
type
Definition: pytypes.h:904
always_construct_holder
Definition: cast.h:1591
handle
\rst Holds a reference to a Python object (no reference counting)
Definition: pytypes.h:176
type_caster
Definition: cast.h:946
object::release
handle release()
\rst Resets the internal pointer to nullptr without decreasing the object's reference count.
Definition: pytypes.h:249
type_caster_holder
conditional_t< is_copy_constructible< holder_type >::value, copyable_holder_caster< type, holder_type >, move_only_holder_caster< type, holder_type > > type_caster_holder
Definition: cast.h:1589
return_value_policy
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: common.h:337
pybind11
Definition: enums_logging.hpp:5
cast_op_type
conditional_t< std::is_pointer< remove_reference_t< T > >::value, typename std::add_pointer< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type > cast_op_type
Determine suitable casting operator for pointer-or-lvalue-casting type casters.
Definition: cast.h:773
none
Definition: pytypes.h:1064
test_callbacks.value
value
Definition: test_callbacks.py:126
return_value_policy::take_ownership
@ take_ownership
Reference an existing object (i.e.
type_caster_base
Generic type caster for objects stored on the heap.
Definition: cast.h:861