Can anyone explain why this code gives the error:
error C2039: 'RT' : is not a member of 'ConcreteTable'
(at least when compiled with VS2008 SP1)
class Record
{
};
template <class T>
class Table
{
public:
typedef typename T::RT Zot; // << error occurs here
};
class ConcreteTable : public Table<ConcreteTable>
{
public:
type...
I have a class
template <unsigned int N>
class StaticVector {
// stuff
};
How can I declare and define in this class a static factory method returning a StaticVector<3> object, sth like
StaticVector<3> create3dVec(double x1, double x2, double x2);
?
...
When declaring a template, I am used to having this kind of code:
template <class T>
But in this question, they used:
template <unsigned int N>
I checked that it compiles. But what does it mean? Is it a non-type parameter? And if so, how can we have a template without any type parameter?
...
To specialize a class template, one has to redefine all of the member functions in the underlying base template (i.e. the unspecialized class template) even if they are expected to remain mostly unchanged. What are some of the accepted methods and "best practices" to avoid this code duplication?
Thanks.
...
template<class Y>
operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release());
}
It is part of implementation of class auto_ptr in standard library.
What does this means to do?
Why there is an "auto_ptr_ref" between "operator" and "()"?
...
Hi,
I have a template class, C_Foo<T>, which is specialised in a number of ways.
struct Bar_Base { ... };
struct Bar_1 : public Bar_Base { ... };
struct Bar_2 : public Bar_Base { ... };
struct Bar_3 : public Bar_Base { ... };
class C_Foo<T> { ... };
class C_Foo_1 : public C_Foo<Bar_1> { ... };
class C_Foo_2 : public C_Foo<Bar_2> { .....
Over the past year I have heard alot about Velocity and NVelocity. Reading their documentation and doing searches on the net hasn't given me the answers I was looking for.
In what situation would I use this library in my development? What problem does it solve that didn't already have a solution?
...
I've added the following new Eclipse template via extension point. It simply adds a template for a sample testTag tag.
<!-- Add code template -->
<extension point="org.eclipse.ui.editors.templates">
<template autoinsert="true"
contextTypeId="html_tag"
description="[Description] Template populated by Snippet ...
What's a good, simple way to have alternate row coloring with freemarker?
Is this really the best way?
<#assign row=0>
<#list items as item>
<#if (row % 2) == 0>
<#assign bgcolor="green">
<#else>
<#assign bgcolor="red">
</#if>
<tr style='background-color: ${bgcolor}'><td>${item}</td></tr>
<#assign r...
Hi,
I am wondering why the following contrived example code works perfectly fine in Visual Studio 2005, but generates an error in GCC ("no matching function to call" when calling Interpolate() as shown below).
Also, how do I work around this? It seems that the error message is just a generic message because GCC did not have a more spe...
I have a DataTamplate for my ItemsControl that merely contains an Image with some other meta data. What I am trying to do is bind to the ItemsControl and have the Images be displayed with the Convas.Left and Canvas.Top that is bound via the data I give.
I have been trying my best to remove any Panels from the control via the ItemsPanel...
I have an assignment in a language-independent class, and part of it is using templated functions like
T functionName(T ¶m1[], T ¶m2[]){
// do stuff
}
I would like to write this program in C#, but I've ran into a problem.
How can I make this work in C#:
<pre><code>
T functionName(ref List<T> param1, r...
I have a set of some classes which are all capable of being constructored with an argument being an instance of a particular interface. Since they all can be constructed by this same object (and the process during which this construction happens is largely the same in all cases), I figured perhaps templating would work. Basically, I wa...
IMPORTANT: The accepted answer was accepted post-bounty, not necessarily because I felt it was the best answer.
I find myself doing things over and over when starting new projects. I create a folder, with sub-folders and then copy over some standard items like a css reset file, famfamfam icons, jquery, etc.
This got me thinking what ...
Sometimes, for a program with a lot of data, it is common to place the data in an external file. An example is a script that produces an HTML report, using an external file to hold a template.
In Java, the most recommended way to retrieve a resource of the program is to use getClass().getClassLoader().getResource() or getClass().getClas...
Hello,
We have a const array of structs, something like this:
static const SettingsSuT _table[] = { {5,1}, {1,2}, {1,1}, etc };
the structure has the following:
size_bytes:
num_items:
Other "meta data" members
So the "total size" is size_bytes*num_items for a single element. All of this information is in the const array, availabl...
Well how do i use a template on the TextBox and the PasswordBox atm i have 2 templates defined but thay contain exactly the same content....
...
I'm trying to write a branchless function to return the MAX or MIN of two integers without resorting to if (or ?:). Using the usual technique I can do this easily enough for a given word size:
inline int32 imax( int32 a, int32 b )
{
// signed for arithmetic shift
int32 mask = a - b;
// mask < 0 means MSB is 1.
return a +...
I am learning templates. Which book is worth buying for doing template programming?
I already have The C++ Programming Language and Effective C++.
...
Do I have to explicitly instantiate a function template's type when it comes to reference type deduction. If that is the case, where is the ambiguity? Let's compare following 2 code snippets:
1st: link for the code
template <typename T>
void foo(T& var, void(*func)(T&)) // T must be instantiated with int and it does .
{
++var;
}
vo...