C++ templates declare in .h, define in .hpp

后端 未结 7 1730
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 05:08

I saw some code in which the developer defined a class template in a .h file, and defined its methods in a .hpp file. This caught me a bit by surprise.

Are there are

7条回答
  •  旧巷少年郎
    2020-12-05 05:47

    The Boost library uses ".hpp" for headers containing the declaration AND implementation. In such cases, there is no need to link with the (pre-compiled) library.

    In respect with Boost idea, such extension as ".inl" could be a good idea to describe the "implementation" source file of a template declaration header.

提交回复
热议问题