Can somebody explain to me why the following works:
template<class T> class MyTemplateClass {
public:
T * ptr;
};
int main(int argc, char** argv) {
MyTemplateClass<double[5]> a;
a.ptr = new double[10][5];
a.ptr[2][3] = 7;
printf("%g\n", a.ptr[2][3]);
return 0;
}
But this doesn't:
class MyClass {
public:
d...
Having used Seaside the past few years I've found template systems to be a bad code smell. Is there a framework for .net using something similar to the Seaside canvas system for generating html, css and javascript? Or else a way to avoid the duplication I tend to find in templates.
[Edit]
NHaml does not come close to what I'm looking f...
When I try to compile this code:
struct BasicVertexProperties
{
Vect3Df position;
};
struct BasicEdgeProperties
{
};
template < typename VERTEXPROPERTIES, typename EDGEPROPERTIES >
class Graph
{
typedef adjacency_list<
setS, // disallow parallel edges
vecS, // vertex container
bidirectionalS, // directed graph
property<verte...
Does anyone know the syntax for an out-of-declaration template method in a template class.
for instance:
template<class TYPE>
class thing
{
public :
void do_very_little();
template<class INNER_TYPE>
INNER_TYPE do_stuff();
};
The first method is defined:
template<class TYPE>
void thing<TYPE>::do_very_little()
{
}
How do I do...
So, I'm passing an object with a "content" property that contains html.
<div>{{ myobject.content }}</div>
I want to be able to output the content so that the characters are rendered as the html characters.
The contents of "conent" might be: <p>Hello</p>
I want this to be sent to the browser as: pHello/p>
Is there something I can...
Second time asking more details ...
I'd like to have a project wide templagetags directory to have the common
tags used by all Apps, then each app can have their own tags if need so.
Let say that I have:
proj1/app1
proj1/app1/templatetags/app1_tags.py
proj1/app2
proj1/app2/templatetags/app2_tags.py
proj1/templatetags/proj1_tags.py
...
I've had a major annoyance with the Borland/Codegear C++ Builder IDE for some time now. When I code I always use a standard layout for the code files. I have a standard header that I use, including, ie. the Licens of the file, filename, date, etc.
But I haven't been able to find anywhere to insert this, so that when I - for instance - c...
I need to choose a good template engine to generate documents in our application. The requirements are:
Generate Microsoft Word and PDF at least
Good templating capabilities including support for simple replacable parameters, arrays/lists, and hierarchies if possible
Allow to include custom graphics
Ideally templates should be editable...
Are there any differences, limitations or gotchas between NDjango and Django templates? I'm specifically interested in implementing them in future ASP.NET MVC projects.
I'm certain I won't be able to use any of my custom template tags that I've written for Django, but would I be able to port them to NDjango?
...
name class an id, a first & a last attributes
In my view.py, I fetch a name object from the database and pass it into the index.html template.
In my templagetags/my_tags.py, I have a filter my_private_tag(value, arg) that takes value and an arg. It appends the arg to the value and returns the result.
def my_private_tag(value, arg):
...
I have MANY small "Test Projects" where I put together just enough code to prove or disprove some idea I'm working on. Some time (sometimes several months) later, I need to use some of this code. It can take hours searching through poorly named folders to find the gem of code I'm looking for.
It's not enough to be worth a Blog or wiki...
why doesn't {% url myVar %} where myVar = 'jack.johnson' doesn't work ?
The view is fine, the urls.py is:
url(r'^(?P[A-Za-z0-9-._]+)/$', overview, name='user_profile'),
...
Why does the following code give me an error (g++ 4.1.2)?
template<class A>
class Foo {
public:
typedef std::vector<A> AVec;
AVec* foo();
};
template<class A>
Foo<A>::AVec* Foo<A>::foo() { // error on this line
return NULL;
}
The error is:
error: expected constructor, destructor, or type conversion before '*' token
How am I ...
i am interested to synthesize a few classes which will have some/all of the functions as in the class res_obj.
struct res_obj
{
int* res_;
res_obj() ///method 1 : no arg constructor
: res_(0)
{
}
explicit res_obj(int value) ///method 2 : single arg constructor
: res_(new int(value))
{
}
...
I was wondering if anyone has experience with using some kind of templating language for generating the html output in the component's renderer.
It seems to me that doing stuff like the following is difficult to maintain if your component rendering will suffer changes during its life.
writer.write('\n');
writer.startElement("script",...
Background
Consider the following:
template <unsigned N>
struct Fibonacci
{
enum
{
value = Fibonacci<N-1>::value + Fibonacci<N-2>::value
};
};
template <>
struct Fibonacci<1>
{
enum
{
value = 1
};
};
template <>
struct Fibonacci<0>
{
enum
{
value = 0
};
};
This is a common example ...
Hey, I'm trying to figure out if it's possible to "overload" a template class deffinition with expression parameters. Kind of like the following snippet of code.
template<class T>
class Test
{
public:
T testvar;
Test()
{
testvar = 5;
cout << "Testvar: " << testvar << endl;
}
};
template<class T>
class Test<T,...
I need a C++ template that, given a type and an object of that type, it can make a decision based on whether the type is an integer or not, while being able to access the actual objects. I tried this
template <typename T, T &N>
struct C {
enum { Value = 0 };
};
template <int &N>
struct C<int, N> {
enum { Value = N };
};
but i...
How do I make a template specialization that takes 2 parameters versus the normal 1?
I was building a pointer class and now I thought about extending to make an array but if I try something like this:
template<class T,int s> class pointer{};
template<class T> class pointer{};
class mama{};
int main(){
pointer<mama> m;
}
It gives ...
I asked this question earlier. I am intrigued by std::set but I have another confusing scenario.
Namely, is the following code legal, portable c++ for T=std::vector and T=std::set:
template <typename T>
void remove_elements(T& collection, int removal_value)
{
typename T::iterator new_end =
std::remove(collection.begin(), c...