Random Chitchat 2012-2016
Would anyone object if I use explicit template instantiation?
Thanks given by:
Flame war? Here's a suggestion for a suitable weapon:

[Image: flammenwerfer_o_610625.jpg]
Thanks given by:
(09-11-2014, 03:19 AM)worktycho Wrote: Would anyone object if I use explicit template instantiation?

I'm not exactly sure what that means, simple example perhaps? Will it compile in MSVC2008? Smile
Thanks given by:
simple example:

header file
Code:
template <class T>
class Foo
{
      bar(T a);
      T x;
}

code file
Code:
template <class T>
Foo::bar(T a)
{
      x = a;
}

// actual instantiation
template Foo<int>;

If Foo is only used for a few values of T then by explicitly instantiating the template we can move the template implementation to separate translation unit. I want to use this to allow testing code to replace types with Mocks without having to make everything inline.

As to will it work on MSVC, that depends on how buggy it is Smile . It was in c++98. If MSVC refuses to compile it then microsoft have a workaround that involves an anonymous namespace, a static function and some code.
Thanks given by:
Looks okay to me, a bit on the weird side, templates in cpp files, but it makes some sense. Go ahead.
Thanks given by:
So I had to use the first dynamic_cast<> in MCS Sad
The cDropSpenserEntity class inherits from two bases and so it cannot be C-style-cast to the second base class. This had broken the redstone simulator on droppers, I wonder why no-one noticed earlier.
Thanks given by:
This keeps reinforcing my point that we need unit tests, particularly for the redstone simulator. I should be ably to decouple it a little more easily with explicit instanciations.

I may be able to get rid of the dynamic_cast if I do that.
Thanks given by:
C++14 has been ratified. So can we start using it in 2017/2018?
Thanks given by:
Just got a very weird error message. It appears that if you have a template with a parameter of type char clang assumes that the parameter is a char so helpfully displays the ASCII character rather than the code. Which lead to an error message talking about a missing template specialisation for block type 'M'
Thanks given by:
We have now reached 7000 commits!
Thanks given by:




Users browsing this thread: 10 Guest(s)