c++ - Cannot get templates to compile under Visual Studio and clang -


i have following minified code.
line // vs compiles on vs not on clang,
, line // clang compiles on clang not on vs.
correct? more importantly, how make equivalent line compile on both?
versions tested clang 3.7.0, , vs 2015.

#include <functional> #include <tuple>  template<typename... args> class c {     struct b     {         std::function<void(args...)> func;         b(std::function<void(args...)> func) : func(func) { }     };     template<typename t>     struct d : b     {         using b::b;         template<size_t... i>         void call(t &t, std::index_sequence<i...>)         {             func(std::get<i>(t)...); // vs             b::template func(std::get<i>(t)...); // clang         }     };     d<std::tuple<args...>> d; public:     c(std::function<void(args...)> func) : d(func) { }     void call()     {         std::tuple<args...> t;         d.call(t, std::make_index_sequence<sizeof...(args)>());     } };  void f(int) {  }  int main() {     c<int> c(f);     c.call(); } 

i think both wrong. first use func(...) unqualified name looked using argument dependent look-up doesn't find function in base class. use of b::template func(...) uses excess keyword template. can force look-up of func in context of class using

this->func(...); 

the this-> forces necessary context. think, b::func(...) should work i'm using this->func(...) in similar situations.

i think relevant clause 14.6.2 [temp.dep] paragraph 3:

in definition of class or class template, scope of dependent base class (14.6.2.1) not examined during unqualified name lookup either @ point of definition of class template or member or during instantiation of class template or member.

the issue b dependent on template arguments of enclosing class. qualifying name this-> or base class name force look-up in base class context.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -