templates

Template function in C# - Return Type?

It seems that c# does not support c++ like templates. For example template <class myType> myType GetMax (myType a, myType b) { return (a>b?a:b); } I want my function to have return type based on its parameters, how can i achieve this in c#? How to use templates in C# EDIT: Can i use object and getType for the almost same purpose? ...

Multiple Validation Rules and Validation Templates in WPF

Does anyone have a tactic for dealing with multiple validation rules and templates for those validation rules. Example: I want to have two validation rules (required & data) I want either... One template that can change is display depending on which rule is fired or Two templates, which get displayed depending on which rule is fired ...

compiler warning at C++ template base class

I get a compiler warning, that I don't understand in that context, when I compile the "Child.cpp" from the following code. (Don't wonder: I stripped off my class declarations to the bare minuum, so the content will not make much sense, but you will see the problem quicker). I get the warning with VS2003 and VS2008 on the highest warning ...

Template class that refers to itself as a template template parameter?

This code: template <template <typename> class T> class A { }; template <typename T> class B { A<B> x; }; doesn't compile, I suppose since A<B> is interpreted as A<B<T> > within B's scope. So, how do you pass B as a template template parameter within it's scope? ...

Explicit specialization in non-namespace scope

template<typename T> class CConstraint { public: CConstraint() { } virtual ~CConstraint() { } template <typename TL> void Verify(int position, int constraints[]) { } template <> void Verify<int>(int, int[]) { } }; Compiling this under g++ gives the following error: Explicit specialization in non-namespace scope 'class CConstrain...

Multi-part template issue with Jinja2

Hi, When creating templates I typically have 3 separate parts (header, body, footer) which I combine to pass a single string to the web-server (CherryPy in this case). My first approach is as follows... from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('')) tmpl = env.get_template('Body.html'...

Strange GCC 'expected primary expression...' error

Possible Duplicate: Templates: template function not playing well with classs template member function template <typename T> struct A { template <int I> void f(); }; template <typename T> void F(A<T> &a) { a.f<0>(); // expected primary-expression before ‘)’ token } int main() { A<int> a; a.f<0>(); // Thi...

C# custom template to edit Visual Studio new project dialog box

Hi, I want to create a custom template so that once selected, it will gray out the Location input box in the New Project window. Does anyone know how to do this? Thanks much in advance ...

Using Django view variables inside templates

Hi, this is a rather basic question (I'm new to Django) but I'm having trouble using a variable set in my view inside my template. If I initialize a string or list inside my view (i.e. h = "hello") and then attempt to call it inside a template: {{ h }} there is neither output nor errors. Similarly, if I try to use a variable inside my ...

Stringified template argument

Is it possible to get a stringified version of a template argument name? Something like this, if only we were running the preprocessor: template <typename T> struct Named{ const char* name(){ return "Named<" #T ">"; } }; Edit Duplicate. See here http://stackoverflow.com/questions/1488186/stringifying-template-arguments ...

How do I make a class whose interface matches double, but upon which templates can be specialized?

How do I make a class whose interface matches double, but whose templated types do not dynamic cast to double? The reason is that I have a run-time type system, and I want to be able to have a type that works just like double: template<int min_value, int max_value> class BoundedDouble: public double {}; And then use template speciali...

How do you return a pointer to a base class with a virtual function?

I have a base class called Element, a derived class called Vector, and I'm trying to redefine two virtual functions from Element in Vector. //element.h template <class T> class Element { public: Element(); virtual Element& plus(const Element&); virtual Element& minus(const Element&); }; and in another file //Vector.h #include "Eleme...

how to get the type of a deferred template parameter

Is there a way to get the defered type of a class template parameter ? template <class TPtr> struct foo { typedef TPtr ptr_type; typedef ??? element_type; /* shall be the type of a deferred TPtr*/ }; so foo<const char*>::element_type results in const char, and foo<std::vector<int>::iterator_type>::element_type results in int. ...

Creating a 'website builder' - How would I architect it?

I've been tasked with adding a website builder to our suite of applications. Most of our clients are non technical small business owners (brick and mortar stores, mom and pop shops). I've been told that I should be looking at Blogger Template Editor and trying to see if I can make something that fully featured and easy to use. The idea b...

Django Template Inheritance -- Missing Images?

Howdy, I have got the following file heirarchy: project   other stuff   templates       images           images for site       app1           templates for app1       registration           login template       base.html (base for entire site)       style.css (for base.html) In the login template, I am extending 'base.html.' 'base.htm...

If you use MVC in your web app then you dont need to use Smarty(TemplateEngine) Right?

I'm just trying to understand the Templating(system). If you use MVC in your web application then you don't need to use something like Smarty(template engine) as you are already separating application code from presentation code anyway by using MVC right? please correct me? So am i correct in thinking it's MVC OR Templating or do you us...

Access RichTextContentControl Text from an AddIn in MS Word using C#

I've created an AddIn for MS Word. There's a new tab and a button. I've added a new template document that has a RichTextContentControl in it. WORD_APP = Globals.ThisAddIn.Application; object oMissing = System.Reflection.Missing.Value; object oTemplate = "E:\\Sandbox\\TemplateWithFields\\TemplateWithFields\\Tem...

C++ template restrictions

I wondering is there any way to set restrictions on template class? Specify that every type substituted in template must have specific ancestor (realize some interface). template < class B > //and every B must be a child of abstract C class A { public: B * obj; int f() { return B::x + this->obj->f(); } }; Like =>...

I have a bunch of template parameters that I want to hide from my users. How can I do this?

I have a superclass which is defined in terms of a few internal types it uses. Subclassing is performed as so: template <class InternalType1, class InternalType2> class Super { ... } class Sub : Super <interalTypeClass1, interalTypeClass2> { ... } But when I want to write a function that takes a pointer to the superclass, t...

django display m2m elements in a template

if a have a declaration like def inside_classroom(request,classname): theclass = Classroom.objects.get(classname = classname) members = theclass.members.all() c = Courses.objects.filter(classroom = theclass) return render_to_response('classroom/inside_classroom.html', { 'theclass': theclass, 'c':c, 'members':mem...