C++ templates, undefined reference

前端 未结 4 994
無奈伤痛
無奈伤痛 2020-11-27 07:08

I have a function declared like so:

template  
T read();

and defined like so:

template          


        
4条回答
  •  离开以前
    2020-11-27 07:58

    The best practice with template functions is to define them in header files. They are created at compile time so compiler has to have definition around to do so.

    When export for templates would be more supported this wouldn't be the case though but right now it still hardly can be used.

提交回复
热议问题