#include #include #include class Foo { std::string mName; public: Foo(std::string name) : mName(name) {} ~Foo() { std::cout << mName << " destructed" << std::endl; } }; std::shared_ptr foo() { return std::make_shared("Constructed from C++"); } Foo* pFoo() { return new Foo("Foo*"); } using namespace emscripten; EMSCRIPTEN_BINDINGS(Marci) { class_("Foo").smart_ptr_constructor>( "Foo", &std::make_shared); function("foo", foo); function("pFoo", pFoo, allow_raw_pointers()); }