templates

C++: Template Parameter Cyclic Dependency

Hello, This is more a best practice question than a language question in itself, since I already have a working solution to what seems to be a common stumbling block in C++. I'm dealing with a typical cyclic dependency issue in template parameter substitutions. I have the following pair of classes: template<class X> class A { /* ... *...

Good Ideas for Automating Common CRUD Operations in Rails

Short version: What are some good ways to allow the end user to define "processes" or sequentially executed CRUD operations in a fairly large project, so they can build templates for common processes (like creating 2 tickets for each new event posted automatically)? Something like Cucumber, but for CRUD operations..., or even Selenium? ...

Who Creates Custom ActionMailer Layouts in Rails, You or the Client?

When projects get large, I imagine you might start having 100s of mailer templates: user_signup_confirmation.html.erb user_signup_failure.html.erb user_account_activation.html.erb user_account_cancelation.html.erb ... What is your workflow for handling this? Do you have them email you what they want and then you mold it into a metho...

WPF ControlTemplate partial replace

Hi ! Suppose we have a very 'XAML long' ControlTemplate for our Control. And we want to add just 1 Button to the Template. MSDN claims that 'There is no way to replace only part of the visual tree of a control'. Do I really have to copy all that ControlTemplate and add my Button to it? Or: Is there any possibility how to provide some...

how to mimic template classes in php

Hello, How to mimic C++ template classes in PHP? EDITED1 For example how would this be in PHP? template <typename T> class MyQueue { std::vector<T> data; public: void Add(T const &d); void Remove(); void Print(); }; ...

wordpress custom page template

I have created a custom page named 'products' <?php /* Template Name: Products */ ?> <?php get_header(); ?> <div id="products_content"> <div id="products_page_header"> <div id="products_page" title="محصولات"> <?php if (have_posts()) : while (have_posts()) : the_post();?> <div class="post"> <h2 id="post-<?php ...

Template deduction in dynamic_cast

I have a class that is defined as the following: template <class WidgetType> class CometWidget : public WidgetType; Inside a function I am doing this: dynamic_cast<CometWidget *>(iter2->second.second)->changesCommited_(); and it resolves the CometWidget type, complies and run correctly. The code runs inside the CometWidget class....

In Django, I know how to build a template. render_to_response('something.html'). But, how do I include a JSON object in there?

When the page loads, I have a JavaScript function that needs to analyze the JSON. But, this JSON must be present when I load "something.html" I know how to do this, but I don't know how to combine them together. return HttpResponse(thejson, mimetype="application/javascript") ...

how do I fix this c++ typelist template compile error?

(from reading chapter 3 of modern c++ design) typelist.hpp: class NullType {}; struct EmptyType {}; template <class T, class U> struct Typelist { typedef T Head; typedef U Tail; }; #define TYPELIST_1(T1) Typelist<T1, NullType> #define TYPELIST_2(T1, T2) Typelist<T1, TYPELIST_1(T2) > #define TYPELIST_3(T1, T2, T3) Typelist<T1, T...

How to build this c++ typelist into a variant?

Here, http://stackoverflow.com/questions/2150618/how-do-i-fix-this-c-typelist-template-compile-error we built a typelist, using the code from modern c++ design. Question is now -- how do I take this and built it into a variant class? Thanks! ...

how to write a c++ template that gives the maximum of two args?

Both arguments are guaranteed to be integers. How do I write myMax such that: myMax<1, 2>; // 2 myMax<3, 2>; // 3 ? I want this to be evaluated at compile time, not run time. (Need to then use this with sizeof for a typelist to allocate space for a variant.) Thanks! ...

C++ optimise class template function when template parameters identical

I've got a template class with a template method within it, giving two template parameters T and U. The operation is quite expensive and is showing up in profiling to be a major use of CPU time. I could optimise it somewhat, but only for the case where T == U (which is fairly common), however I'm not sure on the syntax for doing this... ...

How do I force a particular instance of a C++ template to instantiate?

See title. I have a template. I want to force a particular instance of a template to instantiate. How do I do this? More specifically, can you force an abstract template class to instantiate? ...

Template assertion in C++?

Is there a way to define a template assertInheritsFrom<A, B> such that assertsInheritsFrom<A, B> compiles if and only if class A : public B { ... } // struct A is okay too Thanks! ...

Displaying dictionary value in django template

All, I have the following in my views.py def getgradeform(request): id1=request.user.get_pf().id sc=Sc.objects.filter(id=id1) logging.debug(sc) logging.debug("++++") dict={} dict.update({'sc': sc}) return render_to_response('content/add.html',dict) Logging.debug gives an output as [<sc: Robert>] My question is t...

Template extraction in python/php

Are there existing template extract libraries in either python or php? Perl has Template::Extract (http://search.cpan.org/%7Eautrijus/Template-Extract-0.40/lib/Template/Extract.pm), but I haven't been able to find a similar implementation in either python or php. The only thing close in python that I could find is TemplateMaker (http:/...

templated member function to boost multi index container

Hi, I have a boost multi index container thus. using namespace boost::multi_index; template < typename O > class Container { public: multi_index_container< O, indexed_by< ordered_unique< const_mem_fun< O, std::string, &O::name > > > > _container; }; As you can se...

How do I make a tiny 'shadow' under an image, like this one?

http://www.deviantart.com/#order=9&amp;q=sun As you can see, each picture...underneath it...it has a little tiny shadow around the edges. How can this be done with a variable size image? (css) ...

ASP.NET Databinding Template: Escape Tags in a Server Tag

I'm doing some databinding inside a ListView ItemTemplate, but I suspect this is a problem for any databinding/template situation. I want to write something like: <asp:HiddenField runat="server" ID="hidPositionID" Value="<%#Eval("PositionID") %>" /> But I get a YSOD with an error message that the server tag is not well formed. How d...

hide function template, declare specializations

This is a followup to http://stackoverflow.com/questions/2050900/c-templates-prevent-instantiation-of-base-template I use templates to achieve function overloading without the mess of implicit type conversions: declare the function template, define desired specializations (overloads). all is well except wrong code does not produce erro...