1 #ifndef VTESTBED_GUILE_TRAITS_HH     2 #define VTESTBED_GUILE_TRAITS_HH     4 #include <vtestbed/guile/wrapper.hh>    19             static inline SCM make() { 
return make_object<T>(type()); }
    20             static inline SCM make(
const T& rhs) {
    21                 return make_object<T>(type(), 
new Aspect<T>(rhs));
    23             static inline SCM make(T&& rhs) {
    24                 return make_object<T>(type(), 
new Aspect<T>(std::move(rhs)));
    30         class Traits<std::unique_ptr<T>> {
    38             static inline SCM make() { 
return make_object<T>(type()); }
    39             static inline SCM make(value_type&& rhs) {
    40                 return make_object<T>(type(), std::move(rhs));
    46         class Traits<std::any> {
    49             using value_type = std::any;
    54             static inline SCM make() { 
return make_object<value_type>(type()); }
    55             static inline SCM make(
const value_type& rhs) {
    56                 return make_object(type(), rhs);
    58             static inline SCM make(value_type&& rhs) {
    59                 return make_object(type(), std::move(rhs));
    64         template <
class T> 
inline Wrapper<T>*
    65         get_wrapper(SCM 
object) {
    66             scm_assert_foreign_object_type(Traits<T>::type(), 
object);
    67             auto* wrapper = to_wrapper<T>(
object);
    72         template <> 
inline Wrapper<std::any>*
    73         get_wrapper(SCM 
object) {
    74             scm_assert_foreign_object_type(Traits<std::any>::type(), 
object);
    75             auto* wrapper = to_wrapper<std::any>(
object);
    80         template <
class T> 
inline T*
    81         get_object(SCM 
object) {
    82             SCM type = scm_class_of(
object);
    84             if (type == Traits<T>::type()) {
    85                 ptr = to_wrapper<T>(
object)->get();
    86             } 
else if (type == Traits<std::any>::type()) {
    87                 auto* wrapper = to_wrapper<std::any>(
object);
    88                 if (!wrapper->get().has_value()) {
    91                 if (wrapper->get().type() != 
typeid(T*)) {
    94                 ptr = std::any_cast<T*>(wrapper->get());
   102         template <
class T> 
inline T*
   103         get_pointer(SCM 
object) {
   104             scm_assert_foreign_object_type(Traits<std::any>::type(), 
object);
   105             auto* wrapper = to_wrapper<std::any>(
object);
   107             if (wrapper->get().type() != 
typeid(T*)) {
   110             return std::any_cast<T*>(wrapper->get());
   117 #endif // vim:filetype=cpp Aspect that extends Guile-unaware classes and provides a pointer to the corresponding wrapper object.