So if I want to partially specialize it just for K, then it would be
template<typename T> template<>
typename void A<T>::foo(double)(){}
Is that correct?
Type: Posts; User: cunnus88
So if I want to partially specialize it just for K, then it would be
template<typename T> template<>
typename void A<T>::foo(double)(){}
Is that correct?
Wow. A hunch I had is actually right. But that syntax is pretty funky. I mean
template<> template<>
Really?
Say you have:
template <typename T>
class A {
template <typename K>
void foo(T, K);
};
You can do that in Java because enums are class objects there, but enums in C/C++ are just souped up const ints, so if you print it, all you're going to get is a number. You'll have to write your own...
Oh wow. That worked.
Thanks Elysia. You're a programming master! How the hell do you know every thing?
Could you tell me how? I've looked at several articles on template specialization and it doesn't seem as if specialization of template member functions is possible. I've tried some variations myself...
Sorry, I didn't give full details. The template node itself is subsumed under several other classes in different ways. Like
template<typename T>
class OneClass {
node<T> one_node;
};
...
It's a solution I came up with to a template specialization problem which is really crappy. And if there are any other, better, cleaner ways to do it, please enlighten me.
I have a templated node...
You need a stop condition for your "for" loops. Instead of
for (int m=1; str[m]; m=m+2)
it should be
for (int m=1; m<9; m=m+2)
True. Consistency is important.
My previous understanding was that static member variables have to be defined outside the class body, not just declared. Isn't a statement like
int A::x;
allocating memory as well, and...
After some googling and tinkering, I've found a solution, but I can't say I understand why it works.
// in a header file
template <typename T>
class A {
static stl_container<T*>* container;...
The more I think about it, the more I have a feeling I have to change my design but here's the problem, anyway.
I have a templated class. This class has a static class member variable, which is a...
Yeah, you're right. The more I think about it, it seems that I need to rethink my design.
I have two classes, one derived from the other, and a virtual get function is supposed to return a pointer to a container with different element types depending on who's getting called. Simplified:
...
Yes, you are. Smile. (Do you honestly expect a civilized answer responding with crap like that?)
I'm using the hash_map that comes with gcc 4.0 (i.e. <ext/hash_map>) and I have no idea why the destructor is being called on a key object.
I have a class object for which I've defined a hash...
So if I don't have a corresponding "delete" statement in some_function, this is a memory leak?
So I guess if you have a function that takes a pointer parameter, but has no idea where the...
If there were code like
beginning_of_scope
some_function(new some_object);
end_of_scope
What happens to the new instance of some_object after exiting end_of_scope? Is it freed...
I discovered this just now. My compiled fine on my Mac with gcc 4.0, but when I tried to compile it on a Linux machine with gcc 4.2.2, it popped an error message. I'll just write code for standard...
Thanks. I had misunderstood how accumulate functions. Now I know better.
I'm trying to implement a standard deviation routine using templates but I hit a snag with the bind2nd operator and I just don't get it:
template<typename T> struct minus_squared
: public...
I'm trying to get rid of some inefficiencies in my code. The current (simplified) version is this:
class matrix {
double data*;
matrix& operator=(const matrix& m) {
I had to interface with zlib so I downloaded a thing called gzstream from http://www.cs.unc.edu/Research/compgeom/gzstream/
The problem is that when I try to reset the EOF flags on an igzstream...
Thanks! That makes sense.