templates

C++ type traits to check if class has operator/member

hi Is it possible to use boost type traits or some other mechanism to check if a particular template parameter has an operator/function, e.g. std::vector as a template parameter has operator[], while std::pair does not. ...

Silverlight TemplateBinding to RotateTransform

I am trying to create the simplest Silverlight templated control, and I can't seem to get TemplateBinding to work on the Angle property of a RotateTransform. Here's the ControlTemplate from generic.xaml: <ControlTemplate TargetType="local:CtlKnob"> <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5"> <Grid.RenderTransform> ...

Enabling overriding of app template in django?

I'm writing a simple site to display statistics for some data, and I've got an app called "stats", that I'd like to write default templates for (places in stats/templates/stats), but I'd like these to be overridable in the same way that the templates for the admin app are. IE: If I put a stats/view.html in my project's templates directo...

Don't show application layout on popup window using Rails

I have a rails application using views/layouts/application.html.erb as the default site template. I'm just about to add several popup windows. These shall not inherit and display the application template. How can I exclude several views from loading the application template? Any help would be very appreciated. ...

How to pass a row of boost::multi_array and std::vector by reference to the same template function?

I have a problem with this bit of code: #include <boost/multi_array.hpp> #include <boost/array.hpp> #include <vector> #include <iostream> template <typename Vec> void foo(Vec& x, size_t N) { for (size_t i = 0; i < N; ++i) { x[i] = i; } } int main() { std::vector<double> v1(10); foo(v1, 5); std::cout << v1[4...

Writing a good Wordpress template

I was asked to write a custom template for a wordpress based site, and I'm noticing that themes are usually one big unreadable mess of PHP code mixed with HTML, with a terrible indenting on top of it -- even the default template follows this style. What I'm doing now is put all the PHP code first, then the markup with minimum PHP just f...

Is the number of types in a C++ template variant limited?

I'm trying to understand how variants are implemented, and reading: http://www.codeproject.com/KB/cpp/TTLTyplist.aspx And I'm getting the impression that I can't write a variant that takes X types; but that the template writer picks some N, and I can only have less than-N types in a variant. Is this correct? Thanks! ...

How to use Google Docs for Mailer templates?

Is it possible to use Google Docs for Mailer templates? How can I change template variables via API? Basically, I want to keep a template on Google and export it as a PDF file after changing few variables like name, address etc. Is it possible to do it completely via API in PHP? EDIT LiveDocX is providing these features but I think do...

Preprocess SHPAML in Django's template loader?

Is there any way to make Django's template loader run all templates it loads (i.e. directly or via extend/include) through SHPAML if it figures the HTML is out of date? I know how to invoke SHPAML recursively over an entire directory, but I would prefer to be able to run it on demand so I don't have to remember to sync the HTML every ti...

Writing eclipse templates

I am writing django templates in Eclipse->prefrences->templates, to autocomplete DJango templates. I wrote this {% block ${cursor} %} {% endblock %} Now, when I request and do autocompletion, after typing {% the autocompletion is {% {% block %} {% endblock %} While I would like {% block %} {% endblock %} With cursor after ...

How to implement a basic Variant (& a visitor on the Variant) template in C++?

I have tried reading: http://www.boost.org/doc/libs/1_41_0/boost/variant.hpp http://www.codeproject.com/KB/cpp/TTLTyplist.aspx and chapter 3 of "Modern C++ Design" but still don't understand how variants are implemented. Can anyone paste a short example of how to define something like: class Foo { void process(Type1) { ... }; ...

Templates .dwt in Dreamweaver

I edited my site with FrontPage, there I created some template pages .dwt in the root of the each language /en/master.dwt /fr/master.dwt and so one. Now, when passed the site under Adobe Dreamweaver, it seems do not "recognize" them. I understood that Dreamweaver puts all templates in a folder Templates, but... I don't want it. It br...

How can a server control within a template be sensitive to the data context?

Let's say a control X has a template called RowTemplate. So X's markup would be like: <foo:X> <RowTemplate> <foo:Y>...</foo:Y> </RowTemplate> </foo:X> My question is: How can the Y control be sensitive to the data context? I know I can use template inline tags to get access to the data context: <%# Eval("Id") %>, but ...

Rails Templates?

I am starting to learn Ruby on Rails. I have an application in mind that I would like to create, but I know I'm going to have to repeat a lot of the things that have already been done a million times (such as user authentication, etc). I just found out about rails templates. From what I understand, you can use one of these templates to ...

c++ template casting with derived classes

#include <vector> struct A {int a;}; struct B : public A {char b;}; int main() { B b; typedef std::pair<A*, A*> MyPair; std::vector<MyPair> v; v.push_back(std::make_pair(&b, &b)); //compiler error should be here(pair<B*,B*>) return 0; } I don't understand why this compiles (, maybe somebody may kindly provide detailed expla...

Adding item to list in C++

Hi, I am using two classes in my C++ application. The code is as follows: class MyMessageBox { public: void sendMessage(Message *msg, User *recvr); Message receiveMessage(); list<Message> dataMessageList; }; class User { public: MyMessageBox *dataMsgBox; }; The msg is a pointer to a derived class object of Message cl...

C++ templated constructor won't compile

How come I can't instantiate an object of type Foo with above constructor? I have a class Bar that uses an internal typedef (as a workaround for "template typedefs") and intend to use it in a constructor as below (CASE 1). However, I don't seem to get it to compile. Is this legal C++? CASE 2 seems to suggest the problem is related to th...

Custom Control Not Rendering After Event

I am just playing with custom controls, and have one built that looks like so: <cc:Test ID="jqTestTest01" runat="server" OnTestClick="jqTestTest01_TestClick"> <TestItems> <asp:ListItem Text="Tab One" Value="1" Selected="True" /> <asp:ListItem Text="Tab Two" Value="2" /> <asp:ListItem Text="Tab Thr...

How to force WPF UI element to use resources from the theme, ignoring app's resources

Is there a way to make a WPF element use (explicitly or implicitly) the resources located in themes even if app.xaml provides resources with the same 'key'-s? I have all of the default controls restyled, and all those styles are merged to the app's ResourceDictionary. Now I have one single XAML file that has a single element which I'd l...

How to correctly initialize variable of template type?

Hi, suggest i have a template function like following: template<class T> void doSomething() { T a; // a is correctly initialized if T is a class with a default constructor ... }; But variable a leaves uninitialized, if T is a primitive type. I can write T a(0), but this doesn't work if T is a class. Is there a way to initializ...