templates

template function specialization default argument

template <typename T> void function(T arg1, T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) { } template <> void function<int>(int arg1, int min,int max) { } int main(int argc,char* argv[]) { function<int>(1); } it give syntax error C2689 and C2059 on function default argument line on :: tok...

How to interpret 14.2/2 from the C++ Standard?

The C++ Standard in 14.2/2 says: For a template-name to be explicitly qualified by the template arguments, the name must be known to refer to a template. Can any one Tell this one to prove in terms of programming? ...

Best place to get website templates?

I am planning for creating some good websites and looking for sites which provide great templates. Can any of you recommend any sites from personal experience? I know a google search will give me a million sites for "website templates" ... but i want personal experience. ...

Is there a XSLT-like JavaScript templating system?

I have a big chunk of deeply-nested semi-structured JSON and would like to generate HTML from it. At the moment I'm using jQote2, but much of the code inside my templates deals with dynamically finding the next template to render and then calling it. What's a single <xsl:apply-tenplates> in XSLT takes several lines with JavaScript and jQ...

Can't access controls in LayoutTemplate in LoginControl

Hi, I have to access controls in LayoutTemplate in LoginControl. So in PageLoad() I do something like this: foreach(Control control in loginControl.Controls){ (control As Label).Text =... blah nlah ; //do something with control, } In LayoutTemplate I have some labels, etc, but I can "see" them after PostBack and I don't have a...

Text email template in using Zend_View losing line breaks

I'm using Zend_View to template text email content. However, I've come across one problem which I have been unable to solve: If a line ends with a php block (?>), then the line break is lost. Does anyone have any idea how I can solve this? The application is using Zend framework, but I have no particular reason to use Zend_View to rend...

unable to pass Template function as a callback parameter

Please refer the code below: typedef void (*TimerCallback)(int RequestID_in, void* AdditionalParameter_in); class MyTimer { public: MyTimer(){} bool schedule( int Interval_in, TimerCallback TimerCallback_in, void* AdditionalParameter_in) { //some logic return true; } }; names...

Define a specific case for a templated function (C++)

So in my .h file I have template <class T> void getValue(T *val, int element, int index); and then in my .cc file I have a function: template <class T> void RParser::getValue(T *val, int element, int index) { I also have it explicitly instantiated: template void RParser::getValue<char>(char *val, int element, std::string subr...

errors porting C++ templates from GCC to Visual C++

The following compiles in GCC: cvec.hpp: template <class T> class cvec : public deque<T> { class deque<T>::iterator Find(T); }; cvec.cpp: template <class T> class deque<T>::iterator cvec<T>::Find(T element) { } In Visual C++, get error C2242 "typedef name cannot follow class/struct/union. I changed "class" in the header f...

C# templated / generic method at compile time error

I am working in c# with .net 2.0 (i know its old) Here is my setup: struct propertyType { System.type type; } public class DataProperties { private Dictionary<propertyType, object> properties; public void setProperty(propertyType key, object value) { if(value.getType == key.type) //make sur...

C++: Inheritance v. Containment for a templatized class

I have the following struct: template <typename T> struct Odp { T m_t; }; I want to specialize it so I can add an operator so the type plays nicely with STL sets. (I can't modify Odp directly; it's legacy code.) Here are two methods I see of doing it: struct Ftw : public Odp<int> { bool operator==(const Ftw& rhs) { ...

Is it possible to match templated base in template specializations?

I could of course use is_base if the base class where not a template. However, when it is, I just don't see any way to generically match any derived type. Here's a basic example of what I mean: #include <boost/mpl/bool.hpp> template < typename T > struct test_base { }; template < typename T > struct check : boost::mpl::false_ {}; t...

Initializing static pointer in templated class.

This is difficult for me to formulate in a Google query (at least one that gives me what I'm looking for) so I've had some trouble finding an answer. I'm sure I'm not the first to ask though. Consider a class like so: template < class T > class MyClass { private: static T staticObject; static T * staticPointerObject; }; ... te...

Current state of javascripte template engines?

I did some research months ago looking for a nice javascript template engine and settled on one made by Trimpath. I like this a lot, but I have a few wish list items: The code is rather big. I'd love something tiny, like John Resig's template engine, but easier to use. I'd like support for includes, and django-style inheritance. Are...

How to define a return type of general member function pointer?

I was found general member function pointer call method. buf that example is only void type. I want to make general return type of method function call. class Callback { public: void operator()() { call(); }; virtual void call() = 0; }; class BasicCallback : public Callback { // pointer to member function void (*func...

Loading external script with jinja2 template directive

I'm very new to jinja2 and the use of templates in general so I was wondering if there's an easy way to load an external javascript. I was thinking of using: {% block javascript %} <SCRIPT SRC="myscript.js"></SCRIPT> {% endblock %} But I can't help to ask: Is there a way of loading this script directly from within a template dire...

C++ Templated Functor (based on Modern C++ Design) compile error

Based on chapter 5 (Generalized Functors) from the book "Modern C++ Design," I'm trying to write a Functor template. Before asking me "why don't I just use Boost's bind or Loki straight up?" the simple answer is "because I want to learn." That being said, I have followed the book, and also used the example code as a reference, but I ke...

A trick to find unused PHP files (Drupal template files)

I am looking for a trick to find included files that are not in use. Preferrably not by going trough them by hand. This project has over 400 of such files, 100 are probably unused by now. They are Drupal template files (tpl.php) and were placed in the theme/template during development and -as always- were never removed when obsoleted. ...

Can I create a predicate that will accept both functions and functors as a parameter?

I'm working on a problem in C++ that involves lots of subset and transformation operations on a large quantity of data. To that end, I've created a map function and something like list comprehensions. I've found that a bunch of the predicates I'm writing also have inverses, so I'd need to write: template <typename type_t> bool HasTenFoo...

template method specialisation problem

Can anyone help me with this code. I'm trying to specialise a method. At the moment it doesn't work with one specialisation (1) but I'd like to ultimately have lots of specialisations (2, 3, 4, 5 etc) class X { public: // declaration template< int FLD > void set_native( char *ptr, unsigned int length ); // specialisati...