I would like to provide a library that provides template code. But I would also like to keep the maximum possible ownership of this code (generated code), when I can guess the use of different ordinary types of my template. Here is an example of what I'm trying to do:
lib1.h
#include <iostream>
template<int N>
void print_me() {
std::cout << "I am function number " << N << std::endl;
}
lib1.cpp
#include "lib1.h"
template void print_me<0>();
template void print_me<1>();
I will compile my library using:
g ++ -shared -fPIC lib1.cpp -o lib1.so
And when I use my library:
main.cpp
#include <lib1.h>
int main() {
print_me<0>();
print_me<1>();
print_me<2>();
}
Compiled with
g ++ main.cpp -l1
, print_me < 0 > () print_me < 1 > () lib1.so print_me < 2 > (), ( nm - ). , , ! 0 1 lib1.so, . (0, 1 2) , . , 0 1 main.cpp, , ( main.cpp).
(, lib1.h) main.cpp, - ?