So in writing a C++ template class, I have defined a method that returns an object of the templated type, as such:
template
class Foo
{
public
Do you really want to return an un-initialized value from this function? Sounds like it could lead to a whole lot of crap later down the line.
Why don't you use an appropriate wrapper - if you have access to boost, consider boost::optional
. This way, if you don't initialize it, it can be tested properly.