templates

Seperating template class into multiple files yields linking issues

I have created an example below to illustrate the problem I'm having. Basically, when I separate a template class into separate .h/.cpp file, I get unresolved symbols for the constructor. Using a single file, it compiles fine. What is causing this? fruits.cpp: #include "apple.h" class FruitsDB { public: void addApple();...

Steal/borrow Visual Studio 2010 tabcontrol-template?

I want/would like a TabControl with TabItem's I can close (with an x) and move around. If I also could move the tabitems to other screens it would be great. In fact I want it exactly as in VS2010 with docking and splitting side-by-side etc. But to implement all this by my self would take weeks. Thats life I suppose, but perhaps there is ...

Writing templates without using html for ruby on rails/django

I hate to explicitly use html/css to build pages. Is there a template language I can use to semantically and quickly describe the layout and content of the page so that later I can generate html and css from it? I'm planning to use this on a django site (but I guess if such solution already exists for RoR I can always adapt it). Thank...

Shared template member function of multiple classes

I have multiple classes that are quite different in their behavior, but at the same time, share common functions that have to access the member variables. So what I want to do, is to create a templated member function to avoid extra copy-paste code duplication. The final result should be like: ClassA::CallFoo() ClassB::CallFoo() Class...

Is it possible to have a function(-name) as a template parameter in C++?

I don't want function pointer overhead, I just want the same code for two different functions with the same signature: void f(int x); void g(int x); ... template<typename F> void do_work() { int v = calculate(); F(v); } ... do_work<f>(); do_work<g>(); Is this possible? To clear up possible confusion: With "template paramete...

overload resolution in templates

Any one Explain this with an example "Involving conversions on a function argumentsinvolved in template parameter deduction." EXamples like this: template<class T> struct B { /* ... */ }; template<class T> struct D : public B<T> { /* ... */ }; template<class T> void f(B<T>&); void g(B<int>& bi, D<int>& di) { f(bi); ...

Operator overloading on class templates

I'm having some problems defining some operator overloads for template classes. Let's take this hypothetical class for example. template <class T> class MyClass { // ... }; operator+= // In MyClass.h MyClass<T>& operator+=(const MyClass<T>& classObj); // In MyClass.cpp template <class T> MyClass<T>& MyClass<T>::operator+=(const ...

Turning boost::tuples::cons<...> back into the corresponding boost::tuple<...>

For a little library project I'm using boost::tuple. Right now, I'm facing the problem of turning a "cons list" I operated on via metaprogramming back to a boost::tuple<...> type. The "dirty" solution would be to provide lots of partial specialications a la template<class T> struct id{typedef T type;}; template<class TL> struct type_li...

Can templates such as boost::mpl::integral_c be registered with Boost.Typeof?

boost::mpl::integral_c is declared as: template <typename T, T N> struct integral_c; Is it possible to register this sort of template with Boost.Typeof: For any T? For some T's? ...

recursive c++ template problem

Say I have a template class that takes msgs from source, does something smart to them, and then sends them to a sink: template <typename Source, typename Sink> class MsgHandler { MsgHandler(Source* pSource) : m_pSource(pSource) { m_pSource->setHandler(this); } }; //Now the definition of the Source: template <typename Handler> class ...

Microsoft JQuery Template plugin: Script Stack Space Quota is Exhausted

I read a few questions regarding the Firefox "Script Stack Space Quota is Exhausted." The answers are usually "work with less data". However, how much "JSON" data we process is not the issue. We created a very small template, then loaded over 700 products with that template without an issue. The problem seem to be how much HTML is in...

How do I modify the Magento Share Wishlist email template??

I don't know where to find the "Share Wishlist" email template. I want to change the part where it says "Demo Store" to the proper store name. I also want to change it to a variable that points to the store name specified in the store configuration so that it automatically changes whenever the store name changes. ...

Dirt-simple PHP templates, continued

Background So, last time I inquired about PHP templates, I got a lot of responses like: it isn't needed; PHP is a good enough templating language on its own. it's hard to develop a templating language that is both powerful and easy for designers to work with (or around). it's already been done, use templating framework X. you're st...

How to create a library that wraps an object with a template function using minimal includes?

The goal of this project is to create a library for distribution. In the past, I used forward declares so I didn't have to distribute a bunch of header files along with the libraries. However, I'm now trying to eliminate code duplication by switching to templates and am running into some issues. First, a simple example project showi...

separate layout from templates in perl cgi::application

I am building a perl cgi::application using html::template. I am using 7-8 different templates having the same layout - header, footer, left column etc. How can I separate this html out of the template files into a single layout file. What perl modules do I need in addition to cgi::app and html::template. Thanks ...

What circumstances should someone "try...catch"? Does this apply to libraries?

Suppose you're designing an application (WebApp, Desktop, anything) and you need to define exception handling for the code. Since you want to make things reusable, what logic should you follow when handling exceptions? Are there any patterns to follow? For example, if some DLL is going to use the network and the network is unreliable, ...

Mutating PDF editable fields programatically

Out of tons of questions and answers here about manipulating PDF's with PHP, but none of them seem to fit my requirement. Programmatically, I want to be able to update the content of editable fields. Preferably with PHP. If it matters, the PDF files will be initially hand crafted (as sort of 'template' files that will be copied and fi...

Changing base template based on request.user in Django

I want to modify part of my base navigation menu based on a flag on the user model, without having to include request.user in every single view function in my codebase. The nav menu is part of the base template which every other template extends. Is there a simple way to do this (if so, I suck at search)? If not, is there a standard w...

Why can't I downcast pointer to members in template arguments?

If I make a pointer-to-base-member, I can convert it to a pointer-to-derived-member usually, but not when used within a template like Buzz below, where the first template argument influences the second one. Am I fighting compiler bugs or does the standard really mandate this not work? struct Foo { int x; }; struct Bar : public Foo ...

Beginner Need Help with a Temmplate

Im trying to make a Calendar thats more convenient in my line of business. Im trying to make a better calendar than the stock iphone one. i found a template from http://github.com/guicocoa/GCCalendar anyways, how do i set the + sign to start working so i can add upcoming event parties and other info. and if i have to make one, how do i g...