c++ - GCC 4.6 and missing variadic-templates expansions -
i'm using code create multiple functions wrappers using variadic templates:
// compile g++ -std=c++0x $(pkg-config sigc++-2.0 --cflags --libs) test.cpp -o test #include <iostream> #include <type_traits> #include <sigc++/sigc++.h> template <typename r, typename g, typename... ts> class funcwrapper { public: funcwrapper(g object, std::string const& name, sigc::slot<r, ts...> function) {}; }; int main() { funcwrapper<void, int, int, bool, char> tst(0, "test", [] (int a, bool b, char c) {}); return exit_success; }
this code correctly compiles clang++, not g++ due known issue:
test.cpp:9:73: sorry, unimplemented: cannot expand ‘ts ...’ fixed-length argument list
i know gcc-4.7 should handle correctly, can't upgrade now... i'd have workaround make ts...
unpack correctly. i've tested suggested here in questions this one, don't seem solve issue here.
you can workaround bug with:
template<template <typename...> class t, typename... args> struct join { typedef t<args...> type; };
then replace sigc::slot<r, ts...>
typename join<sigc::slot, r, ts...>::type
(thanks chris jefferson's suggestion on gcc bug report)
Comments
Post a Comment