templates

What is the best way of deploying VS project/item templates?

I made an installer fro project/item templates in VS2010 to put the templates in the user's Templates folder. Is this an OK way of doing things? Or is there a way to deploy templates for all users? If so - where should I put them? Thanks. ...

typedef templates in global scope

using template classes I usually make some typedefs like: typedef super<puper<complex<template<type> > > > simple_name I usually do it in 2 ways: template <class A, ...> struct Types { typedef ... } template <class A, ...> class Part_Of_Logick { public: typedef ... } Is it possible to set typedefs at the global sco...

How to intentionally cause a compile-time error on template instantiation

Sometimes when coding with C++ templates, you want to prevent users from instantiating a specific specialization or set of specializations, because the result would be nonsensical. So you can define a (specific or partial) specialization whose definition, if instantiated, would cause a compiler error. The goal would be, if a user "misu...

How do I determine the number of bits in a template non-type integral constant parameter?

I would assume that this is covered in the C++ Standard, but I've not been able to find it. I am writing some templates that are going to do arithmetic on their non-type integral parameters, and I find I need the equivalent of MAX_INT for the parameter 'x' in a template like template <int x> Foo. Ideally someone could point me to the pa...

g++ typedef templates in inheritor class

simplifying my problem we can consider: template <class T> class Base{ typedef typename std::pair<T, T> pair; }; template <class T> class Inheritor : public Base<T> { pair *p; // mean that we want to use constructor of std::pair. // say: std::pair withou argument list Inheritor<T>::pair *p...

Templated function pointer?

I want to do something like this: I want the user to provide a return type and an argument (there will always only be one) then I want the user to be able to provide the pointer of a function that matches this criteria. I will be using this to create a timed event. The issue here is that usually with templates you must provide T and make...

Template function with template return type in C++

Relevant portion of the .h file: template<class T, class W> T inputValidate( T input, W minVal, W maxVal); Relevant portion of the .cpp file: T inputValidate( T input, W minVal, W maxVal) { if (input < minVal || input > maxVal) { cout << "Invalid input! Try again: "; cin input; } return input; } I get an error of "er...

creating a std::vector of a templated class?

I currently have a class that uses template arguments. I need an array of these. How could I do this (without boost). ex: template <typename RET, typename T> class AguiTimedEvent { RET (*onEvent)(T arg); double timeStamp; public: RET call(T arg); bool expired(); AguiTimedEvent(); AguiTimedEvent(RET (*Timefunc)(T ...

Dirt-simple PHP templates... can this work without `eval`?

Update- Thanks for all the responses. This Q is getting kind of messy, so I started a sequel if anyone's interested. I was throwing together a quick script for a friend and stumbled across a really simple way of doing templating in PHP. Basically, the idea is to parse the html document as a heredoc string, so variables inside of it ...

std::rel_ops functionality as a base class. Is that appropriate solution?

Hello, I've implemented the functionality of std::rel_ops namespace as a template base class (it defines all comparison operators using only operators < and ==). For me it's a bit weird that it works (so far) properly, also I'm concerned about the 'hacks' used. Can anyone assess the following code and say if I'm just lucky it to work or...

Form designer breaks on generic abstract UserControl

I have a generic abstract UserControl class, SensorControl, which I want all my sensor control panels to inherit from. The problem When attempting to design the EthernetSensorControl (one of my inherited UserControl forms, from within Visual Studio, the following error is displayed in the form designer: The designer could not be show...

CompileTimeChecker from Modern C++ Design not working as expected.

I've recently started reading Modern C++ Design by Andrei Alexandrescu. After reading Compile-Time Assertions, I tried the following code: template<bool> struct CompileTimeChecker { CompileTimeChecker(...){}; }; template<> struct CompileTimeChecker<false>{}; #define STATIC_CHECK(expr, msg) \ {\ class ERROR_##msg{}; \ (void...

C++ typename and inner classes

I tried googling this, but I was unable to come up with a suitable answer. Could any C++ gurus tell me why C++ requires you to declare OuterClass<T>::Innerclass with the typename keyword? I am a TA for a data structures course and I see this error all of the time. I know to tell my students that they need to put typename in front of th...

Template specialization

While reading this, I'm confused with the following examples: // Example 2: Explicit specialization // template<class T> // (a) a base template void f( T ); template<class T> // (b) a second base template, overloads (a) void f( T* ); // (function templates can't be partially // specialized; they overl...

Out of class constructor definition for a specialized class template

I am trying to define a constructor for an explicitly specialized class template outside the class definition, as so: template <typename T> struct x; template <> struct x<int> { inline x(); /* This would have compiled: x() { } */ }; template <> // Error x<int>::x() { } But it seems to be an error. Comeau says...

How to use two Wordpress templates at once... or something similar?

I'm building a wordpress template with a lot of javascript, so I am also setting up a fallback version what requires different php in the index file of the template, and preferably, different header files. The best way to do a fallback seems to be setting a javascript redirect on the "non-javascript site" to go to the "javascript versio...

Using templates for 2D/3D point

Is it worth to write classes representing 1D, 2D, 3D points using templates template <class T> class Point2D { protected: T X, Y; public: Point2D(const T x, const T y) : hot smileyx), Y(y)) {} ... }; template <class T> class Point3D : public Point2D<T> { protected: T Z; public: Point3D(const T x, const T ...

Mako templates with Google App Engine

I want to use Mako templates with GAE instead of Django templates. I found this post http://blog.pansapiens.com/2008/06/24/mako-templates-in-google-app-engine-seems-to-work-for-me/ I downloaded Mako from this page by using easy_install http://www.makotemplates.org/download.html But that gave me a "beaker" file c:\python26\lib\site-pa...

Why declaration/definition must both be in source file for template class in c++?

Anyone can elaborate the reason? ...

Is there anything like Dwoo-s {with} or {loop} in Smarty 3 or earlier?

{with} and {loop} plugins in Dwoo template engine change default context for variable name resolution. If in Dwoo you feed template: {$arr.foo} {with $arr} {$foo} / {$arr.foo} {/with} with data: array('arr' => array( 'foo' => 'bar' )) it will output: bar bar / because second {$arr.foo} actually means {$arr.arr.foo} in global c...