Is following design possible?:
template
class Test{
public:
template
void doSomething();
//rest of things
private:
T obj;
//some things
};
Now if it was possible I'd do some explicit specializations for…
I had the (seemingly) bright idea of using extern template class std::shared_ptr in stdafx.h immediately after #include in order to prevent std::shared_ptr from being redundantly instantiated in…
I'm writing a class that has an unordered_set of its own type as a member.
Therefore I need to write a specialization for hash. This specialization needs to be defined after Foo is declared. But it seems to me as if I already need the…
Similar to this question about explicit specialisation of static const class members of a template class, and this question about explicit specialisation of a template class, but my issue is with explicit specialisation of a variable template.
My…
Previous question.
I repeat the code from the previous question to make this question self-contained. The code below compiles and does not issue any warnings if it is compiled using gcc 4.8.3. with -std=c++1y. However, it does issue warnings if…
I have a template class that looks something like this:
template class C
{
void A();
void B();
// Other stuff
};
template void C::A() { /* something */ }
template void C::B() { /* something */ }
What I…
Considering a template function like below how is it possible to do explicitly specialize one version of function for multiple types:
template
void doSomething(){
//whatever
}
The intention is to have one specialization instead of…
If I compile the following code:
//
// g++ static.cpp -o static.o
// ar rcs libstatic.a static.o
//
#include
template < typename T >
struct TemplatedClass
{
void Test( T value )
{
std::cout << "Foobar was: " << value <<…
Consider this synthetic example. I have two native C++ projects in my Visual Studio 2010 solution. One is console exe and another is lib.
There are two files in lib:
// TImage.h
template class TImage
{
public:
TImage()
{
#ifndef _LIB
…
The code below compiles and works correctly in Clang but in GCC it gives an error:
:9:14: error: explicit specialization in non-namespace scope 'class DecideType'
template class DecideType
{
template
For readability reasons, I would like to specialize a function template close to the definition of a class which is declared inside a namespace:
#include
template void my_function() {
std::cout << "my_function default" <<…