Я пытаюсь скомпилировать свой проект с emscripten. Естественно, в Visual Studio 2013 все в порядке.Emscripten и преобразование из std :: bind to std :: function
хранить функции в этом:
template<typename Return, typename ...Arguments>
using CBFunction = std::function<Return(Arguments...)>;
typedef unsigned int CBID;
template<typename Return, typename ...Arguments>
class CBCollection
{
std::map<CBID, CBFunction<Return, Arguments...>> cbs;
public:
CBID addCB(CBFunction<Return, Arguments...> cb)
{
CBID id = findFreeID();
cbs[id] = cb;
return id;
}
...
}
Позже я могу добавить простые и члены функции:
CBCollection<void, MatrixStack, float> BeforeRenderCBs;
...
AnimatedSprite::AnimatedSprite()
{
using namespace placeholders;
BeforeRenderCBs.addCB(bind(&AnimatedSprite::beforeRenderCB, this, _1, _2));
}
с emscripten это результат:
<scratch space>:624:1: note: expanded from here
"C:/Development/LexUnitEngine/Engine/include/Buffer.h"
^
C:\Development\LexUnitEngine\Engine\source\AnimatedSprite.cpp:76:24: error: no viable conversion from '__bind<void (AnimatedSprite::*)(MatrixStack &, float), AnimatedSprite *, std::__1::placeholders::__ph<1> &, std::__1::placeholders::__ph<2> &>' to 'CBFunction<void, MatrixStack, float>'
(aka 'std::__1::function<void (MatrixStack, float)>')
BeforeRenderCBs.addCB(bind(&AnimatedSprite::beforeRenderCB, this, _1, _2));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\PROGRA~1\EMSCRI~1\EMSCRI~1\129~1.0\system\include\libcxx\functional:1448:5: note: candidate constructor not viable: no known conversion from '__bind<void (AnimatedSprite::*)(MatrixStack &, float), AnimatedSprite *, std::__1::placeholders::__ph<1> &, std::__1::placeholders::__ph<2> &>' to
'nullptr_t' for 1st argument
function(nullptr_t) _NOEXCEPT : __f_(0) {}
^
C:\PROGRA~1\EMSCRI~1\EMSCRI~1\129~1.0\system\include\libcxx\functional:1449:5: note: candidate constructor not viable: no known conversion from '__bind<void (AnimatedSprite::*)(MatrixStack &, float), AnimatedSprite *, std::__1::placeholders::__ph<1> &, std::__1::placeholders::__ph<2> &>' to
'const std::__1::function<void (MatrixStack, float)> &' for 1st argument
function(const function&);
^
C:\PROGRA~1\EMSCRI~1\EMSCRI~1\129~1.0\system\include\libcxx\functional:1450:5: note: candidate constructor not viable: no known conversion from '__bind<void (AnimatedSprite::*)(MatrixStack &, float), AnimatedSprite *, std::__1::placeholders::__ph<1> &, std::__1::placeholders::__ph<2> &>' to
'std::__1::function<void (MatrixStack, float)> &&' for 1st argument
function(function&&) _NOEXCEPT;
^
C:\PROGRA~1\EMSCRI~1\EMSCRI~1\129~1.0\system\include\libcxx\functional:1454:41: note: candidate template ignored: disabled by 'enable_if' [with _Fp = std::__1::__bind<void (AnimatedSprite::*)(MatrixStack &, float), AnimatedSprite *, std::__1::placeholders::__ph<1> &, std::__1::placeholders::__ph<2>
&>]
__callable<_Fp>::value &&
^
C:/Development/LexUnitEngine/Engine/include/CallbackCollection.h:49:46: note: passing argument to parameter 'cb' here
CBID addCB(CBFunction<Return, Arguments...> cb)
^
Я пытался переключите CBFunction на
std::function<Return(Arguments...)
везде, но это не решило проблему, и мне нужны CBFunction другие места.
emscripten версия 1.29.0, лязг 3.4