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

learn more… | top users | synonyms

8
votes
1answer
128 views

Is my C++11 generic container a good design?

After refactors and refactors and the discovery of very common patterns on many of the classes of the software I wrote, I decided that it would be fine to have something like an arbitrary-keyed map, ...
8
votes
2answers
430 views

Compile time decorator pattern in C++ with templates

I'm doing some high energy physics modelling in C++. I have written code that implements class that score interactions of particles with detector material. Here is a base class: ...
0
votes
0answers
12 views

How to use the strategy pattern with STL containers? [migrated]

Assume that I have a strategy interface named BinaryClassifier that can take a Sample and return a ...
6
votes
1answer
54 views

Dynamically call lambda based on stream input: Try 3

Based on Dynamically call lambda based on stream input: Try 2 This fixes most of the points pointed out by @Morwenn. It has been generalized so anybody can call it. The only extra part needed by the ...
7
votes
1answer
76 views

C++ template Range

From a previous question I got an answer that included some template magic (that to be blunt was mind boggling (as I could not understand it)). So I have been trying to achieve the same results ...
4
votes
1answer
43 views

Template with boost::operators extremely verbose and repeating

I got the following ugly code: ...
16
votes
2answers
299 views

Dynamically call lambda based on stream input

Some context: I have code that looks like this (minor issue noted here): ...
0
votes
0answers
8 views

Performance consideration and code reduction for Templates [migrated]

I'm trying to decide if this might be a good idea to help reduce the size of some of my xaml resource dictionaries on a large project. Except I'm concerned about any potential performance issues going ...
7
votes
0answers
66 views

How to structure a master page?

I have a small coldfusion section of our site that all uses similar js and css files and page structure. The code is currently repeated for each file, and I'd like to factor it out and set something ...
11
votes
3answers
123 views

Expression template to compute the Euclidean distance

I was writing some geometry-related code again and had a closer look at my function supposed to compute the Euclidean distance between two points (N-dimensional points by the way, hence the ...
11
votes
2answers
129 views

Very basic tuple implementation

I've been messing with metaprogramming and variadic templates in C++, and I came up with this very primitive implementation of a tuple: ...
0
votes
0answers
44 views

PHP Web Components

I read about W3C Web Components spec and JavaScript's libraries like polymer.js and others, so I tried to find something similar in PHP, but with no luck. So I wrote a tiny class to work with custom ...
10
votes
2answers
158 views

Template vector struct in C11

This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a ...
6
votes
1answer
126 views

Variadic templates and pointers to member functions to achieve a named-parameters interface in C++

I studied a bit and packed all the suggestions that I received here: Fluent interface and polymorphism and I came up with this: ...
3
votes
1answer
30 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 ...
4
votes
1answer
22 views

toggleSaveStream button template

I've got a view which has a corresponding template. The template looks something like like: ...
4
votes
2answers
80 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
24 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. ...
2
votes
1answer
134 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
42 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
89 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 ...
4
votes
2answers
57 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: ...
10
votes
2answers
179 views

Templated Quicksort

Original quicksort.h ...
6
votes
3answers
249 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
38 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 ...
7
votes
1answer
136 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 ...
0
votes
1answer
48 views
3
votes
1answer
136 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
147 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 ...
12
votes
1answer
183 views

Rendering HTML through template using dynamic CSS?

I'm creating an unordered-list element in Backbone via underscore templating. I've got the following: ...
4
votes
1answer
117 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 -: ...
2
votes
0answers
668 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. I've written the below code for this, but I think it's very lengthy. Can anyone give me ...
3
votes
1answer
89 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 ...
3
votes
1answer
72 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
234 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. ...
1
vote
0answers
98 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
137 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
495 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. ...
1
vote
0answers
75 views

Design issue with decoder class [closed]

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
362 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. ...
6
votes
4answers
294 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
838 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
119 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
1answer
109 views

JavaScript templating language: ivy-markup

This library is a markup parser which is intended to be used in node.js and browser environment. I've decided to use Jasmine for tests. The library's name is ivy-markup. URL: ...
4
votes
1answer
230 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
119 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 ...
4
votes
1answer
710 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. ...
4
votes
2answers
202 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
132 views

unw_graph class (unweighted graph)

Here is my new STL-like implementation of an unweighted graph. Could you please tell me what member functions I should include in my library? unweighted_graph.hpp ...