invalid use of incomplete type

I’m trying to use a typedef from a subclass in my project, I’ve isolated my problem in the example below. Does anyone know where I’m going wrong? template<typename Subclass> class A { public: //Why doesn’t it like this? void action(typename Subclass::mytype var) { (static_cast<Subclass*>(this))->do_action(var); } }; class B : public A<B> { public: typedef int … Read more

Ruby templates: How to pass variables into inlined ERB?

I have an ERB template inlined into Ruby code: require ‘erb’ DATA = { :a => “HELLO”, :b => “WORLD”, } template = <<-EOF current key is: <%= current %> current value is: <%= DATA[current] %> EOF DATA.keys.each do |current| result = template.result outputFile =,File::CREAT|File::TRUNC|File::RDWR) outputFile.write(result) outputFile.close end I can’t pass the variable … Read more

Declare variable in a Play2 scala template

How do you declare and initialize a variable to be used locally in a Play2 Scala template? I have this: @var title : String = “Home” declared at the top of the template, but it gives me this error: illegal start of simple expression “””),_display_(Seq[Any](/*3.2*/var)),format.raw/*3.5*/(“”” title : String = “Home” Answer @defining(“foo”) { title=> <div>@title</div> … Read more

Why does the order of template argument substitution matter?

C++11 14.8.2 – Template Argument Deduction – [temp.deduct] 7 The substitution occurs in all types and expressions that are used in the function type and in template parameter declarations. The expressions include not only constant expressions such as those that appear in array bounds or as nontype template arguments but also general expressions (ie. non-constant … Read more

Can Mustache Templates do template extension?

I’m new to Mustache. Many templating languages (e.g., Django / Jinja) will let you extend a “parent” template like so… base.html <html><head></head> <body> {% block content %}{% endblock %} </body> </html> frontpage.html {% extends “base.html” %} {% block content %}<h1>Foobar!</h1>{% endblock %} rendered frontpage.html <html><head></head> <body> <h1>Foobar!</h1> </body> </html> I’m aware of Mustache’s partials (e.g., … Read more

C++11 does not deduce type when std::function or lambda functions are involved

When I define this function, template<class A> set<A> test(const set<A>& input) { return input; } I can call it using test(mySet) elsewhere in the code without having to explicitly define the template type. However, when I use the following function: template<class A> set<A> filter(const set<A>& input,function<bool(A)> compare) { set<A> ret; for(auto it = input.begin(); it … Read more

AngularJs (1.X) Include Partial Template

I’ve this in my main layout file <body> <header id=”header” ng-controller=”HeaderController”></header> <div class=”container” ng-view></div> I’ve a header.html partial template in my directory structure. How to include this template in my app? I thought angular automatically includes the template after processing the controller, but it doesnt work. The header node should be replaced with the content … Read more