templates

write a C or C++ library with "template"

Hi, (1). When using C++ template, is it correct that the compiler (e.g. g++) will not compile the template definition (which can only be in header file not source file) directly, but generate the code based on template definition for each of its instantiations and then compile the generated code for its instantiations? (2). If I want ...

Conditional typedefs

If I have a little peice o' code as such... template <typename _T> class Foo { public: typedef const T& ParamType; void DoStuff(ParamType thingy); }; This can be non-optimal if sizeof(_T) <= sizeof(_T*). Therefore, I want to have a conditional typedef. If the size of _T is less than or equal to that of a pointer, just pass it...

How to put ASP.NET MVC Project Template into Visual Studio 2008 when it's not there?

Visual Studio 2008 not picking up the MVC 1.0 project template. The MVC 1.0 release is installed on my system along with .NET 3.5 w/ SP1 (prereqs). I can't find the MVC template in the VS application's disk folders when manually searching. My folders are: VS 2008 (9.0) C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\, rele...

Template class, function specialization

I want to have a template class that looks something like what I have down below. Then, I want a function in it with a template specialization depending on a CLASS template parameter. How do I make this work? I realize the code I provided is wrong on many levels, but it's just to illustrate the concept. template <typename _T, size_t num...

"Surround with"-template in Eclipse: foreach

I am new to Eclipse which I use primarily for Java. I have previously used IntelliJ Idea in which it is possible to select a variable which extends Iteratable (Collection, List etc) and have it produce a correct foreach loop. I know Eclipse does something similar with the foreach template, where it guesses which variable to iterate over...

Explicit instantiation

Hi guys, After few weeks brake (had to finish couple of assignments for my study, by the way, why God allowed anyone to invent Java?), I'm trying to expand and extend my knowlege of templates with book: Templates - The Complete Guide by David Vandevoorde and Nicolai M. Josuttis, and what I'm trying to understand at this moment is as in t...

CUDA with map<value, key> & atomic operations

Hi, as far as i know i can use C++ templates in CUDA device code. So if i'm using map to create a dictionary will the operation of inserting new values be atomic? I want to count the number of appearances of a certain values, i.e. create a code-dictionary with probabilities of the codes. Thanks Macs ...

How to use dicts in Mako templates?

Whenever I pass a complicated data structure to Mako, it's hard to iterate it. For example, I pass a dict of dict of list, and to access it in Mako, I have to do something like: % for item in dict1['dict2']['list']: ... %endfor I am wondering if Mako has some mechanism that could replace [] usage to access dictionary elements with simp...

Template member function virtual?

I heard, templated member functions of a class can't be virtual. Is it true? BTW, if they can be, then please give an example of such a scenario when I would need such function? ...

Use image templates in buttons without borders

Hi, I'd like to use image templates on some of my buttons to have them behave as follow : Raised background in "normal" state, so the image appears engraved in the button When the button is pushed, the image turns to blue until it's released (like a selected toggle button) I need my button to be without borders I tried different com...

Transferring signature of the method as template parameter to a class

Hey! I'd like to create a template interface for data-handling classes in my projects. I can write something like this: template <class T> class DataHandler { public: void Process(const& T) = 0; }; Then, suppose, I define a class this way: class MyClass: public DataHandler<int> { void Process(const int&) { /* Bla-...

Templates - Exercises

As I mentioned in my yesterday's post, I'm trying to teach myself templates from the book: Templates: The Complete Guide. And although I'm finding this book very nicely presented and material there is explained really well there are no exercises attached after each chapter to test your knowledge, like it is in The C++ Language by B.S for...

Mapping a class and a member function

Hi, Can someone suggest me a way to map a template classes with a set of member functions from another class? Whenever i call one of the function inside a template class, it should call the associated member function of the other class. Updating with a use-case template<int walktype> class Walker { Node* node; bool walk() ...

WPF TreeView does not apply DataTemplate accordingly

I have a business object project, which contains composite structure: public class Tree { public IProductComponent TreeRoot { get; set; } } public interface ITreeComponent { public string Name { get; set; } } public class ContainerComponent : ITreeComponent { public BindingList<ITreeComponent> Children { get; set; } } public class ...

How to define my own functions to use in Mako templates?

How can I make my own function to use in all the Mako templates? For example, I want to create function boda(a, b) that will return a + b. (Toy example.) How can I do this? One way I know that I can do it in template itself: <% def boda(a, b): return a + b %> But I want this function to be globally available to all the templates,...

In CSS, how do I make the text not go on a 2nd line?

Suppose I have text inside a div right now. When I resize my browser to make it really small, the text goes on a 2nd line instead of making the scroll bar. Instead, I would like to keep the text all on one line and just have a horizontal scroll bar. How can I do this? WIth overflow? ...

In mako, how can I cycle through a list and display each value?

I have a Python list that I'm supplying to the template: {'error_name':'Please enter a name', 'error_email':'Please enter an email'} And would like to display: <ul> <li>Please enter a name</li> <li>Please enter an email</li> </ul> ...

Getting info from all related objects in django

I'm trying to do something pretty simple, but I'm new to Django. I have a quiz system set up for an experiment I'm running. The relevant entries in models.py follow: class Flavor(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Passage(models.Model): name = models.CharFie...

How to create dynamic Template String

Is there is any API which replace template string along with values using Spring or java. For example: Dear %FIRST_NAME% %LAST_NAME%, ---- remaining text----------- where parameters (FIRST_NAME, LAST_NAME) in the form of Map. ...

Prevent drupal from loading other module's javascript

I have a drupal page that I'm using in a way that's very different from all the other pages of the site. I have a module that loads a set of specialized js on this page. I'm finding that my JS does not work well with the js from other modules or perhaps drupal core. How can I prevent the other modules from doing drupal_add_js on that s...