c++ - Including a header with template into a source file causing an error -


i have following class includes template method create inside header:

network.h

class network {     network(cudnnhandle_t handle, std::vector<int> batch);     template <typename t, typename... args, typename std::enable_if<std::is_same<block, t>::value>::type* = nullptr> t create(args&&... args)      {         block block(handle_, batch_, std::forward<args>(args)...);         blocks_.push_back(block);         return block;     } }; 

i have class dacn inherits network class , uses template method inside it's constructor:

dacn.h

class dacn : public network { public:     dacn(cudnnhandle_t handle, std::vector<int> batch, int temporal_stride, int action_dim) : network(handle,batch)     {         auto s  = create<block>(temporal_stride,84,84);     } }; 

at point compiles fine without errors. construct dacn.cpp file , include dacn.h file:

dacn.cpp

#include "dacn.h" 

i following error when compiling dacn.cpp file:

dacn.h(13): error: no instance of overloaded function "dacn::create" matches argument list argument types are: (int, int, int)

why error?

i found problem. compiling nvcc because compiling cuda code. apparently nvcc has problems dealing complex template patterns. rearranged things such nvcc calls gcc compiler on template substantiation part of code.

sorry taking time.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -