specialization Questions

3

Solved

Given I have a template setup to do something on a type such as... template<typename T> class SimpleTemplate { private: T m_obj; public: void operator()() { m_obj.DoSomething(); } }; And...

4

Solved

Please explain to me why the following piece of code complies and works perfectly. I am very confused. #include<iostream> template<class A = int, class B=double> class Base {}; templa...
Paddlefish asked 9/9, 2013 at 14:27

3

Solved

I am reading the Complete Guide on Templates and it says the following: Where it is talking about class template specialization. Although it is possible to specialize a single member function of a...
Roselleroselyn asked 10/5, 2011 at 12:26

6

Solved

I have a templated class that has a data member of type std::vector<T>, where T is also a parameter of my templated class. In my template class I have quite some logic that does this: T &am...
Dendriform asked 17/1, 2013 at 17:37

5

Solved

Considering the following two usage scenarios (exactly as you see them, that is, the end-user will only be interested in using Vector2_t and Vector3_t): [1]Inheritance: template<typename T, si...
Michelson asked 7/4, 2009 at 0:3

1

Solved

I extracted the following minimal example from my production project. My machine learning project is made up of a linear algebra library, a deep learning library, and an application. The linear alg...
Meilen asked 13/11, 2022 at 13:1

5

Solved

I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? I hope so. -edit- I'll have several classes that inherit from SomeTag. I don't w...
Shewchuk asked 11/11, 2008 at 18:17

1

Solved

I want to instantiate a template from the STL, using maps,vectors, and arrays, as follows: map<some_type,vector<map<some_type,vector...>*>> elements; The ellipses is just pseudo...
Kelleykelli asked 1/3, 2022 at 22:14

3

Solved

CDI has the feature of Specialization, and I'm looking for that in the Spring world. Details. In CDI, the @Specializes annotation allows one to change the behaviour of a bean just by overriding it...
Schellens asked 13/11, 2014 at 15:33

4

Solved

Hallo! I would like to specialise only one of two template types. E.g. template <typename A, typename B> class X should have a special implementation for a single function X<float, somety...
Moultrie asked 22/9, 2010 at 11:46

3

Solved

I need to specialize template member function for some type (let's say double). It works fine while class X itself is not a template class, but when I make it template GCC starts giving compile-tim...
Quadrivial asked 1/4, 2011 at 11:47

3

Solved

I would like to specialize / subclass the requests package to add some method with custom functionality. I tried to do this: # concrete_requests.py import requests class concreteRequests(request...
Houseclean asked 19/5, 2015 at 13:49

3

Solved

I recently started playing with Arduinos, and, coming from the Java world, I am struggling to contend with the constraints of microcontroller programming. I am slipping ever closer to the Arduino 2...
Rhodie asked 24/3, 2021 at 21:48

1

Solved

Is it possible to specialize the std::allocator_traits, template like this? namespace falloc_ { template<class Tp> class FAllocator ; } // partial spec for all falloc_::FAllocator<U&gt...
Obtect asked 2/3, 2021 at 22:5

1

I have read What does template's implicit specialization mean? and its answers, but I am still not satisfied that I understand this part of Partial template specialization from cppreference.com...
Undershot asked 23/10, 2020 at 20:44

7

I have a templated class A<T, int> and two typedefs A<string, 20> and A<string, 30>. How do I override the constructor for A<string, 20> ? The following does not work: template <typ...
Interpolation asked 14/12, 2009 at 19:2

6

My full code is too long, but here is a snippet that will reflect the essence of my problem: class BPCFGParser { public: ... ... class Edge { ... ... }; class ActiveEquivClass { ... ...
Leena asked 12/12, 2009 at 19:59

6

Solved

Always considering that the following header, containing my templated class, is included in at least two .CPP files, this code compiles correctly: template <class T> class TClass { public: ...
Cochran asked 12/11, 2009 at 16:31

2

Solved

I'm playing with templates and partial specialization, but there is one specialization I don't know how to write... I'll simplify code to make it easier to read. Let's condiser template <typen...
Glottalized asked 24/5, 2011 at 17:9

6

Solved

I have a templatized class like so : template<typename T> class A { protected: std::vector<T> myVector; public: /* constructors + a bunch of member functions here */ } I would...
Bautista asked 25/8, 2014 at 12:32

1

Solved

Consider this code: #include <type_traits> template < typename > struct BB { }; template < > struct BB<float> : BB<int> { }; struct DD : BB<float> { }; templ...
Monomania asked 16/8, 2019 at 18:22

6

Solved

Let's assume we have a template function "foo": template<class T> void foo(T arg) { ... } I can make specialization for some particular type, e.g. template<> void foo(int arg) { ......
Battleplane asked 12/3, 2010 at 2:4

2

Solved

I am trying to create a global function template specialized for some given types. It looks something like that: A.h (primary template, template specialization, extern) template <typename T&gt...
Lactation asked 12/11, 2018 at 22:38

5

Solved

Given: template<typename T> inline bool f( T n ) { return n >= 0 && n <= 100; } When used with an unsigned type generates a warning: unsigned n; f( n ); // warning: compar...
Collincolline asked 21/1, 2011 at 17:56

4

Solved

In C++11 and later, is it allowed to specialize std::to_string in the std namespace for custom types? namespace std { string to_string(::MyClass const & c) { return c.toString(); } } Sample ...
Multi asked 10/4, 2016 at 17:38

© 2022 - 2025 — McMap. All rights reserved.