templates

C++ template inheritance issue with base types

I have the following code and it fails to compile template < typename T > class Base { public: typedef T * TPtr; void func() { } }; template < typename T > class Derived : public Base< T > { public: using Base< T >::TPtr; using Base< T >::func; TPtr ptr; }; int main( int c, char *v[] ) { Derived< int...

Problems in initializing member of a template class

My code does not compile. Below is my code template <typename T> class TemplateClass { const T constMember; public: TemplateClass() { constMember = T(); } }; int main() { TemplateClass <int> obj; } I get this error : error: uninitialized member 'TemplateClass<int>::constMember' with 'const' type 'c...

Non-virtual derivation: what do I really get from the compiler?

Hi, I am wondering what is produced by the compiler when using non-virtual derivation: template< unsigned int D > class Point { int[D]; // No virtual function // ... }; class Point2 : public Point<2> {}; class Point3 : public Point<3> {}; Does the derivation here only imply compile-time checks? Or is there some other ove...

why my template is already defined?

hey, i'm trying to compile my work and i'm getting this error : function template has already been defined and it's written about all my template functions. any idea what can cause such thing? ...

creating a drupal non-cached template variable

In drupal 6 I'm trying to execute a function on every page and output a different link based on what IP address someone is coming from. However, when I try this, it seems that the result is getting cached. I have tried this as a module and in template.php, but have not gotten results. What is the best approach to make sure this function ...

Error C2275 caused by template member function. Is this code wrong?

Hello all, I think I've run into a (possible) VC6 (I know. It's what we use.) compiler error, but am open to the fact that I've just missed something dumb. Given the following code (It's just an example!): #include <iostream> // Class with template member function: class SomeClass { public: SomeClass() {}; template<class T> T ge...

Append dynamic HTML elements through function call in jquery-tmpl

I am using the jquery-tmpl template library to build a dynamic <select> list. In my template I have a function call that returns all <option> elements from an existing <select> element on the page. In my template the function call executes successfully and returns the .html() from the existing <select> list but renders it as text in th...

how can I use built-in ASP.NET templates for sending emails?

Hello world! Is there any samples on how to use ASP.NET built-in templates out of the page, just for rendering text with params. For instance, to build email message. thanks in advance. ...

Design of pointer container template

I would like to write a "versatile" class representing the general container storing pointers. Should I use public inheritance or containment? template <class T> class List : public std::vector <T *> { //... } Or template <class T> class List { private: std::vector <T *> items; //... } May some problems occur with abstract class...

dynamic_cast<> ing variable arguments to templates

I have a C++ application that executes test cases. It is possible that some test cases will depend on output from other test cases. All test cases implement a basic interface: /// base class for all test cases class ITest { public: virtual void Execute() = 0; }; Test cases that produce some object that may be useful to other tes...

Template programming in C++

Hi, I am having trouble getting to grips with programming using templates in C++. Consider the following files. C.h #ifndef _C_H #define _C_H template <class T> class C { public: C(); virtual ~C(); } #endif _C_H C.cpp #include "C.h" template <class T> C<T>::C() { } template <class T> C<T>::~C() { } I try instantia...

Template programming - Common Mistakes

Possible Duplicate: C++ template gotchas Hi, I am just in to my second month on SO, and I have seen enough number of posts on SO related to several common issues with templates. Is it a good idea to make a small Wiki on this (sadly I don't know how to make one)? The idea is to provide a reference as definitive as this (GMan'...

C++ single template specialisation with multiple template parameters

Hallo! I would like to specialise only one of two template types. E.g. template <typename A, typename B> class X should have a special implementation for a single function X<float, sometype>::someFunc(). Sample code: main.h: #include <iostream> template <typename F, typename I> class B { public: void someFunc() { std...

Accepting nested variadic class templates as arguments to function template.

I'm trying to make a function template that will accept two (or more) of the nested variadic class templates listed below, as arguments, and put them into another data structure that will accept different types (pair or tuple is what I'll most likely use). Here are the classes and subclasses, along with the usage of my function (the fun...

Change the Implement Interface template

In Visual Studio 2010, is it possible to change the default template used when implementing an interface? I would like to change the implementation of properties from public int MyProperty { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } to public...

Passing const char* as template argument

Why can't you pass literal strings in here? I made it work with a very slight workaround. template<const char* ptr> struct lols { lols() : i(ptr) {} std::string i; }; class file { public: static const char arg[]; }; decltype(file::arg) file::arg = __FILE__; // Getting the right type declaration for this was irritating, so I ...

Drop-down TabControl

I've been trying to create a custom skin/template for a TabControl in WPF. I want the tabs to be displayed in a ComboBox. When you select the item from the ComboBox, I want the content area of the tab control to display the TabItem contents. Here's an image showing what I'm looking for: I could do this using some sort of master-deta...

How do I write a Django template tag for access control?

I'm trying, in vain, to create a simple Django template tag to either show or hide a "delete" link next to a submitted comment on my site. In a nutshell, I want to pass the comment object to the template tag, determine if the currently logged in user is authorized to delete the comment and then either show or not show the link. The usa...

Silverlight cannot find resource in the same dictionary

I have the following style defined in the ResourceDictionary of a Silverlight 4.0 application <Style x:Key="GridSplitterStyle" TargetType="sdk:GridSplitter"> <Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="Background" Value="Transparent" /> ...

Windows Security Template to Allow CAN Controller Access

I'd like to see advice on how the security template should be configured to permit CAN controller access from an application. Thank you. ...