8. embind overload 重载

#include 
#include <string>

using namespace emscripten;

class OverloadClass {
public:
    OverloadClass() = default;
    std::string foo () const {
        return "Signature: ()";
    }

    std::string foo (int x) {
        return "Signature: (int x)";
    }

    std::string foo (int x, int y) {
        return "Signature: (int x, int y)";
    }
};

EMSCRIPTEN_BINDINGS(module) {
  class_("OverloadClass")
      .constructor<>()
      .function("foo_v", select_overloadstring(void) const>(&OverloadClass::foo))
      .function("foo_i", select_overloadstring(int)>(&OverloadClass::foo))
      .function("foo_ii", select_overloadstring(int, int)>(&OverloadClass::foo));
}

 

你可能感兴趣的:(8. embind overload 重载)