templates

specialize a member template without specializing its parent

I have a class template nested inside another template. Partially specializing it is easy: I just declare another template< … > block inside its parent. However, I need another partial specialization that happens to specify all its local template arguments. This makes it into an explicit specialization. Explicit specializations, for wha...

How can I change gridview templatecolumn order dynamically?

How can I change gridview templatecolumn order dynamically? ...

C++ class template of specific baseclass

Let's say I have the classes: class Base{}; class A: public Base{ int i; }; class B:public Base{ bool b; }; And now I want to define a templated class: template < typename T1, typename T2 > class BasePair{ T1 first; T2 second; }; But I want to define it such that only decendants of class Base can be used as templa...

Magento template question

Hello, I have a problem with Magento's configurable product template. http://clientsupports.com/mind/index.php/clothing/bottoms/33.html I would like to move color and size under the price $33.00. I tried to modify catalog.xml in layout directory. I tried to find a template file under catalog/product/view, but I can't find anything. ...

Bugs related to template-functions in GCC 3.4.6

I ran into a strange compile error at the office today and I'm suspecting it to be a bug in our version of GCC (3.4.6). I've been able to boil it down to a few lines of code (below). The compile error I get is: test.cpp:26: error: expected primary-expression before '>' token test.cpp:26: error: expected primary-expression before ')' tok...

Drupal 6: template.php redirections

I haven't worked to much within the template.php file in the Drupal installation, but this time I need to theme a node form. Following an excellent guide I found at http://drupal.org/node/601646, I set up the following snippet. function amity_island_theme($existing, $type, $theme, $path) { if ((arg(0) == 'node') && (arg(1) == 'add') &...

Does calling the constructor of an empty class actually use any memory?

Suppose I have a class like class Empty{ Empty(int a){ cout << a; } } And then I invoke it using int main(){ Empty(2); return 0; } Will this cause any memory to be allocated on the stack for the creation of an "Empty" object? Obviously, the arguments need to be pushed onto the stack, but I don't want to incur any extra ...

Databind a List with a Template to a Dropdown Datasource

I have a Template via: public class OwnedProvinces { public Guid ProvinceID; public string ProvinceName; } And I created a list with this template here: List<OwnedProvinces> getinfo = (from upi in db.Utopia_Province_Data_Captured_Gens where upi.Owner_User_ID == SQLStatementsCS.UserID(...

"Forward-unbreakable" accessor class templates [C++]

Hi, Unless I am thoroughly mistaken, the getter/setter pattern is a common pattern used for two things: To make a private variable so that it can be used, but never modified, by only providing a getVariable method (or, more rarely, only modifiable, by only providing a setVariable method). To make sure that, in the future, if you happe...

Definition of templated member function in templated class (C++)

I have the following templated class, declared in an .hpp file with the implementation in a .inl file included at the end of the .hpp file. It has a templated copy constructor, but I don't know nor can't find anywhere the correct syntax for implementing the templated copy constructor in the .inl file. Does anyone know the correct syntax ...

asp.net - Use ascx as a layout template

This is my layout template (ascx without code behind) <%@ Control Language="C#" AutoEventWireup="true" Inherits="ws.helpers.LayoutUC" %> <div>blah blah blah</div> <ws:Panel runat="server" ID="left"></ws:Panel> <ws:Panel runat="server" ID="main"></ws:Panel> <ws:Panel runat="server" ID="right"></ws:Panel> Modules will be added into ws:P...

How to create a "default" stream insertion operator in C++?

I have a class similar to boost::any, in that it is a templated container class. I'd like to have a method to write the contained value to a string. However, if the contained type doesn't provide a stream insertion operator, I'd like my method to return some default tring rather than failing to compile. Below is as close as I've come, an...

C++ difference of keywords 'typename' and 'class' in templates

For templates I have seen both declarations: template < typename T > And: template < class T > What's the difference? And what exactly do those keywords mean in the following example (taken from the German Wikipedia article about templates)? template < template < typename, typename > class Container, typename Type > class Exampl...

c++ getting dynamic generic type of pointer?

Hi! the title probably is misleading, but i didn't really know how to name it. let's say I have the following structs template <typename T> struct SillyBase{ void doFunnyStuff(vector<T> vec){ dummyField = T(); for(int i=0; i<10; i++) vec.push_back(dummyField++); } T dummyField; }; struct A : pu...

C++ Language template question

Hi, Below is a small test case that demonstrates a problem that I am trying to solve using templates in C++: template<typename T> void unused(T const &) { /* Do nothing. */ } int main() { volatile bool x = false; unused(!x); // type of "!x" is bool } As written below, the g++ v3.4.6 compiler complains: test.cc: In constructor...

Need help with C++ templates

I'm fairly sure this is a template question, since I can't seem to solve it any other way - but non-template solutions are also welcome. A Finite State Machine has a number of program States and each state can react to a number of Events. So, I want to define classes for Event, State and FSM. FSM has a collection (probably vector, migh...

Silverlight 3 Datagrid: Template rows container

Is it possible to template the container for datagrid rows so that they can wrap horizontally? eg in the ItemsControl you can simply change the ItemsPanel to use a WrapPanel. I can't use a ItemsControl because I want to use the Grouping support in the DataGrid when bound to a DomainDataSource. ...

c++ why is constructor in this example called twice?

Hi! I just try to understand the behaviour of the following situation: template <typename T1> struct A{ template <typename T2> A(T2 val){ cout<<"sizeof(T1): "<<sizeof(T1)<<" sizeof(T2): "<<sizeof(T2)<<endl; } T1 dummyField; }; so - the class is templated with T1 and the constructor is templated with T2 now - ...

Is there something similar to WPF DataTemplates in GTK/Glade?

I am coding a pyGTK application, and I'd like to change an input based on the user's selection from a ComboBox. For example, a user could select truck/car/van, and the input parameters would change corresponding to the type of vehicle. Is there a way one can define the different sub-panels using Glade? It would be easy to just define a ...

How to use boost::array with unknown size as object variable

I'd like to use boost::array as a class member, but I do not know the size at compile time. I thought of something like this, but it doesn't work: int main() { boost::array<int, 4> array = {{1,2,3,4}}; MyClass obj(array); } class MyClass { private: boost::array<int, std::size_t> array; public: template<s...