templates

Template Design / Architecture

I am looking into creating something similar to a form template system on my web site. As an example, say I want the users to be able to create form templates (similar to Wufoo, they can define any number of inputs, etc). Then from these created templates, anybody would be able to use these templates, fill them out, and therefore creat...

How can I expose a uniform interface to a template class ?

Hi everyone, I have implemented a templated buffer class like this: template <class T, class Impl> class base_hardware_buffer : Impl { public: typedef const T& const_reference; typedef T* pointer; void push_back(reference r) { // Do some generic operation, call impl when needed // ... } pointer...

Using std::vector<T*>::push_back with std::mem_fun and std::bind1st

I'm trying to use std::vector<T*>::push_back with std::mem_fun and std::binder1st, but it doesnt seem to be feasible, can this be done? I've tried to exemplify with the code below. #include <vector> #include <functional> #include <iostream> using namespace std; struct A { int _Foo; virtual int AFoo() { return _Foo; }...

C++ templates declare in .h, define in .hpp

I saw some code in which the developer defined a class template in a .h file, and defined its methods in a .hpp file. This caught me a bit by surprise. Are there are particular conventions in C++ when dealing with templates and what files they should be in? For example say I had a Vector class template with methods for vector operatio...

C++ friend comparison between two instantiations of one class template

I am trying to write a class template that provides a comparison operator between two instatiations with different template types. As is often the case, this operator is a non-member friend. A simplified example of what I am trying to achieve can be seen below. template<typename T> class Wrapper { // Base type, which must have a val()...

How to create sharepoint 2010 site programmatically based on site template

Hello all, iam new to sharepoint my requirement is, we are developing a business intelligence dash board using pps with some custom reports built on it. I need to replicate this site to create n no of subites based on this bi dash board site. So iam planning to make this site as a site template and trying to create the site programmati...

template specialization according to sizeof type

I would like to provide a templated function, that varies its implementation (->specialization) according to the sizeof the template type. Something similar to this (omitted typecasts), but without the if/elseif: template<class T> T byteswap(T & swapIt) { if(sizeof(T) == 2) { return _byteswap_ushort (swapIt); } ...

ExpressionEngine 1.6.9: displaying a weblog at all pages.

Hi friends, I'm a EE newbie. I have the code below. the poll weblog displays at search result page, but doesn't display at blog and post details page :/ what am I missing? display at search result page: www.blabla.com/search/noresults/d8ee432f229715a4adfbe1cc0d21049a/ NO display at blog pages: www.blabla.com/blog/ or www.blabla.co...

What is the type of T?

In the code below: template<typename T> struct X {}; int main() { X<int()> x; // what is the type of T ? } What is the type of T? I saw something like this in the boost sources. ...

Django db and Template

I am trying to implement the following setup: I have 5 different Apps. All 5 are part of one project. I am trying to extract all the common elements these different apps have. Than I want to make those elements variables that I can than make the view.py paste into templates I create. So I have templates that have variables in it like...

WPF: swapping out control templates increases performance, efficiency?

I have a general question about WPF performance. We have a relatively simple forms application. Some team members believe that redesigning the templates for basic controls will improve performance and maintainability. One preferred technique is to create multiple control templates for a control, and swap them out with triggers. The belie...

Implicit conversion between templated class instances that use classes that inherit from one-another

I have a class that looks like this: class Base { public: Base( int val = 0 ) : value( val ) {}; int value; }; Classes A and B inherit Base: class A : public Base {}; class B : public Base {}; I also have a templated class with a signature similar to: template < class T > class Temp { public: ...

Way to set up class template with explicit instantiations

After asking this question and reading up a lot on templates, I am wondering whether the following setup for a class template makes sense. I have a class template called ResourceManager that will only be loading a few specific resources like ResourceManager<sf::Image>, ResourceManager<sf::Music>, etc. Obviously I define the class templa...

Templating and trying to reference context path from inside a CSS file

I'm working with JSF and XHTML templates, I'm using a CSS file in the templates, the background images being called like: background-image: url("../../images/imageFile.jpg"); Because I'm using templates I found out that I must keep same depth for both pages and styles/images to pages apply styles correctly, but the project had change...

How does template parameter of std::function work? (implementation)

In Bjarne Stroustrup's home page (C++0x FAQ): struct X { int foo(int); }; std::function<int(X*, int)> f; f = &X::foo; //pointer to member X x; int v = f(&x, 5); //call X::foo() for x with 5 How it works? How std::function calls foo member function? According to the template parameter int(X*, int), is &X::foo converted from the memb...

In need of a Tool/template that posts downloads similar to Wordpress?

I'm not even sure what they call this or these kinds of tools. But I'm in need of a tool that works similar to Wordpress that works like a blog. However, instead of blogging I want to post downloadable content to my website with images and maybe a description of what the download is. Like a blog, newer posts/content show up at the top o...

container of mixed types in C++ (similar to nsdictionary)

What I would like to do (in C++) is create a 'Parameter' data type which has a value, min, and max. I would then like to create a container for these types. E.g. I have the following code: template <typename T> class ParamT { public: ParamT() { } ParamT(T _value):value(_value) { } P...

Does order matter in specialization of a function in class template

Consider something like... template<typename T> class Vector { ... bool operator==( const Vector<float> &rhs ) { // compare and return } bool operator==( const Vector<T> &rhs ) { // compare and return } ... }; Notice how the specialization is above the non specialized version. If I were to put the specialized ver...

ASP.NET MVC: Javascript executing correctly on create view, but not edit view.

I have two views: create and edit. Both share a strongly typed editor template user control. I have a jQuery wysiwyg editor on the shared editor template, and it works fine without errors on the create view, but when I load up the edit view, firefox reports that "$ is not defined" "jquery is not defined" etc. Also, the images from th...

How to specialize member functions based on class template argument

What the question says. In addition, is it possible to do this inline? Here is a small example just to give an idea... template<typename T> class Foo { public: Foo() :z(0.0) {} void do( const Foo<T> &f ) { z = f.z; } // specialize 'do' for Foo<int>, possible inline? private: T z; }; ...