emscripten-core / emscripten-core/emscripten
Failed to select_overload when template function have a typename after a variadic typename
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 109
Description
Please consider the following example. I made an example more and more complex. The goal is to be able to bind `struct S5` but at the current time, I can't bind `struct S4` when the template is `` with the `U` auto-deduced.
Do you have an idea ? Or is it a limitation of bind.h ? Any workaround ?
Thanks,
```
#include
using namespace emscripten;
struct S {
void f() const {}
};
struct S2 {
template
void f() const {}
};
struct S3 {
template
void f() const {}
};
struct S4 {
template
void f(U) const {}
};
struct S5 {
template
void f(U...) const {}
};
EMSCRIPTEN_BINDINGS(jessica) {
class_("S").function("f", select_overload(&S::f));
class_("S2").function("f2", select_overload(&S2::f));
class_("S3").function("f3",
select_overload(&S3::f));
// BAD1: auto deduce char.
//class_("S4").function(
// "f4", select_overload(&S4::f));
/*
/root/prog/emscripten/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:306:6: note: candidate template ignored: couldn't infer template argument 'ClassType'
auto select_overload(Signature (ClassType::*fn)) -> decltype(fn) {
^
/root/prog/emscripten/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:301:12: note: candidate template ignored: substitution failure [with Signature = void (char) const]: pointer to function type 'void (char) const' cannot have 'const' qualifier
Signature* select_overload(Signature* fn) {
~~~~~~~~~ ^
*/
// BAD2: explicit template char.
class_("S4").function(
"f4", select_overload(&S4::f));
/*
/root/prog/emscripten/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:306:6: note: candidate template ignored: couldn't infer template argument 'ClassType'
auto select_overload(Signature (ClassType::*fn)) -> decltype(fn) {
^
/root/prog/emscripten/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:301:12: note: candidate template ignored: substitution failure [with Signature = void (char) const]: pointer to function type 'void (char) const' cannot have 'const' qualifier
Signature* select_overload(Signature* fn) {
~~~~~~~~~ ^
*/
}
```
Build it with:
`emcc main.cpp -o output.js -s MODULARIZE=1 --bind -s EXPORT_NAME=ModuleTest`
Contributor guide
Assessment
This issue has not been assessed yet.