::rvalue_from_python_storage&lt;custom_string&gt;*)
          data)-&gt;storage.bytes;
      new (storage) custom_string(value);
      data-&gt;convertible = storage;
    }
  };

  custom_string hello() { return custom_string(&quot;Hello world.&quot;); }

  std::size_t size(custom_string const&amp; s) { return s.value().size(); }

  void init_module()
  {
    using namespace boost::python;

    boost::python::to_python_converter&lt;
      custom_string,
      custom_string_to_python_str&gt;();

    custom_s