Небольшой воспроизводимый пример мог бы выглядеть так:
Код: Выделить всё
// header.hpp
template
struct Foo {
T foo(T t);
};
// impl1.cpp
#include "header.hpp"
template
T Foo::foo(T t) {
return t + 1;
}
template struct Foo;
template struct Foo;
// impl2.cpp
#include "header.hpp"
template
T Foo::foo(T t) {
return t + 0.1;
}
template struct Foo;
template struct Foo;
// main.cpp
#include "header.hpp"
#include
int main() {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78473986/different-template-instantiations-in-multiple-cpp-files[/url]
Мобильная версия