templates

How do I validate template parameters in compile time when a templated class contains no usable member functions?

I have a following templated struct: template<int Degree> struct CPowerOfTen { enum { Value = 10 * CPowerOfTen<Degree - 1>::Value }; }; template<> struct CPowerOfTen<0> { enum { Value = 1 }; }; which is to be used like this: const int NumberOfDecimalDigits = 5; const int MaxRepresentableValue = CPowerOfTen<NumberOfDecimalDigits>...

Reducing number of template arguments for class

Hi, I have a method and two classes defined like this: template<template<class X> class T> void doSomething() { T<int> x; } template <class T> class ClassWithOneArg { T t; }; template <class T1, class T2> class ClassWithTwoArgs { T1 t1; T2 t2; }; I can now doSomething<ClassWithOneArg>(); but I cannot doSomethi...

Expression template operator overloading problem with std::vector.

I'm currently working on a numerical library that uses expression templates. Unfortunately I encountered a problem with my operator overloads. Consider the following stripped down example. #include <vector> namespace test { class test {}; template<class A, class B> class testExpr {}; template<class A, class B> tes...

Issue with visual studio template & directory creation

Hi all! I'm trying to make a Visual Studio (2010) template (multi-project). Everything seems good, except that the projects are being created in a sub-directory of the solution. This is not the behavior I'm looking for. The zip file contains: Folder1 +-- Project1 +-- Project1.vstemplate +-- Project2 +-- Project2.vstemplate mya...

Start template animation as soon as control is loaded.

I have the following code inside my ControlTemplate: <EventTrigger RoutedEvent="ControlTemplate.Loaded"> <EventTrigger.EnterActions> <BeginStoryboard> And I want to start Storyboard which I have defined in ControlTemplate, when control is loaded. So my question is: what in ControlTemplate rises Loaded event...

C++ templates: Query regarding which is better of way of using and why

I have a got a question. Which is the better of doing it. typedef enum{ One = 1, Two = 2 } Number; template< typename T, Number num > void foo( const T& param ) { } or template< typename T > void foo( const T& param, Number num ) { } What basically I am looking for is, how are these two methods different? If I have to use any ...

C++ whether a template type is a pointer or not

Possible Duplicate: Determine if Type is a pointer in a template function I am looking for a method to determine whether a template is a pointer or not at compiling time. Because when T is not a pointer, the program will not compile as you cannot delete a normal type variable. template <typename T> void delete(T &aVar) { ...

Codeigniter, how to make a template

Hello all, im trying to ding into codeigniter MVC but i dont know how i make my template so i have 2 files (header and footer) and then i can make my controllers and then ONLY put information in the "content" div, so i include the top and the header a good way like this <?php include("header.php"); ?> <div id="content">My content here<...

Trouble understanding whence a copy constructor came

Hello everyone :) I have the following small code: template <typename T> class V { public: T x; explicit V(T & _x) :x(_x){} }; int main() { V<float> b(1.0f); // fails return 0; } And it happens to fail. The message returned by g++ 4.4.5 is: g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d...

Function Templates - Explicit specialisation vs Global Functions (C++)

I know that Function Templates are used so as to make the functions portable and so that they could be used with any data types. Also Explicit Specialization of templates is done if we have a more efficient implementation for a specific data type. But then instead of Explicit Specialization we could also just code a Nontemplate Functio...

Implicit conversion not happening

Hello again :) The last question I asked was something I stumbled upon when trying to understanding another thing... that I also can't understand (not my day). This is quite a long question statement, but at least I hope this question might prove useful to many people and not only me. The code I have is the following: template <typen...

Function that populates a dropdownlist inside a gridview edit template

I am trying to have different options for different user roles. Here is my code: Private Function GetApprovedBy() As String If User.Identity.Name = "officer" Then Return "Approved by Officer" ElseIf User.Identity.Name = "manager" Then Return "Approved by Manager" Else Return St...

Item Template in the ItemPresenter

In this template ItemPresenter just defines host panel for the Items. Is it possible to define ItemTemplate? <ControlTemplate x:Key="ItemsControlTemplate" TargetType="ItemsControl"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ScrollViewer> <ItemsPr...

eZ Publish template creation

Hi. I'm trying to add a new template (.tpl) file to an existing design for a company. It is fairly basic: * New page with iFrame that can be controlled from admin. * Add new CSS to the new file that will either overwrite existing CSS or add to template. I have tried to find reference to where I should place such a template and how to...

How to add a jscript or html item template via an add-in in visual studio

I'm currenlty working on an add-in and require the functionality to add custom item templates to a project programatically. I'm currently installing the templates (which are of a .zip format) in ..\Visual Studio 2010\Templates\ItemTemplates\. From within the add-in I then call the following code: string templateLocation = (solution as...

Programmatic way of refreshing VS Item Template cache from within Visual Studio Add-In

Is there a way from within a Visual Studio Add-in to get visual studio to rebuild its cache in a similar way to calling DevEnv.exe with the /InstallVSTemplates command? ...

How to conditionally generate additional projects from a ProjectItem template?

I have a situation where I'm generating a single project via a Project Item template in Visual Studio. I pop up a dialog which offers the options to create additional test and setup projects, too. My question is: how do I instrument this using the existing infrastructure? ...

WordPress Mobile Pack Custom Page Template

Heya, Hoping someone can help. I've inherited a WP based website which has WPMP already installed & activated & working on it (I can see it work on many pages). I've had to create a custom template & a few pages that use this template. Unfortunately, when I switch to mobile mode (or check out the new pages on my iPhone), no posts show...

Declare class member at runtime in D

I want the following struct as a class member, but I don't know the type of T, so I need "declare" the struct at runtime. struct Chunk (T) { string id; T[][] data; } class FileBla { this() { Chunk !int ck; // need to be turned in a class member } } Should be missing something easy. ...

CSS / Other templates for Business Web App

I'm working on a scheduling application that will schedule students and staff into classes (and do some other administrative work as well.) It's going to need a web-based UI, and unfortunately I'm not that good at UI design and artistic stuff, so I prefer to work with templates when I can. I'm looking for CSS templates (or just plain i...