9#include <boost/python/detail/prefix.hpp>
10#include <boost/python/to_python_value.hpp>
12#include <boost/mpl/and.hpp>
34namespace PythonInterface {
43template <
typename T>
struct IsConstSharedPtr : std::false_type {};
47template <
typename T>
struct IsConstSharedPtr<
std::shared_ptr<const T>> : std::true_type {};
56template <
typename ConstPtrType>
struct RemoveConstImpl {
58 using ValueType =
typename std::remove_pointer<ConstPtrType>::type;
60 using NonConstValueType =
typename std::remove_const<ValueType>::type;
62 inline PyObject *operator()(
const ConstPtrType &p)
const {
64 return to_python_value<NonConstValueType *>()(
const_cast<NonConstValueType *
>(p));
67 inline PyTypeObject
const *get_pytype()
const {
69 return converter::registered<NonConstValueType *>::converters.to_python_target_type();
76template <
typename T>
struct RemoveConst_Requires_Pointer_Return_Value {};
82template <
typename ConstSharedPtr>
struct RemoveConstSharedPtrImpl {
83 using ConstElementType =
typename ConstSharedPtr::element_type;
84 using NonConstElementType =
typename std::remove_const<ConstElementType>::type;
85 using NonConstSharedPtr =
typename std::shared_ptr<NonConstElementType>;
87 inline PyObject *operator()(
const ConstSharedPtr &p)
const {
89 return to_python_value<NonConstSharedPtr>()(std::const_pointer_cast<NonConstElementType>(p));
92 inline PyTypeObject
const *get_pytype()
const {
94 return registered<NonConstSharedPtr>::converters.to_python_target_type();
101template <
typename T>
struct RemoveConstSharedPtr_Requires_SharedPtr_Const_T_Pointer_Return_Value {};
111 using type =
typename boost::mpl::if_c<std::is_pointer<T>::value, RemoveConstImpl<T>,
112 RemoveConst_Requires_Pointer_Return_Value<T>>
::type;
124 typename boost::mpl::if_c<IsConstSharedPtr<T>::value, RemoveConstSharedPtrImpl<T>,
125 RemoveConstSharedPtr_Requires_SharedPtr_Const_T_Pointer_Return_Value<T>>
::type;
Helper class which provides the Collimation Length for SANS instruments.
typename boost::mpl::if_c< IsConstSharedPtr< T >::value, RemoveConstSharedPtrImpl< T >, RemoveConstSharedPtr_Requires_SharedPtr_Const_T_Pointer_Return_Value< T > >::type type
Implements the RemoveConstSharedPtr policy.
typename boost::mpl::if_c< std::is_pointer< T >::value, RemoveConstImpl< T >, RemoveConst_Requires_Pointer_Return_Value< T > >::type type
Implements the RemoveConst policy.