templates

Why does initialization of a template type require a repeat of the type of the variable?

Suppose I have an object that has a member variable that is of some template type. So, in the declaration of the class, there would be something like this: // This is just the declaration of bar which is a member of some class. templatizedType<Foo> bar; Now, when I want to initialize bar why do I have to do // This is the initializa...

Template specialization problem

Hi, I'm trying really hard to made this work, but I'm having no luck. I'm sure there is a work around, but I haven't run across it yet. Alright, let's see if I can describe the problem and the needs simply enough: I have a RGB template class that can take typenames as one of its template parameters. It takes the typename and sends it...

Generating compile time errors for invalid data types in a template class?

I am using C++ to create a string class. I want the class to only accept the data types char and wchar_t and I want the compiler to catch any invalid data types during compile time using #error. I do not like using assert( ). How can I do this? ...

Letting users custom skin

As an exercise, I'm trying to wrap my head around what goes into letting a user custom skin their profile (like myspace as an example). I'm using PHP. Since I'm clueless as to the whole thing, I'm not sure what to ask, but some of my concerns are how complex this is, is it going to require an overhaul of my code, can I separate this part...

Intermediate results using expression templates

Hi, in C++ Template Metaprogramming : Concepts, Tools, and Techniques from Boost and Beyond ... One drawback of expression templates is that they tend to encourage writing large, complicated expressions, because evaluation is only delayed until the assignment operator is invoked. If a programmer wants to reuse some intermediate res...

debugging templates with GDB

Hi all. My gdb is GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh). And I can't debug templates. Can anybody help me? How can I debug templates with this debugger? Thanks. ...

Need a vector that derives from a vector.

Hi, Consider this simple code: class A { }; class V1: vector<A *>{ // my nice functions }; if I have a instance of V1, then any object derived from A can be inserted into the vector, ok here. Now, lets say I have two simple classes called B and C both derives from A; if I have a instance of V1, then both pointers of B and C can...

Extend base template in Smarty

Hello, Is it possible to extend a base template with another template in Smarty? I know this is possible in Django using the {% entend %} tag. Is there an equivalent (or workaround) in Smarty? Thanks ...

WPF TemplateBinding with custom class

Hi, I have a custom class that extends "Control" like so: class TheCountry : Control { //...details } Then I have that element in my XAML: <Canvas x:Name="mainCanvas" Height="768" Width="1536" AllowDrop="False"> <spots:TheCountry Country="Australia" Canvas.Left="1362" Canvas.Top="486" Template="{DynamicResource TheCountr...

How do I invoke a non-default constructor for each inherited type from a type list?

I'm using a boost typelist to implement the policy pattern in the following manner. using namespace boost::mpl; template <typename PolicyTypeList = boost::mpl::vector<> > class Host : public inherit_linearly<PolicyTypeList, inherit<_1, _2> >::type { public: Host() : m_expensiveType(/* ... */) { } private: const ExpensiveType m...

How to use a Dynamic Data page template in a CreateUserWizard TemplatedWizardStep

I am busy building an ASP.NET website that runs off a SQLServer 2008 backend database and I am using LinqToSQL and Dynamic Data. I use ASP membership for user registration. However I need to capture extra user information that is stored in other tables. I am using ASP's built-in controls i.e. login, change password, create user wizard et...

Why use a templating engine with a framework?

I recently discovered the PHP framework Kohana (which is awesome) and was reading a thread about using it in conjunction with a templating engine such as Smarty or Twig. My question is why bother? Surely an MCV framework, by definition, is a templating engine. Even "raw" PHP is, arguably, a templating engine. What possible benefits are t...

Question regarding RJS and usage of link_to_remote

I was working on my website when I cam across this problem, I have 100 posts in my blog and I am paginating them 10 at a time, I display the 1st 15 and display a link at the bottom which basically is implemented using the link_to_remote tag. <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => link.to_i + 1} , :html => {:...

XML template in Java

Hi, I need to generate xmls and these differ only in the values that the tags contain. Is it possible to create a template xml and then write only the values each time?(I do not want to go the jaxb way as these are small xmls and are not worth creating objects for them). Is this a good approach? Any thoughts / pointers will help me dec...

Boost::typeof compiler problem: mangling typeof, use decltype instead

Hi, short example: #include <boost/typeof/typeof.hpp> #include <boost/proto/core.hpp> using namespace boost; template<class T, class U> BOOST_TYPEOF_TPL(T() + U()) add2(const T& t, const U& u) { return t + u; }; int main(){ typedef BOOST_TYPEOF(add2(2.5, 1.5)) type; // get type -> works BOOST_STATIC_ASSERT((is_same...

Will Visual Studio 2010 support HTML 5?

Since Visual Studio 2010 is slated for release in March of 2010 and HTML 5 is now starting to be used even more widely, I would like to know if Visual Studio will ship with HTML 5 templates, standard controls and support for the more common markup? A definition for support of HTML 5 would be that any new version of Visual Studio should ...

Templates: template function not playing well with class's template member function

This is a minimal test case of some code that I actually have. It fails when it tries to evaluate a.getResult<B>(): test.cpp: In function 'void printStuff(const A&)': test.cpp:6: error: expected primary-expression before '>' token test.cpp:6: error: expected primary-expression before ')' token The code is: #include <iostream> templa...

problem with link_to_remote in Rails 2.1

I am facing this strange problem with the following section of code <% if (@more == -1) %> <%= link_to_remote "More Posts", :html => {:id => 'more-link', :onClick => 'return false;'}%> <% else %> <%= link_to_remote "More Posts", :url => {:action => 'view' ,:id => @more.to_i + 1} , :html => {:id => 'more-link'} %> <% end %> Now whe...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the column's background in which the mouse is over should be yellow and all the color in the other columns should be, let's say, blue. I've tried ...

PHP beginner - looking for veteran criticism of code example (code works btw, that's a start!)

From what I've gathered browsing SO, I'm the worst nightmare of good people like you: someone who never formally learned any programming, decided he'd like to enhance his hobby website, and bought a fast-track PHP book off the shelf and went at it. Browsing SO has taught me a great deal of things, highlights of which include: PHP is t...