templates

Default template parameter in constructor

So I have this piece of code and out of convenience I want the default parameter for its constructor be of the int kind and 0. (I have more parameters in a class of my project and one of them is optional and I don't want to write the constructor twice because its big) class mama{ public: template<typename x> mama(x i=int(0)){} }...

Throw-catch cause linkage errors

I'm getting linkage errors of the following type: Festival.obj : error LNK2019: unresolved external symbol "public: void __thiscall Tree::add(class Price &)" (?add@?$Tree@VPrice@@@@QAEXAAVPrice@@@Z) referenced in function __catch$?AddBand@Festival@@QAE?AW4StatusType@@HHH@Z$0 I used to think it has to do with try-catch me...

ruby ERB template debugging, display as ruby

Question: Instead of getting transformed output from my ERB template, is there a parameter, setting or hack I can use that will output the raw ruby code that gets generated right before the transformation runs? Rationale: I am having trouble figuring out the problem with an ERB template syntax error, and I would like to see the plain ru...

Cheap php templating with vprintf?

Ok, so printf/sprint/vprintf all accept a certain type specifier syntax %[num][type]. (http://us2.php.net/sprintf see examples 3 and 4) Where num is the index to the type. Example: vprintf('Number %1$d string %2$s. String %2$s, number %1$d',array(1,"no")); Yes, it is limited... And you would need to maintain the indexes. But it's nativ...

PHPBB3 How to display Last Post Title in index

I am using the prosilver theme in phpbb3. In the file forumlist_body.html there is a part that looks like this: <dd class="lastpost"><span> <!-- IF forumrow.LAST_POST_TIME --> <dfn>{L_LAST_POST}</dfn> {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL} <!-- IF not S_IS_BOT --> <a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- E...

C++ Function Pointer issue

For some reason trying to pass a pointer to this function to a varadic function produces the following error: 1>c:\... : error C2664: 'PyArg_ParseTuple' : cannot convert parameter 3 from 'int (__cdecl *)(PyObject *,void *)' to '...' 1> Context does not allow for disambiguation of overloaded function PyArg_ParseTuple(args, "O&O&:...

Visual Studio - Can I export templates via command line?

Is the "Export Template" functionality available from a command line anywhere? I checked the command line arguments for both MSBuild.exe and devenv.exe and didn't see anything obvious. ...

How can I disambiguate this template code?

I'm having trouble figuring out how to solve a compiler error I'm running into. I've reduced it down to this simplest-case representation: enum EAtomId { EAtomId_Test }; int StringFormat(char* o_dest, size_t i_destSizeChars, const char* i_format, ...); template <size_t SIZE> int StringFormat(char (&o_dest)[SIZE], EAtomId i_format, ......

Replacing attribute value in XSLT

I am trying to perform an XSL Transformation. But an attribute replacement doesn't work. I have this XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; <xsl:output encoding="UTF-8" doctype-public="-//WAPFORUM//DTD WML 1.1//EN" doctype-system="http://www.wapforu...

How to determine whether a C++ template has specified method

Let's suppose I am writing a function template GCD which uses both operator/ and operator%. For some types, for example, complex numbers or polynomials both can be computed efficiently (i.e. when dividing polynomials you get remainder "for free"). So some of my class templates have divmod implemented, which returns a pair of quotient and...

type/value mismatch in template C++ class declaration

I am trying to compile the following code on Linux using gcc 4.2: #include <map> #include <list> template<typename T> class A { ... private: std::map<const T, std::list<std::pair<T, long int> >::iterator> lookup_map_; std::list<std::pair<T, long int> > order_list_; }; When I compile this class I receive the following messag...

Failing to use stl containers in templated functions/classes

When I try and compile the following code... #include <vector> template <class T> void DoNothing() { std::vector<T>::iterator it; } int main(int argc, char**argv) { return 0; } g++ says: test.cpp:5: error: expected `;' before ‘it’ And I don't understand why this is a problem. If I replace it with std::vector<int>::it...

Smarty templates uploaded during high trafficked site causes blank page

I work on a very high trafficked website that uses a Smarty templating system. When I upload a fresh copy of a template that is currently being used, the page turns blank (as if there is nothing in the template file itself). I have to shut down lighttpd, upload the template again, and start lighttpd back up. Are there any settings in S...

Django templates: Group items in Threes

Hi here guys. I have an odd problem with Django. I have a set of objects that Im looping through in a template as you would normally. However, I need to group the items in threes. The layout of the page goes like this: Painting 1 - Painting 2 - Painting 3 D E S C R I P T I O N 1 D E S C R I P T I O N 2 D E S C ...

Should the extensive use of local_assigns.has_key? in partial be considered a code smell?

I have the Rails partial which has a few such checks: <%= if local_assigns.has_key?(:show_blabla) && show_blabla == false %> blabla <% end %> I think that sort of hides the real list of parameters which are used by such partial, and hey local_assigns is not in documentation even. What are your thoughts? ...

default template class argument confuses g++?

Hi all, Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have been compiling without a problem using the Intel (9.0) compiler. Here's a code snippet that shows what happened: template<typename A, typename B> class Foo { }; struct Bar { void method ( Foo<int,int> const& stuff = Foo<int,int>() ); }; The g++ compi...

Using string literals as parameters to template tags in Django templates

One of the things I find myself doing often is passing string literals as parameters to template tags or functions; for instance: {% url my-url 'my_param' %} Unfortunately, the django template engine doesn't let you do this. So I find myself doing this a lot in my view code: my_context_dict['MY_PARAM'] = 'my_param' and then in my ...

C++ Custom Enum Struct for INI file reader

I'm trying to create an Enum that has a string label and a value and I plan to use this to read stuff from an ini file. For example in the ini file I might have some double, int or string type values preceded by the tag/name of the value: SomeFloat = 0.5 SomeInteger = 5 FileName = ../Data/xor.csv When I read the tag from a file it co...

How to validate that some template does *not* compile for given argument types?

I'm writing a smart ptr template which is intended to be instantiated only for a given base class and its subclasses, which provides boost::shared_ptr-like implicit conversions to variants MyPtr<U> of the template MyPtr<T> has long as the conversion is valid from T* to U* (valid base class and const-compatible). This was working fine in...

getopts Values class and Template.Substitute don't (immediately) work together

I have python code something like: from string import Template import optparse def main(): usage = "usage: %prog options outputname" p = optparse.OptionParser(usage) p.add_option('--optiona', '-a', default="") p.add_option('--optionb', '-b', default="") options, arguments = p.parse_args() t = Template('Option a is ${optiona...