templates

What is the lexically correct statement in Velocity Template Language

The following line of code is a generic version of a line in a template I'm working on. I have locked at the Velocity Template Language Documentation but I keep gettting errors no matter how I format this statement. This is my first real experience with VTL so I was hoping to get a set of experienced eyes on the issue: #set($includeAt...

Explicit template instantiation with member template function

I have a template class with a template member function. I want to explicitly instantiate the class to avoid a drastic compilation slowdown. I am using g++ 4.1.2. I get ambiguous template specialization errors from the compiler. This the shortest code which will reproduce the problem: template <class T, class S > class Test { public: ...

Eclipse Java: Template for the 'create field' quick fix suggestion?

Hi. In constructors I very often assign to a non-existing field and choose Ctrl+1 "Create field 'memberField' in type 'CurrentType'". The problem is that I want the field to be final by default, which it isn't. Is there a template for this quick fix somewhere? Thanks. ...

Typedef (alias) of an generic class

Hello, is it possible in C++ to create an alias of template class (without specifying parameters)? typedef std::map myOwnMap; doesn't work. And if not, is there any good reason? ...

MySQL: select on a table with tablename from a recordset

I would like to do this in one step so I would like to know how can I: table a (documents) has: pk, document_id, template_id table b (templates) has: pk, template_id, template_table_name table c (template_table_name_1) has: pk, document_id, document_specific_columns so... I would like to query table a, get document_id and template_id...

Why does the compiler not resolve this call to a template function?

Hi, In below program why does the compiler generate an error for the call to the printMax template function and not the call to the printMaxInts function? #include <iostream> template<class A> void printMax(A a,A b) { A c = a>b?a:b; std::cout<<c; } void printMaxInts(int a ,int b) { int c = a>b?a:b; std::cout<<c; } int...

Is there a Javascript template system that wraps HTML?

I wonder if there are anything like a Javascript template system that wraps HTML, so that we don't have to deal with HTML directly (yeah, i know it's a bad idea, but just out of curiosity). So instead of writing HTML: <body> <div id="title">Great work!</div> <span>My name is Peter</span> </body> We write in Json: body: [ {div:...

"too many template-parameter-lists" error when specializing a member function

Hi All, I would like to define some template member methods inside a template class like so: template <typename T> class CallSometing { public: void call (T tObj); // 1st template <typename A> void call (T tObj, A aObj); // 2nd template <typename A> template <typename B> void call (T tObj, A aObj, B bObj); // 3r...

Windows API GetOpenFileName with template and hook

I'm trying to use a template with GetOpenFileName without success. I've found very little on this topic in the MSDN or on the web. I've based my attempt on what I saw here http://visual-c.itags.org/visual-c-c++/77687/ My code follows. The TEMPLATE comments show where I made changes to code b4 the template attempt; mainly to remove ...

use sfinae to test namespace members existence

Hello, I was trying to figure out if it is possible to use sfinae to test namespace member existence. Google is rather silent about it. I've tried the following code, but it fails. namespace xyz{ struct abc{}; } struct abc{}; struct test_xyz{ typedef char yes; typedef struct{ char a[2]; } no; template <class C> static yes test(...

Eclipse 'Anonymous Inner Type' - autocomplete

Hello everyone, Sometimes I tend using autocomplete from eclipse (3.5) for anonymous inner types. For some reason eclipse always puts ending-parenthesis and semicolon in wrong order. A small example: button.addActionListener( new Act... ) // <-- Pressing Autocomplete (strg+space) results in: button.addActionListener( new ActionListe...

I need a template system (XML-based) that can be used both with PHP (server-side) and Javascript (client side)

Hi there, I am looking for a good template system (preferably XML-based) that provides implementations both for PHP and Javascript. This would enable me to write templates for some elements that are either: - Populated on server side : when simply displaying those, in "reader" mode. - Or instantiated / populated on client side : whe...

gpl licence concern

when you use and edit something under GPL licence ? say a program or website design template , how should I write the copy rights now of the new product ? p.s "licence are PITA I never get the sooo many terms and regulations!, i just need simple human answer please." ...

Inheritance and templates and virtual functions ( this can get messy)

Just finding my way around templates so was trying out a few stuff. Let me know what I am doing wrong here. I am trying to overload a inherited templates virtual method. // class templates #include <iostream> using namespace std; template <class T, class A> class mypair { T a, b; public: mypair (T first, T second) {a...

CRTP and templated expressions

In a complex library that uses templated expressions, and the Curiously Recursive Template Pattern (CRTP), I need some overloaded operators to be specialized with base classes, but operations involving their derived classes are not finding the base-class specialization. Ie: if an operator is defined for BaseA< T > + BaseA< T >, then c...

Cross source file template instantiation and use

I have a class with several template member functions that I would like to distribute among several source files to speed up compilation times. (The templates are implementation details and are not intended to be used outside the class, hence their definition in sources not headers.) How would I go about splitting up these templates in ...

visitor template for boost::variant

Hi, I would like to use a boost.variant<T0,T1,T2> as a parameter to a template 'Visitor' class which would provide visitor operators as required by the boost.variant visitor mechanism, in this case all returning void i.e., void operator()(T0 value); void operator()(T1 value); void operator()(T2 value); The template would also have fo...

Simple reference counting: smart pointers

I would like to implement a simple reference counting using smart pointers. The variable pointer represents pointer to stored object, reference_count represents total count of copies of the object. if we initialize an object using NULL: reference_count = -1 else reference_count = 1 copy ctor and operator = increment reference_count des...

Should I use the template to render JSON or use Controller returning JSON in RoR?

That's my great doubt. We have a project in RoR and we are making it more dynamic, using Ajax calls. They want that I put literal JSON in html templates and parse it with eval() in javascript, avoiding to putting exception into Controller to return response as JSON directly. Example: WhateverControoler#index -> will render views/whatev...

Google Appengine: objects passed to a template changes their addresses in memory

I query an array of objects from DB, then compare addresses of the objects in Model and in View. They differs! Why? I want access the same objects as from template as from business logics code. I wouldn't ask for it but it really bother me because function calls are disallowed in Django-styled templates and I even can't assign custom pr...