Questions tagged [template-instantiation]
80 questions
0
votes
0 answers
Exported template class instantiation leads to compilation error with msvc
I'm trying to compile a code similar to the following one, it is part of a library dll which I'm trying to compile with MS Visual Compiler :
#include
#include
0
votes
1 answer
dllexport class template instances (specializations), reducing compilation time for header-only template libraries
Is it possible to export some of the class template instances, while leaving to a library's user the ability of generating other specializations of a given class template (when compiling the executable).
Given I have a public header
//…

Sergey Kolesnik
- 3,009
- 1
- 8
- 28
0
votes
1 answer
How does the object creation work for this class template?
I have this code below which I was trying out from a course I was undertaking, that pretty much does what is expected to do
#include
template
class A {
public:
T x;
U y;
A(T x, U y) { std::cout <<…

Inian
- 80,270
- 14
- 142
- 161
0
votes
3 answers
Generate code instantiating a function template with different arguments
Given the following code:
#include
template
int foo(int v) // dummy parameter
{
return v * X + v / Y; // dummy calculation
}
int main()
{
// x, y, v are only known at runtime
int x = 4;
int y = 6;
int…

Tobias Hermann
- 9,936
- 6
- 61
- 134
0
votes
2 answers
Explicit Instantiation of Templated Overloaded Operator
The following code works:
struct A
{
int v = 3;
};
namespace Foo
{
template
int operator+(A const& lhs, A const& rhs)
{
return lhs.v + rhs.v + k;
}
}
using Foo::operator+;
int main()
{
A a1, a2;
std::cout…

Adi Shavit
- 16,743
- 5
- 67
- 137