a design structure for creating several things that are almost identical but need different values. Not template-meta-programming.

learn more… | top users | synonyms

3
votes
1answer
17 views

Could this template function be improved?

I'm writing wrapper functions for some of the functions in <algorithm>. While the following works perfectly, I'm not sure if this is the best way to approach it: template<class ...
4
votes
1answer
19 views

toggleSaveStream button template

I've got a view which has a corresponding template. The template looks something like like: <div id="streamItems" class="left-list droppable-list"></div> <div ...
3
votes
2answers
48 views

Template data types implementation

I'm preparing for an exam on C++, as part of my preparation I want to implement a generic map without using anything from the STD for educational purposes. Before jumping into implementation of ...
1
vote
1answer
18 views

Is it bad practice to mix in chrome.i18n (internationalization method) into templates?

I'm mixing chrome.i18n into my templates as templateHelpers with Backbone.Marionette. templateHelpers: function () { return { // Mix in chrome to reference internationalize. ...
2
votes
1answer
104 views

How to make string.Format template more readable?

Have a look to the following example. Clearly it's very hard to understand the meaning of each parameter passed to the string.Format to be replaced to the numeric sequence of {0}, {1}, ... I want to ...
5
votes
1answer
39 views

Type safe program uniform manipulation in OpenGL

I've made an attempt at writing class wrappers around basic OpenGL objects to make managing them easier and more intuitive. Writing a generic one for program uniforms proved to require a little bit ...
5
votes
2answers
85 views

What might be another way to test if int is 32 bits wide at compile time?

Below is code that will compile when INT_MAX is equal to 232. It will generate a compiler error when INT_MAX is not equal to 232. #include <iostream> #include <climits> namespace ...
4
votes
2answers
51 views

How clean is this mustache template for a listing page?

This was our old site that I am redesigning. Someone else hardcoded with inline CSS and javascript in tables. I wanted to make it dynamic, so I added Mustache and made this template: {{#labs}} ...
2
votes
0answers
52 views

C++ class “overload” using variadic templates and wrapped function pointers

I'm using C++11 and I have the following problem (pseudo C++): template<typename T, R1 (*F1)(Args1...)> class one_size_fits_them_all {}; template<typename T, typename U, typename V, R1 ...
9
votes
2answers
129 views

Templated Quicksort

Original quicksort.h #include <algorithm> namespace quicksort { template <typename iterator, typename value_type> struct traits { static iterator choose_pivot (iterator first, ...
5
votes
3answers
188 views

Is this a good first use of template classes with my Deck class?

I have previous revisions of my deck of cards project, but I may not need to link them here since the emphasis is on the use of templates. I've never used them before until now, and I like how ...
3
votes
1answer
31 views

IniReader template overrides become ambiguous

I was tasked with refactoring our existing IniReader class, which is Windows only compatible, to be cross-platform ( specifically UNIX compatible ). We decided that boost::property_tree was a good fit ...
7
votes
1answer
132 views

Is this over-engineering and a bad use of templates?

I'm not very good with templates, so any general tips would be appreciated. Basically this class parses a CSV file with a very specific format. My original idea for this was that I wanted this to ...
4
votes
0answers
108 views

Building a good C++11 template library - compile-time checked enum array

The task is to add data or values to members of a given enum class. The compiler should check, if a value for each enum member is available, and not just default construct empty values. It is a tool ...
0
votes
1answer
34 views

Need some help with templatizing a linked-list [closed]

#include <iostream> using namespace std; #ifndef _LIST_H_ #define _LIST_H_ template<class T> class Node { public: Node(); Node(T data); ~Node(); T data; ...
3
votes
1answer
132 views

Event handler using variadic templates

I am currently working on a game and found myself in need of an event handler. I wrote an event handler similar to this one some time ago, but decided to update it using variadic templates (this is ...
2
votes
2answers
130 views

Please review my fast templated call back implementation

Below is the code for my templated callback implementation. Currently it works for a single parameter. One thing I was going to try and do next was increase the argument to the function from 1..N ...
2
votes
1answer
38 views

Attempting to build template but Having Issue with gets and posts

I am building my first real php web app. as many you know this requires building LOTS of pages. in attempting to streamline the repetitive stuff i placed most of my stuff within a content.php page ...
4
votes
0answers
115 views

Rendering HTML through template. Best practices for dynamic CSS?

I'm creating an unordered-list element in Backbone via underscore templating. I've got the following: <ul id="FrontRack" style=" background-image: url({%= ...
4
votes
1answer
105 views

Pointer to a Template structure

I have seen this type of definition for a "node" of a Linked-List-type Data Structure in many codes and have myself used this many times -: template<typename T> struct node { T data; ...
2
votes
1answer
534 views

Data with Handlebars templating function

In my app development, I need to fetch data from backed, and it needs to implement it into an HTML page. For this, I made this work. But I think this is very lengthy. Can anyone give me the better ...
3
votes
1answer
87 views

O(lg n) algorithm for a fibonacci number with c++ template

I wrote a function to find a specific fibonacci number, which runs in O(lg n). Then I modified it with a template. Though it works, I'm new to template and want to know if I used template correctly. ...
3
votes
1answer
68 views

Should I use an object or type as trait?

Edit: Disclaimer: I am new to templates and traits. I apologize in advance if this is a bad question. I am refactoring two similar classes with small differences strewn all over them into one ...
5
votes
1answer
191 views

Generic pipe and filters

I made a template pipe and filters to replace an old pipe and filters implementation that used inheritance and had a very heavy base class. #include <iostream> #include <boost/bind.hpp> ...
1
vote
0answers
90 views

PHP Templateing Engine That uses closures to eliminate iterative includes

This is the second submission for Code Review for this project but since the API changed considerably I felt it should not be taped onto the original post. To see the original post and comment see ...
3
votes
2answers
125 views

Potential Problems with this templating technique

I like the way Zend Framework works it's views and I make extensive use of partials but every partial include results in it's own file system hit. As I'm building my own framework I thought I could do ...
6
votes
1answer
360 views

Simple “nullable” template class. Are there weaknesses in the implementation?

The goal is to have fields in a class which are optional and can be determined if they are set in order to be able to leave them out of serialization. template<typename T> class Nullable { ...
1
vote
0answers
65 views

Design issue with decoder class

I'm designing a C++ Decoder class for decoding a format, and would like some feedback on my design choice: I want the user to be able to provide input to the decoder by either supplying an array, a ...
1
vote
1answer
319 views

std::string/std::wstring template wrapper for Win32 API

I have not completed this but want to make my own template library for wrapping the Win32 API to make it compatible with std::string/std::wstring... Here's a sample of what I've worked with so far. ...
5
votes
4answers
270 views

General advice on a practice linked_list for C++ classes/templates

Introduction I'm learning C++ (Coming from Haskell, C, and Assembly - and other languages sparsely) and this was my practice with classes and templates. It's a linked list that you can call in this ...
4
votes
1answer
682 views

C++ compile-time checked switch 'statement'

In the project I work on there are several places where a switch statement is used on a type enum. (I know, better to use virtual functions or a visitor pattern or something, but sometimes switching ...
-1
votes
1answer
117 views

I'm a C programmer moving to C++. Am I using classes and templates correctly? [closed]

I took a quick look at the C++ documentation on templates and classes. I'm not entirely sure if I'm using the features(read: syntax) properly, but I get the concepts. I have to admit that scope is a ...
3
votes
0answers
86 views

JavaScript templating language: ivy-markup

I'm quite new to GitHub. Like others, I usually download libraries from it but recently decided to host a small library on it. It would be great to get comments on its usability and code structure. ...
4
votes
1answer
227 views

Cleaner way to determine and load page template

I feel that my current business view logic is not efficient or very clean. The problem is building the right output, but with less code and more DRY. I have 3 'static' links, as in, direct tags: ...
2
votes
2answers
116 views

C++ plain type serializer design

I am designing a class to store primitive types into byte buffer using predefined byte order. I am not going to use Boost.Serialization because I am working with plain types only and I need predefined ...
3
votes
1answer
569 views

Working with forms in Meteor, using selectors for every input

I'm trying to work with forms, and just getting a grasp on JavaScript. Basically I'm unsure if there is a more reusable way to handle forms with Meteor/jQuery. // Creating a new prayer, including the ...
4
votes
2answers
195 views

PHP Template Engine

I have been working on a php driven template engine. This is fairly light weight, and fast from all of my testing, but I was hoping to get some feed back on it. First I would like to show you an ...
1
vote
2answers
115 views

Review request: unw_graph class (unweighted graph)

Here is my new stl-like implementation of an unweighted graph. Could you please tell me what member functions should I include to my library? Thanks in advance. file: unweighted_graph.hpp #include ...
2
votes
0answers
119 views

Template parameter used for configuration of classes [on hold]

I am not sure if this good programming. I am not the well template programmer. I have a big simulation framework (rigid body simulation). And so far I have one special include file "TypeDefs.hpp" ...
2
votes
2answers
483 views

A PHP MVC working with Mustache (and now nested templates!)

I'd love some feedback about this code that I'm editing and shortening now. Here's the class: <?php namespace bbn\cls; class mvc { use \bbn\traits\info; // From \bbn\traits\info. ...
3
votes
0answers
3k views

Localizing templates using require.js, backbone and underscore

This question is about templating and localizing, using require.js and underscore templates through backbone.js. The application will need to be localised on the fly. Before embarking down a path ...
2
votes
1answer
325 views

Polymorphic STL foreach without passing the container type

I was trying to figure out how to make a foreach macro for STL containers that is break-able and I came up with this method that uses templates to recognize the container type automatically. Any ...
2
votes
3answers
273 views

Need advice with a simple container class with templates C++ (code layout and readability)

First of all, thanks for looking at this code. I'm a novice coder trying to learn C++ on my own so any help is much appreciated. I've been working on a simple program to output values to the console ...
1
vote
2answers
360 views

C++ templated singleton class - properly destroyed?

I have written a templated singleton class in C++ but I am afraid that it is not properly destroyed. Can you advise me on that ? my singleton.h #ifndef SINGLETON_H #define SINGLETON_H template ...
2
votes
1answer
697 views

Template system with master layout

Here is my template code <?php namespace classes; /** * Description of Template * * @author Aamir */ class Template { private $templateVars, $templateFile ; ...
1
vote
2answers
101 views

Using Choose and Apply Templates with Mode, vs Complexless Template Matches

So I have a little XML (Sub)language, it has 3 elements of interest: para, point, and code If a code occurs inside a para, point element I want to handle it for inline use, if not, i want to set it ...
2
votes
1answer
212 views

How can I improve the design of this serialization mechanism?

I'm working on caching library which is intended to work with all types of values. Values are represented as instances of value_type: value_type holds a std::vector<char> for the raw data, and ...
3
votes
0answers
163 views

Variadic function with restricted types

I am designing a class which (among other things) acts as a vertex in an undirected graph. #include <iterator> #include <string> class Node { public: explicit Node(const ...
2
votes
0answers
803 views

Review request : Jinja CMS for Energiekantoor.nl on Google App Engine

Energiekantoor.nl is a non-commercial community for purchasing power and natural gas, Reason: we (civilians in my neighbourhood) want to lower the energy bill of our homes. To maintain the site ...
1
vote
0answers
142 views

How would you improve this scala basic xml template?

Currently exploring the play framework, I'm about to replace the proposed templating system, using the powerful xml processing of the scala library. HEre is what I have come with : import scala.xml._ ...