N
Noah Roberts
I thought I knew how to do this but either I don't or my compiler is a
POS (which may be true anyway). I have:
namespace whatnot {
template < typename T >
struct bob
{
void f(int) { }
};
}
Elsewhere, where I have definitions for a particular object I need to
use bob on:
#include <thingy.h>
namespace whatnot {
template < >
void bob<thigy>::f(int);
}
in a cpp:
#include "specialization.h"
namespace whatnot {
template < >
void bob<thingy>::f(int) { thingy::do_it(); }
}
}
When I try this though I get linker errors saying that void bob
<thingy>::f(int) is missing. Surprisingly, to me anyway, if I put the
body of my f specialization into the specialization.h file everything
seems to work ok, and I'm not using the inline keyword.
I thought I recalled a conversation elsewhere that implied the "template
< >" was not needed for cases like this so I tried removing it in
various different ways. No go. Google searches seem to indicate the
above should work.
So, I'm probably being stupid, so what is it?
POS (which may be true anyway). I have:
namespace whatnot {
template < typename T >
struct bob
{
void f(int) { }
};
}
Elsewhere, where I have definitions for a particular object I need to
use bob on:
#include <thingy.h>
namespace whatnot {
template < >
void bob<thigy>::f(int);
}
in a cpp:
#include "specialization.h"
namespace whatnot {
template < >
void bob<thingy>::f(int) { thingy::do_it(); }
}
}
When I try this though I get linker errors saying that void bob
<thingy>::f(int) is missing. Surprisingly, to me anyway, if I put the
body of my f specialization into the specialization.h file everything
seems to work ok, and I'm not using the inline keyword.
I thought I recalled a conversation elsewhere that implied the "template
< >" was not needed for cases like this so I tried removing it in
various different ways. No go. Google searches seem to indicate the
above should work.
So, I'm probably being stupid, so what is it?