templates

Can templates be used to access struct variables by name?

Let's suppose I have a struct like this: struct my_struct { int a; int b; } I have a function which should set a new value for either "a" or "b". This function also requires to specify which variable to set. A typical example would be like this: void f(int which, my_struct* s, int new_value) { if(which == 0) s->a = new_va...

import all variables of parent class

You may have notice that later versions of gcc is more strict with standards (see this question) All inherited members of a template class should be called using the full name, ie. ParentClass<T>::member instead of just member But still I have a lot of old code that does not respect this. Adding using ParentClass<T>::member for ea...

Is it currently possible to get more meaningful error messages from C++ template code?

As in the title. ...

Where can I get templates for MediaWiki?

I have noticed that a lot of mediawiki-based websites use such templates as Robelbox, Ambox etc. Where can I get them and how should they be installed? ...

Should C++ template be used in this case?

I have a class that my client uses to Get() a packet. The packet contains a std::vector whose type is not known until the packet is generated internally in my Interface class (in this example, it depends on the Packet::type variable). I was wondering if template could be used for this since the Packet class is just a generic class whose...

Template error

Hi, my Rails app works fine locally. But once I put it on a server and in production mode, I get this error: ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #7 of app/views/admin/confirm.rhtml: 4: <br>Description: 5: <br><%= @description %> 6: <br>Features: 7: <% @features.each do |feature| %> 8: <br><%...

cpp iterator problem

template<class T> class mStack { private: vector<T> a; vector<T>::iterator top; public: void push(T); T pop(); mStack(); void printStack(); }; The code with above class is not getting compiled... why? What is the problem? The compiler says "expected ; above top". ...

Is there a best practice for string replacement in .aspx pages?

I have an .aspx page setup. I have a lot of placeholders that need to be replaced. First name, last name, city, state, etc, etc. How do I go about doing this in an efficient manner? Drop a bunch of... <asp:Label runat="server" id="Label_FirstName" Text="" /> ...everywhere? Or is there a way to use the data binding syntax in the n...

Django Template if tag not working under FastCGI when checking bool True

I have a strange issue specific to my Django deployment under Python 2.6 + Ubuntu + Apache 2.2 + FastCGI. If I have a template as such: {% with True as something %} {%if something%} It Worked!!! {%endif%} {%endwith%} it should output the string "It Worked!!!". It does not on my production server with mod_fastcgi. This w...

Howto Pass Filehandle to a Function for Output Streaming

Dear all, I have the following template function which prints to cout: template <typename T> void prn_vec(const std::vector < T >&arg, string sep="") { for (unsigned n = 0; n < arg.size(); n++) { cout << arg[n] << sep; } return; } // Usage: //prn_vec<int>(myVec,"\t"); /...

Getter/Setter methods of MyEclipse

I need to know which is the language used in the template code used for generating getter/setter methods in MyEclipse. 1) I want to use my static utility method in the getter/setter method template code of myeclipse. 2) I want to invoke my utility method only when the field data type is String. ...

How do you activate the MVC templates in VS2008 from a WebForms App

I'm in the process of adding ASP.NET MVC to a WebForms app. One of the neat features of an ASP.NET MVC solution that you create from scratch is that a right click on the solution explorer and Add > New Item... will give a list of templates which include the MVC templates. However, in a WebForms app these templates don't appear. I though...

C++ template static pointer-to-member initialization

I have a template class which has a static pointer-to-member, like this: template<class T, T* T::*nextptr> class Queue { T* head; T* tail; static T* T::*pnext; }; My question is how to write the initializer of the static pointer-to-member. I tried the obvious case: template<class T, T* T::*nextptr> T* Queue<T, nextptr>::*...

Naming conventions for template types?

Traditionally, the names of template types are just a single upper-case letter: template<class A, class B, class C> class Foo {}; But I hesitate to do this because it's non-descriptive and hard therefore to read. So, wouldn't something like this be better: template<class AtomT, class BioT, class ChemT> class Foo {}; I also tend to ...

Best way to implement conditional in a PHP templating system?

I'm creating a very simple PHP templating system for a custom CMS/news system. Each article has the intro and the full content (if applicable). I want to have a conditional of the form: {continue}click to continue{/continue} So if it's possible to continue, the text "click to continue" will display, otherwise, don't display this whole...

Can a django template know whether the view it is invoked from has the @login_required decorator?

Let's say that I have a system that has some pages that are public (both non-authenticated users and logged-in users can view) and others which only logged-in users can view. I want the template to show slightly different content for each of these two classes of pages. The @login_required view decorator is always used on views which on...

Formatting orb tags in MVEL

How to remove the whitespace line generat by @code{}, @if{}, @foreach{}, @end{} ect Orb Tags in the result of MVEL 2.0 Templating ? ? ? ? ...

How to put different template types into one vector

Hi, I'd like to construct a message with unknown length or number of arguments. I took a simple template like template <typename T> class Argument { public: int size; int type; T data; }; and with some overloaded addMessage (int value) { Argument<int> *a = new Argument<int>; vec.push_back(a); } (same for string and so ...

Why doesn't this Blitz++ code compile ?

I'm a blitz++ newbie. So far, so good, but I'm a bit mystified why the commented out line in the code below fails to compile with error: conversion from ‘blitz::_bz_tinyMatExpr<blitz::_bz_tinyMatrixMatrixProduct<double, double, 3, 3, 3, 3, 1, 3, 1> >’ to non-scalar type ‘const m33’ requested I'm on Debian/Lenny (g++ 4.3.2, Blitz 0.9...

Is the NVelocity project dead? Are there alternatives?

I'm looking for a template engine for .NET/C# to generate email notifications in my application. I read about NVelocity in the past and think it would fit my needs, but it seems this project is dead. Would you still recommended to use NVelocity for that purpose or can you suggest any alternatives? Note: I found some other templating en...