templates

when is better to use c++ template?

right now i am learning C++, and now I know the basic concept of template, which act just like a generic type, and i found almost every c++ program used template, So i really want to know when are we supposed to use template ? Can someone conclude your experience for me about c++ template ? When will you consider to use template ? Su...

Does ItemsTemplate+DataTemplate obscure bindings?

At several points in my current application, I have an ItemTemplate such as the following: <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <ToggleButton Ma...

Expanding and creating code templates in Eclipse when using emacs keybindings

How do I expand code templates in Eclipse when using the emacs keybindings? Is there a hotkey for turning selected code into a template? ...

How can I edit my templates in SquareSpace?

I'm hosting my blog in SquareSpace, and I need to add a <Script> tag at the footer of every post. In the middle of this <Script> tag, I need to replace a value with the permalink for the current post. So, in my home page, where I'm showing 5 posts, I need this <Script> to show up 5 times, each time with the permalink of the correspond...

Why doesn't this C++ template code compile?

Does anyone know why this will not compile? I've tried both VS 2008 and GCC 4.something and both spit out errors. It doesn't matter whether or not I'm referencing "ThisFunctionDoesNotCompile()". I can workaround this by just passing 'InternalType' as a second template parameter to Base, but I'm still curious why this comes up as an er...

What dpi resolution is used for an iPhone App ?

I am working on a template for an iPhone App and was wondering what dpi resolution is used for it ? 300 or 72 ? I am not sure and I hope somebody can answer me that question. thanks in advance farid ...

How to create a 2D array in C++ using this specific container

I'm trying to port a int a[][] from Java to C++. I'm using this class as a container ArrayRef for ints because it handles references, and the project uses it extensively. In the AbstractReader class I declared const ArrayRef<int> START_END_PATTERN_; const ArrayRef<int> MIDDLE_PATTERN_; const ArrayRef<ArrayRef<int> > L_PATTERNS_; co...

What would cause a Django template for loop to raise a Key Error?

I upgraded a working Django app to 1.1 and I now get a KeyError exception on a for loop! Template error In template /vol/.../templates/base_bbn.html, error at line 7 Caught an exception while rendering: 'django.contrib.comments.urls.' You would think that there couldn't be a KeyError on a for loop like this because there would be a ...

Creating a item template for Visual Studio 2008, with file-dependencies, is it possible?

I have a template that adds a new entry to the "Add->New item" right-click menu on a project in the solution explorer in Visual Studio. I have already built the template, put it into my ItemTemplates directory beneath my documents folder, and it works, in the sense that I can add new items to the project through the template. However, ...

c++ template syntax error

Hi all; My C++ is a little rusty having worked in Java and C# for the last half dozen years. I've got a stupid little error that I just cannot figure out. I've pared the code down as much as possible. #include <list> template<class T> class Subscriber { virtual void published( T t ) = 0; }; template <class T> class PubSub { priva...

Visual Studio auto-including (C#)

Is there a way to specify which namespace "includes" should be automatically added any time you create a new C# file in Visual Studio 2008? Thanks! ...

C++: Optimize using templates variables

Hi, Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter = true) { if(tryUseGetter) { if(_properties[name]->hasGetter) { return (Type*)_properties[name]->getter(); } return (Type*)_properties[name]->data; } else { return (Type*)_properties[name]->data; } } ...

How to call a templated function if it exists, and something else otherwise?

I want to do something like template <typename T> void foo(const T& t) { IF bar(t) would compile bar(t); ELSE baz(t); } I thought that something using enable_if would do the job here, splitting up foo into two pieces, but I can't seem to work out the details. What's the simplest way of achieving this? ...

C++: Convert Macro based Property System to use templates

I've already implemented, using macros, a C++ property system that satisfied the following requirements: Property can be referenced using a integeral key Property can be accessed via a generic Set/Get Properties (and property keys) must be inheritable Properties can be registered with getters/setters and is implemented as follows E...

VC6 and template error

Hi, I am overloading operator << to implement a stream like interface for a class: template<typename T> CAudit& operator << ( const T& data ) { audittext << data; return *this; } CAudit& operator << ( LPCSTR data ) { audittext << data; return *this; } The template version fails to compile with "fatal error C1001: INT...

Best view layer with simple URLs for an EJB3 application

Hi. I would like to get your input on what would be the most fitting view layer for EJB 3.0 [1] Java application for me. JSF is no good because it is a mess when it comes to web URIs. I would like a view framework which would help with automating html form submission and validation while using clean URIs like example.com/story/1 or exam...

Eclipse HTML editor for HTML template files

I'm trying to edit phpbb HTML template file with Eclipse Ganymedes version 3.4.1 containing Web Developer Tools. These template files contain HTML markup with template variable marks in form {*variable_name*}. Now, when trying to open such file, Eclipse trys to validate also these template variable marks. For example template contains ...

javascript templating engine that maintains focus on textboxes etc?

So I know there is a few templating engines out there, but I thought I'd ask for someones experience and reccomendation on one that can do what I'm after. I'd previously made an (intranet) web app that used asp.net editable listviews to take input and used an update panel to make it persist the data regularly (save) This worked ok but...

Is compile-time "strlen()" effective?

Sometimes it necessary to compary a string's length with a constant. For example: if ( line.length() > 2 ) { // Do something... } But I trying to avoid using "magic" constants in code. Usually I use such code: if ( line.length() > strlen("[]") ) { // Do something... } It more readable, but not efficient because of function ca...

How to return NULL from a method in a Template Class

I have a method which looks like this: template <typename T> T Test<T>::FindItem(T item) { if(found) //return original value, no problem here else //I want to return NULL here, like: return NULL; } This fails in certain cases at runtime because some of the values can't be converted to NULL in C++ e.g.,...