简体   繁体   中英

How to get rid of multiple definitions of fully specialized function templates?

I'm having a problem with linking the objects of one of my C++ applications. The source files are all compiled into object files, but many of them rely on the same library, which has a fully specialised function template. The linker complains when trying to link them all together. I understand why this is, but I don't understand how to fix it.

I found this , which explains the problem exactly, but the forum thread never got to a point where the OP asked for a solution. Womp, womp.

How do I compile all the source files, but only get the specialised functions from the library once?

The problem there is that the specialization also has the implementation in the header, which is wrong.

You should either move the implementation to a source file, or mark the method as inline .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM