Looking at this project (http://www.savarese.com/software/libssrckdtree/) I found the definition "C++ header-only template library". At the moment I have basic C++ knowledge but would like to know what this exactly means and why this people use it on this project
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Some libraries take the form of a binary file you must link with your project, along with a header file that defines the available classes or functions. A "header-only library" would be one that includes no binary file, just a header you include in your source.
Templates are classes or functions that are customized to their particular use; they're typically defined in a header file since the compiler must read their source to customize them. You can't compile a template to a binary file until you know exactly how it's going to be used, so you include the source along with your own code and the compiler can then process them together.
It means that all of the code is in header files; there are no libraries associated with the library. What that means in practice depends—in the worst case, it means that the author has never even compiled the code:-). Most likely, it means that the code has never been tested with the exact combination of compiler, version and options that you use, and that compile times will shoot way up. On the other hand, it means that you can use the library even if the author doesn't have access to the same compiler as you, and you're not forced to use whatever options he used when he compiled the library. Or alternatively, if it is open source, you don't have to build the library yourself.
For template libraries, it's possible to provide all of the functionality in just header (.h files) because traditionally compilers needed the full definition of the template class in order to instantiate for a given type. There is nothing to put in a library unless the library is going to provide pre-instantiated versions or if there is some portion of the template library that doesn't need to be templated.