templates

Why can't you define new types in a C++ template argument?

I'm creating a library to allow OCaml/Haskell-like algebraic data types and pattern matching. The algebraic data types are implemented using a class similar to Boost.Variant. I would like to be able to define new types (the constructor) in the template arguments, but I get an error. I'm using my own type with variadic templates, but I'll...

Function template specialization format

What is the reason for the second brackets <> in the following function template: template<> void doh::operator()<>(int i) This came up in SO question where it was suggested that there are brackets missing after operator(), however I could not find the explanation. I understand the meaning if it was a type specialization (full specia...

how to add a new modulo position on a joomla template?

hi there, i'm using a joomla template called decayed and it doesn't have the right position, only the left one and nothing more. i would like to add a right and a button positions on that template. how can i do it? cheers ...

C# Project Type not present in Visual Studio 2005

I have been coding using Visual Studio 2005, in VB.NET for a while. No problems. Recently, I decided I wanted to start a New C# project. Upon attempting to do this, I noticed Visual Studio 2005 was missing this functionality entirely! This is exactly what I get on my screen: Also note that I have both Visual Studio 2003 and 2005 i...

How to write a C++ template that accepts every class and class template?

Be forewarned: This question seems way more obvious than it actually is. I'd like to write a template that can accept any concrete class or template class as a template parameter. This might seem useless because without knowing whether the passed in T is templated or not you won't know how to use it. The reason I want this is so that I ...

Calculate float at compile-time using templates

Hi, I'm new to this whole Template Metaprogramming in C++ mess and I simply can't get this right. The scenario: For example, I've got fractions 2/5, 6/9,... I want to calculate the result of those fractions at compile-time and sort them later using that value at run-time. Is this even possible? Macros maybe? Edit: Thanks Naveen, but i...

WPF button content template

I want the content of a wpf button to be left aligned I tried the following but the text is still centered inside the button. <Button > <StackPanel HorizontalAlignment="Stretch"> <TextBlock HorizontalAlignment="Left" Text="Save"/> </StackPanel> </Button> What do i do? ...

c++ functor and function templates

consider this simple and pointless code. #include <iostream> struct A { template<int N> void test() { std::cout << N << std::endl; } }; int main() { A a; a.test<1>(); } It is a very simple example of a function template. What if however, I wanted to replace A::test with an overloaded operator() to make it a ...

Why can't I nest a block tag inside an if tag?

I have a master template file called base.html, in it I have the following code: {% ifequal environment "dev" %} {% block stylesheets %}{% endblock %} {% endifequal %} I inherit this in other templates and do the following: {% block stylesheets %} <link ... > {% endblock %} The problem is, the stylesheet I link never gets a...

How to escape special characters in Groovy's SimpleTemplateEngine?

By default, groovy's SimpleTemplateEngine uses <% %> as the scriptlet container. How do I escape these characters if I want to print out <% %>? ...

Dynamically change GridView item template

I have a fairly big asp.net website that use GridView bound to the same object in lots of places. I'm using an item template to customize each row. However to have the same template in all the pages I have to copy & paste the item template to each page. Obviously this is not the best solution. On top of this I want to be able to change t...

Header File Template

Is there a standard template to use for .NET source code files? I am accustom to putting my header information between /* */ tags, but StyleCop is complaining about those. ...

WPF Reference ScrollContentPresenter of ScrollViewer Template

I have a WPF ScrollViewer, and I would like to get to the ScrollContentPresenter of it's template. ...

How to implement Template Inheritance (like Django?) in PHP5

Is there an existing good example, or how should one approach creating a basic Template system (thinking MVC) that supports "Template Inheritance" in PHP5? For an example of what I define as Template Inheritance, refer to the Django (a Python framework for web development) Templates documentation: http://docs.djangoproject.com/en/dev/to...

Template specialisation where templated type is also a template

I've created a small utility function for string conversion so that I don't have to go around creating ostringstream objects all over the place template<typename T> inline string ToString(const T& x) { std::ostringstream o; if (!(o << x)) throw BadConversion(string("ToString(") + typeid(x).name() + ")"); return o.str...

Generating JavaScript with templates in ASP.Net

I have a need for generating JavaScript on the server. I can do this by using ASPX pages to template JavaScript but I'm getting warnings and I don't benefit from syntax hilighting which I would like. Is there a way to tell the .Net environment/Visual Studio that a certain ASPX page is supposed to output non-HTML text? The reason for thi...

Joomla, display diferent templates for each article

I have 2 Joomla templates installed on my site, I would like one of the pages to use the one template and the rest of the site to use the other template. Is this possible? ...

WPF: Switch Template based on UserControl Data

Trying to implement what I thought was a simple concept. I have a user control (view) bound to a view model which provides a list of data. I have added toggle buttons to the usercontrol and would like to allow the user to use these toggle buttons to switch out which template is used to show the data. All of the templates used for the ...

Templated Barton and Nackman Trick Problems

I'm trying to implement class using the Barton and Nackman trick to avoid dynamic dispatch. (I'm writing MCMC code where performance matters.) I'm not a C++ expert but the basic trick is working for me elsewhere. However I now have a case where the second derived class needs to be templated. This seems to cause problems. The outline ...

Channging Template

Hi All, I have a togglebutton on which I want to use two different template on Checked and Unchecked State. When the ToggleButton is Clicked (IsChecked=True) I want to Use template 1 and when it is clicked for the second time I want to use Template 2. That's it !!! How can I do that ?? Should I use Event Trigger or Trigger for that...