Sha256: 58b5789b669d0af934fa64eaf304b24e35dc2540a45b472e89098e982aa6257e

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

#ifndef Rice__detail__to_ruby_defn__hpp_
#define Rice__detail__to_ruby_defn__hpp_

#include "../traits/rice_traits.hpp"

namespace Rice
{
  namespace detail
  {
    //! Convert a C++ object to Ruby.
    /*! If x is a pointer, wraps the pointee as a Ruby object.  If x is an
     *  Object, returns x.
     *
     *  If no conversion exists a compile-time error is generated.
     *
     *  \param x the object to convert.
     *  \return a Ruby representation of the C++ object.
     *
     *  Example:
     *  \code
     *    rb_p(to_ruby(42));
     *
     *    Foo * p_foo = new Foo();
     *    rb_p(to_ruby(p_foo));
     *  \endcode
     */
    template <typename T>
    class To_Ruby;
   
    // Helper template function that let's users avoid having to specify the template type - its deduced
    template <typename T>
    VALUE to_ruby(T&& x)
    {
      using Unqualified_T = remove_cv_recursive_t<T>;
      return To_Ruby<Unqualified_T>().convert(std::forward<T>(x));
    }

    // Helper template function that let's users avoid having to specify the template type - its deduced
    template <typename T>
    VALUE to_ruby(T* x)
    {
      using Unqualified_T = remove_cv_recursive_t<T>;
      return To_Ruby<Unqualified_T*>().convert(x);
    }
  } // detail
} // Rice

#endif // Rice__detail__to_ruby_defn__hpp_

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rice-4.3.3 rice/detail/to_ruby_defn.hpp
rice-4.3.2 rice/detail/to_ruby_defn.hpp
rice-4.3.1 rice/detail/to_ruby_defn.hpp
rice-4.3.0 rice/detail/to_ruby_defn.hpp
rice-4.2.1 rice/detail/to_ruby_defn.hpp
rice-4.2.0 rice/detail/to_ruby_defn.hpp
rice-4.1.0 rice/detail/to_ruby_defn.hpp