templates

C# generics compared to C++ templates.

Possible Duplicate: What are the differences between Generics in C# and Java and Templates in C++? What are the differences between C# generics compared to C++ templates? I understand that they do not solve exactly the same problem, so what are the pros and cons of both? ...

How to create project and item templates?

I want to know how to create project and item templates in VS2008. Can anybody explain to me step-by-step how to do that? I am new to templates. ...

Can template polymorphism be used in place of OO polymorphism?

I am trying to get my head around applying template programming (and at some future point, template metaprogramming) to real-world scenarios. One problem I am finding is that C++ Templates and Polymorphism don't always play together the way I want. My question is if the way I'm trying to apply template programming is improper (and I sho...

How can I use literal DOM markup as a Prototype Template?

Prototype's Template class allows you to easily substitute values into a string template. Instead of declaring the Template source-string in my code, I want to extract the source-string from the DOM. For example, in my markup I have an element: <div id="template1"> <img src="#{src}" title="#{title}" /> </div> I want to create the ...

Why is the use of typedef in this template necessary?

When I compile this code in Visual Studio 2005: template <class T> class CFooVector : public std::vector<CFoo<T>> { public: void SetToFirst( typename std::vector<CFoo<T>>::iterator & iter ); }; template <class T> void CFooVector<T>::SetToFirst( typename std::vector<CFoo<T>>::iterator & iter ) { iter = begin(); ...

C++: Default values for template arguments other than the last ones?

Hi all, I have my templated container class that looks like this: template< class KeyType, class ValueType, class KeyCompareFunctor = AnObnoxiouslyLongSequenceOfCharacters<KeyType>, class ValueCompareFunctor = AnObnoxiouslyLongSequenceOfCharacters<ValueType> > class MyClass { [...] } Which means that ...

Python string templater

I'm using this REST web service, which returns various templated strings as urls, for example: "http://api.app.com/{foo}" In Ruby, I can then use url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar') to get "http://api.app.com/bar" Is there any way to do this in Python? I know about %() templates, b...

C++ Template Metaprogramming - Is it possible to output the generated code?

I would like to debug some templated code to understand it better. Unfortunately I'm new to template metaprogramming and it IS hard for me to get in. When I try to output the preprocessed source files I get 125 000 lines of code :/ So is there a way I can see the generated Code? (The library I'm using is SeqAn) ...

django template forloop.counter question

Hi all, i have many fields in my form i was trying to apply different css to neighbour forms fields like <li class='thiscolor' > <field> </li> <li class='thatcolor' > <field> </li> if there a way like {% for field in form %} **{% if forloop.counter%2 == 0 %}** <li class='thiscolor'> {% else%} <li class='thatcolo...

asp.net html templating

I am thinking about a really simple html templating system to implement in asp.net. Basically given a .html file with a couple of placeholders like [menu] and [content] it would grab the appropriate data and merge it with the html and the display the page. I'd like to be able to use asp.net stuff like controls and postback but this isn...

What's wrong with my Visual Studio 2008 template?

I'm trying to create my own class template for Visual Studio called "Public Class". I followed the official MSDN instructions on how to manually create an Item Template pretty much to the letter, but I'm having no luck getting the template to show up in the "My Templates" section of the "Add New Item" dialog. I placed PublicClass.zip i...

Django cross-site reverse URLs

Probably simple question and I'm just missing something, but I'm stuck out of ideas. I have Django project serving several sites with distinct sessions.py and completely different ROOT_URLCONFs. One site handles user registration, authentication and profile settings, other site (on another domain) acts as file manager and so on. Sites a...

Programs compiles in g++ but exits with linker errors in gcc

I'm trying out the solution to a question about specialized template classes. This code with a compiles fine in g++, but throws up linker errors when compiled with gcc. What's the cause of these errors ? $ g++ traits2.cpp $ gcc traits2.cpp /tmp/ccI7CNCY.o: In function `__static_initialization_and_destruction_0(int, int)': traits2.cpp...

Possible to use different templates for different countries

is it possible to use different templates for different countries, i use WP but can't get much support from their forums. I have a site for Baby Rockers And i get traffic from different countries, is it possible to say have a china visitor see a different template with Chinese writing rather than them having to use google translator. ...

Listbox selection and DataTemplate

Hi I have a bounded listbox and I have created a DataTemplate that among other things have a button. I expected the listboxItem to get selected once I click the button but Its not working. Any ideas? ...

C++ compile time program wide unique numbers

I've come up with a solution to a problem but I'm not sure if it'll always work or just on my compiler. First, the problem: I've noticed in a number of situations it's desirable to have a template class that gets reinstantiated each time it's used even when given the same types (say your template class has static members that are initial...

Template Metaprogramming - i still don't get it :(

Hi folks ... i have a problem .. i don't understand Template Metaprogramming. The Problem is : i read a lot . But it does not make much sense to me :/ Fact nr.1 : Template Metaprogramming is faster template <int N> struct Factorial { enum { value = N * Factorial<N - 1>::value }; }; template <> struct Factorial<0> { enum...

Archive Template in Wordpress

Hello, I want to create an archive page template for Wordpress that will look like this: August 2009 Post 4 Post 3 Post 2 Post 1 July 2009 Post 2 Post 1 So, basically, I want all the posts from the blog, ordered descending by date and grouped by month. Can someone provide me the PHP code for this? Thanks! PS: Wordpress versio...

Most effient way to template a multi lingual site.

I am building a English/french website and was wondering if there is a best practice for such a job. Duplicating the site and making a french and english folder with the appropriate site inside. Using PHP to swap the content with html tags. eg. if($lang=='en'): Use php to swap only the content leaving the html tags the same for both....

I can't get the grails controller "render" method to work with an explicit template

I'm just getting started with grails, and I'm having an issue. I have a "controller" and "view" for the projects home page (there's no model for the home page) I called the view "index.gsp", and put it in a directory views/home However, no matter what I do, grails is trying to read the page "home.gsp" (and then home.jsp), despite me h...