templates

Abstract base class puzzle

In my class design I ran into the following problem: class MyData { int foo; }; class AbstraktA { public: virtual void A() = 0; }; class AbstraktB : public AbstraktA { public: virtual void B() = 0; }; template<class T> class ImplA : public AbstraktA { public: void A(){ cout << "ImplA A()"; } }; class ImplB ...

error C2784: Could not deduce template argument

Hi guys, Still fighting with templates. In this example, despite the fact that is copied straight from a book I'm getting the following error message: Error 2 error C2784: 'IsClassT<T>::One IsClassT<T>::test(int C::* )' : could not deduce template argument for 'int C::* ' from 'int'. This is an example from a book Templates - The Comple...

Force type of C++ template

Hi, I've a basic template class, but I'd like to restrain the type of the specialisation to a set of classes or types. e.g.: template <typename T> class MyClass { .../... private: T* _p; }; MyClass<std::string> a; // OK MYCLass<short> b; // OK MyClass<double> c; // not OK Those are just examples, the allowed types may...

Using type passed as a template in C++

Is it possible to actually use the type passed as a template for control flow? I'd like to write a function that uses templates, which in turn calls another function based on the type passed: template <class T> void test_function (T var) { //Do stuff if (T == char) { bar (var); } else { foo (var); } /...

How to generate lots of redundant ajax elements like checkboxes and pulldowns in Django?

Hello folks. I've been getting lots of answers from stackoverflow now that I'm in Django just by searching. Now I hope my question will also create some value for everybody. In choosing Django, I was hoping there was some similar mechanism to the way you can do partials in ROR. This was going to help me in two ways. One was in gener...

Template with constant expression: error C2975 with VC++2008

Hello, I am trying to use elements of meta programming, but hit the wall with the first trial. I would like to have a comparator structure which can be used as following: intersect_by<ID>(L1.data, L2.data, "By ID: "); intersect_by<IDf>(L1.data, L2.data, "By IDf: "); Where: struct ID{};// Tag used for original IDs struct IDf{};/...

Why this works (Templates, SFINAE). C++

Hi guys, referring to yesterday's post, this woke me up this morning. Why does this actually work? As long as the function test is concerned, this function has no body so how can it perform anything? I want to know why and how this works? I'm REALLY interested to see your answers. template<typename T> class IsClassT { private: ...

write php codes independent from template

How can I write php codes independent from XHTML codes? Thanks in advance ...

ASP.NET custom templated datalist throws argument out of range (index) on button press

I have a class BaseTemplate public abstract class BaseTemplate : ITemplate This adds the controls, and provides abstract methods to implement in the inheriting class. The inheriting class then adds its html according to its data source and manages the data binding. This all works fine - I get the control appearing with properly parse...

Strange declaration(templates). C++

How can I understand what is declared here: (this is taken from another post on this forum) template<typename C> static char (&f(ChT<int Fallback::*, &C::x>*))[1]; Here's how I read: template of static function f called with (ChT<int Fallback::*, &C::x>*), but then I can't make sense why is there an address-of operator and why is the...

Visual Studio 2008 Create Word 2007 Template Project Crashes

I've got this weird crashing happening when creating a C# Word 2007 Template Project in Visual Studio 2008. The IDE tells me that it's creating the project (it does create the solution and C# vsproj as well as the dotx and cs files). Then the IDE just crashes - no errors, messages, etc. When I try devenv /SafeMode it still doesn't work. ...

Create hyperlink in django template of object that has a space

I am trying to create a dynamic hyperlink that depends on a value passed from a function: {% for item in field_list %} <a href={% url index_view %}{{ item }}/> {{ item }} </a> <br> {% endfor %} The problem is that one of the items in field_list is "Hockey Player". The link for some reason is dropping everything after the space, s...

Using free function as pseudo-constructors to exploit template parameter deduction

Is it a common pattern/idiom to use free functions as pseudo-constructors to avoid having to explicitly specify template parameters? For example, everyone knows about std::make_pair, which uses its parameters to deduce the pair types: template <class A, class B> std::pair<A, B> make_pair(A a, B b) { return std::pair<A, B>(a, b); } /...

Generate Visual Studio Project Templates with CruiseControl.Net or MSBuild

Hey all. I have a working workflow in CruiseControl.Net that successfully builds and tests an MSBuild project that is calling my Visual Studio 2010 solution. How do I create Visual Studio project templates in either CruiseControl.Net or with MSBuild? The build server does not have Visual Studio 2010 installed. Thanks for your time! N...

What is a good CPU/PC setup to speed up intensive C++/templates compilation?

I currently have a machine with an Opteron 275 (2.2Ghz), which is a dual core CPU, and 4GB of RAM, along with a very fast hard drive. I find that when compiling even somewhat simple projects that use C++ templates (think boost, etc.), my compile times can take quite a while (minutes for small things, much longer for bigger projects). Unf...

Good Administration Center Templates

Hello, This may not be a programming question per se. But I am wondering what template do you use for your sites/webapps admin centers. Am looking primarily at free templates that give a basic structure. I know I can build my own, but I haven't had too much success in something that works for all my webapps/sites. Wondering if there is ...

Joomla - template dissapearing

Hello, I have a Joomla Website located at http://www.MikeSilvis.com, and upon going to the site initially everything looks fine. However if you go into the site and click any link say web-design You can see that the default template is no longer being displayed. I have tried changing to a different template but that does not seem to ...

how to render data received from JSON in Social App with OpenSocial Templates!

Hi all, I am getting data in the Social App in form of JSON. I am using OpenSocial v0.9 Templates to render data in the App with the tag but the problem is I want to render data in tabular form, but with it repeats items in a row so is there any way possible! Regards, Abhishek ...

php define variable inside str_replace array

I have a template system, that replaces text such as {HEADER} with the appropriate content. I use an array like this, that replaces the key with the value using str_replace. $array = array("HEADER","This is the header"); foreach($array as $var => $content) { $template = str_replace("{" . strtoupper($var). "}", $content,$templ...

Access Specific Choice Widget/Field from ChoiceField

Anyway to access the widget/render a specific choice from a ChoiceField? APPROVAL_CHOICES = ( ('true', 'Approve'), ('false', 'Re-Submit') ) class ProofApprovalForm(forms.Form): approved = forms.ChoiceField( choices=APPROVAL_CHOICES, widget=forms.widgets.RadioSelect ) Would like to access the choices i...