templates

I get an error during a template import attempt in Dot Net Nuke 5.x.x

Hello all, I get a error during a template import, the template is created in Dot Net Nuke 5, I am trying to create a new child portal and import a template, during the process I get: Tab Exists at DotNetNuke.Entities.Tabs.TabController.AddTabInternal(TabInfo objTab, Boolean includeAllTabsModules) at DotNetNuke.Entities.Tabs.TabControll...

C++ template question

Hello! Is there any way to achieve the specified behaviour? If there is some trick or this could be done using traits or enable_if, please let me know. template <typename T> struct Functional { T operator()() const { T a(5); // I want this statement to be tranformed into // plain 'return;' in...

Creating an interface for an abstract class template in C++

I have the code as below. I have a abstract template class Foo and two subclasses (Foo1 and Foo2) which derive from instantiations of the template. I wish to use pointers in my program that can point to either objects of type Foo1 or Foo2, hence I created an interface IFoo. My problem is I'm not sure how to include functionB in the inte...

Getting HTML in the controller from view template

Hi folks, Stackoverflow has taught me so much about what proper RESTful, MVC, GET/POST is that I am wondering how people learn to program/engineer in the past before Stackoverflow existed. ;) Given that, here is another question on how I can do a (fairly) common procedure in the most appropriate way. I need to generate a HTML from a ...

C++ basic template question

Hello! I'm slightly confused with template specialization. I have classes Vector2, Vector3 which have operator+= in it (which are defined the following way). Vector2& operator+=(const Vector2& v) { x() += v.x(), y() += v.y(); return *this; } Now I want to add the generic addition behaviour and say something like: ...

Variadic C++ function doesn't work when fetching arguments of type float

I have a variadic template function: template<typename T, typename ArgType> vector<T> createVector(const int count, ...) { vector<T> values; va_list vl; va_start(vl, count); for (int i=0; i < count; ++i) { T value = static_cast<T>(va_arg(vl, ArgType)); values.push_back(value); } va_end(vl); return values; } Thi...

Class method with number of arguments specified by integer template parameter

Was not exactly sure how to phrase this question or what to search on so if this is the same as another question please close and redirect to the appropriate question. Suppose template<typename Type, int Size> class vector { Type data[Size]; } Is it possible to replace a constructor which takes Size number of arguments in template ...

How to fix the syntax in this code rife with templates?

The following code template<typename T, typename U> class Alpha { public: template<typename V> void foo() {} }; template<typename T, typename U> class Beta { public: Alpha<T, U> alpha; void arf(); }; template<typename T, typename U> void Beta<T, U>::arf() { alpha.foo<int>(); } int main() { Beta<int, float> beta; ...

django templates

How can i split cases for None and False in django templates. {%if x %} True {%else%} None and False - how i can split this cases? {%endif%} ...

Function template in a namespace in a separate file compiles fine, but the linker cannot find it

This problem is in defining and declaring a function template in a namespace that is defined in an external file from where the function is instantiated. Here's the smallest reproducible example I could come up with. 4 files follow: The function template declaration in a named namespace: // bar.h #include <algorithm> namespace barspac...

Do templates support variable numbers of parameters

Hello, I'm trying to determine if the following scenario is appropriate for a template, and if so how it would be done. I have a base class, event_base. It is inherited by specific types of events. class event_base_c { //... members common to all events ... // serialize the class for transmision virtual std::string ser...

What is an lvalue reference to function?

In §14.1.4, the new C++0x standard describes the non-types allowed as template parameters. 4) A non-type template-parameter shall have one of the following (optionally cv-qualified) types: integral or enumeration type, pointer to object or pointer to function, lvalue reference to object or lvalue reference to function, ...

C++0x passing arguments to variadic template functions

What does it mean to take a variable number of arguments by reference? Does it mean that each of the arguments are passed by reference? Consider for example the following functions which performs some processing on each its arguments: void f() // base case for recursion { } template <typename Head, typename ... Tail> void f(Head& he...

Django Template Images

Take a simple view like this: def my_gallery(request): images= ? t = Template("<html><body>Here my images from XY {{ images }}.</body></html>") html = t.render(Context({'images': ? })) return HttpResponse(html) How do I have to define the variable images/ What do I have to fill in the Context so that Django displays m...

Content-dependent templates/partials with moustache.js

I'd like to use moustache.js to render the following JSON structure: [ {type:'img', src:'some_url'}, {type:'text', text:'lorem ipsum ...'}, {type:'link', href:'some_url', label:'click here'}, // more entries ... ] I'd like to render each item depending on type: img should br rendered as <img src="{{src}}">, text as <p>{{text}...

Need to keep track of types of opencv Mats

Hi, So I'm using the class Mat from opencv in a program I'm writing. Mat looks something like this: class Mat { public: Mat(int width, int height, int type); template <typename T> T getElt(int x, int y); int depth(); ... } The type in the constructor specifies whether elements in the Mat are float...

how to specialize templated member functions of non-templated classes?

suppose I have a file alpha.h: class Alpha { public: template<typename T> void foo(); }; template<> void Alpha::foo<int>() {} template<> void Alpha::foo<float>() {} If I include alpha.h in more than one cpp file and compile with GCC 4.4, it complains there are multiple definitions of foo<int> and foo<float> across multiple object...

ASP.NET MVC 2: Data Annotation or Template: way to associate a DDL to its Model.data option list?

Summary: If you use ASP.NET MVC 2's templates to render a DropDownList, how would you access the list of options if they are stored in the top level View's Model.property? Also, is there some [DataAnnotation] way to associate this list? Links to examples would be very helpful. Background: In ASP.NET MVC 2, you can create a custom cl...

Smarty template question

hi, i am new to smarty template and i am trying to do this. I have a html form in the tpl file and in that form action is for a php email function email.php. I am not able to get it to work. if i have the complete code(html form + php email code) and save as a php file, it works fine. is there any way to call the php code from email.p...

Expression intermediates in GCC (if that's what they're actually called)

I am trying to convert a math library written with VS so it will compile though GCC. The trouble is, I have a lot of overloaded operators that look like this: template<typename T> inline quaternion<T> operator+(quaternion<T> &a, quaternion<T> &b) {return quaternion<T>(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);} and so on. The problem is: Thes...