templates

Hide outer tables in ASP.net

One of the features of a website I'm working on is that you can "maximize" the contents of the page, basically removing all the outer elements of the page, navigation, banners, etc. This is currently done in what seems like the worst possible way: <% if (shouldBreakFrame) { %><!--#include file="header.include" --><% } %> // Contents o...

HTML e-mail template testing - for web and mobiles

Hi all, I am not sure that this is the right place for this question so if not please advice me where to ask. I am currently building a HTML e-mail template with sophisticated design and I am wondering how & where to test it. In "how & where" I mean which are the most common mail applications for desktop and mobile devices. So is ther...

Scope problems in template C++

Is there any scope problem in this program? #include<iostream> using namespace std; template<class Type> class Base { public: Type member; Base(Type param): member(param){ } }; template<class Type> class Derived: public Base<Type> { public: Derived(Type param):Base<Type>(param){ // ...

Lack of ortogonality in templates between class and function

// InternalTemplate.cpp : Defines the entry point for the console application. // #include "stdafx.h" template<class T> struct LeftSide { static void insert(T*& newLink, T*& parent) { parent->getLeft() = newLink; newLink->parent = newLink; } }; template<class T> struct Link { T* parent_; T* left_; T* right_; T*& getParent()...

How to deduce class type from method type in C++ templates?

In templates as shown below, I would like the call Run(&Base::foo) succeed without the need to name the Base type twice (as is done in the compiling Run<Base>(&Base::foo) call). Can I have that? Possibly without adding a ton of Boost headers? With the provided code, I get an error of: prog.cpp:26: error: no matching function for call t...

How to create an array to hold C++ classes (not instances) to be used iteratively in a template function.

I need to repeatedly make calls to a template function with different classes defined elsewhere in the code, like so: MyTemplateFunction<ClassOne>( &AnotherTemplateFunction<ClassOne> ); MyTemplateFunction<ClassTwo>( &AnotherTemplateFunction<ClassTwo> ); MyTemplateFunction<ClassThree>( &AnotherTemplateFunction<ClassThree> ); MyTemplateFu...

Deduce return type of operator/function for templates

Is something like this possible? // We can even assume T and U are native C++ types template<typename T, typename U> magically_deduce_return_type_of(T * U) my_mul() { return T * U; } Or would somebody have to hack up a return_type struct and specialize it for every pair of native types? ...

Using size of one array in another array

// sizeofarray.cpp #include <iostream> template <typename T,int N> int size(T (&Array)[N]) { return N; } int main() { char p[]="Je suis trop bon, et vous?"; char q[size(p)]; // (A) return 0; } I heard that an array size in C++ must be a constant expression. So char q[size(p)] is invalid, am I right? But I got no errors when...

expanded parameter list for variadic template

I'm working on an Event based architecture for a research project. The system currently uses Qt signalling, but we are trying to move away from Qt, so I need something that will work almost as well as the Qt event loop and signals across threads. Probably against my better judgement, I've chosen to use variadic templates to create a gen...

How do I create skeleton files, or templates, for MacVim

I have seen instructions about creating a "skeleton" file in vim. This involves creating the file, naming it "tmpl" plus the extension of the file type you are targeting (ex: tmpl.html), saving it to the "skeleton" directory, and then editing the vimrc file. But, in MacVim, I don't see a "skeleton" directory anywhere. Googling, etc., ha...

Python class-dependent template?

i want to create a widget depending on the class of the object, is there a simple way to do that in mako? for example class A might have attributes A and B while class B might have attributes A, B and C is there a pattern for this? i want to make a super class that they but inherit, but if I have a function print and call it by cal...

Polymorphic STL compare function (class cmp class, class cmp int) for sorting

I'm implementing a game. I have a state tree and a set<> based priority queue that sorts the states on their costs. For this I have the < operator implemented as: struct DereferenceCompareState : public std::binary_function<State*, State*, bool> { bool operator()(const State* lhs, const State* rhs) const { verbose6("comparing ...

Structure or Class with variable number of members

I want to create a structure/class with a variable number of class members which could be decided at compilation stage (like done in template metaprogramming) Example : Its hypothetical in which both type and variable names are to be specified like Type T1 variable name should be varName1 and so on ..... template <class T1 (varName1) >...

How to write a "joiner" extension for Jinja2?

Hi I've been trying to create an extension for jinja2 that would join multiple items with a separator, while skipping items (template fragments) that evaluate to whitespace. There are several of those fragments and you never know in advance which ones will be non-empty and which ones will. Sounds like a trivial task, but I had real har...

Single Pages loading with index.php instead of single.php in wordpress

My single pages and posts are not being loaded by single.php, instead they are being loaded in index.php I'm not able to figure out the reason for this. My is a template which I have made myself and the loop in index.php is almost the same in the default theme of wordpress 3. This is creating lots of troubles for me. What could be the ...

Multiple definitions of my template class

Hi, In my library, I have several initialize() and cleanup() functions, for different modules it depends on. To make this part more safe to use, I decided to follow the RAII rule and built up an Initializer template class, that takes two functions as parameters: // initializer.hpp (include guards omitted) template <void initialize(),...

How to call WP Theme Templates from WP Plugin?

Ok, you know when you're editing a page in Wordpress? You can change the page template under Page Attributes. How can I call a list of the current theme's page templates? I need that to use in my plugin. ...

Lyx template for scientific paper

Anyone know of any simple Template for scientific paper which is easy to modify and looks great? So that i don't have to use several hour to find out the syntax. ...

Why do I have to specialize it?

What am I doing wrong? #include "stdafx.h" #include <iostream> #include <string> using std::cout; using std::string; template<int v> struct Int2Type { enum {value = v}; }; template<bool condition,class Left, class Right> struct Result; template<class Left, class Right> struct Result<true,Left,Right> { typedef Left value; }...

ExtJS XTemplate and empty JSON parsing

How do you determine that a JSON object is empty in a XTemplate? I've tried <tpl if="myObject != {}"> <tpl if="myObject"> <tpl if="myObject != undefined"> etc, but can't seem to find the right way to detect an empty object. Thanks. ...