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

learn more… | top users | synonyms

2
votes
0answers
12 views

C++ custom memory allocator

I'm working on a C++ custom memory allocator, that would be kind of a replacement for the C flexible array syntax, you know, the stuff like that: ...
3
votes
1answer
36 views

Templated renderer class

A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash. ...
0
votes
1answer
31 views

Simple Batch Templating Utility in Python

I would like to present for review my (much) revised batch templating utility which had it's humble beginnings here in a previous post. As I mentioned there, this program is my entry into python ...
3
votes
2answers
90 views

Email Template Parser PHP Class

This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into ...
3
votes
1answer
54 views

Fully Generic C++ Stack Implementation Without Lists, Arrays, or Vectors

I'm trying to write a fully generic Stack in C++. I'm not sure if this is the best way to do this. Right now I know that the Pop method needs improvement since ...
8
votes
2answers
89 views

Type-safe cartesian co-ordinates

I've recently been fiddling around with a type safe implementation of cartesian co-ordinates (and a few operations on those co-ordinates). Often it's easy to get units mixed up: is something in ...
5
votes
3answers
188 views

“Set” your expectations low for this ADT

For my third assignment in CS2, I was given the following: A set is a special bag that does not allow duplicates. Specify each operation for a set of objects by stating its purpose, by ...
0
votes
1answer
22 views

Prefered Style Container for the Components in the DataTemplate

The following XAML is a close (tidied up) version of what I have use in my WPF application. If you have noticed there are two Styles applied to the same component ...
14
votes
4answers
1k views

Smart as a bag of rocks

For my second project in CS2, I was given the following assignment: Implement a new ADT called a bag with receipts. The specification for the class of bag with receipts differs from a ...
8
votes
1answer
577 views

Create New C++ Class

I'm currently developing a new version of ExpressGenGen Using TDD. While I'm rewriting the new version of my Code Generator Generator. I'm using its old version to generate code to be used by the new ...
3
votes
0answers
52 views

Generating all permutations of a template pack

AllPermutedPacks<Pack<Types...>>::type is to be the pack of packs consisting of all permutations of Types.... For ...
0
votes
0answers
33 views

Loading template file and replacing placeholders

I have an HTLP template file called "template.tmpl". In the template I have a few placeholders like {{NAME}} and {{USERNAME}}. I ...
3
votes
1answer
79 views

Generating a zoo of animals

The pattern I've come up here is for the AnimalGenerator itself, outside of the (abstract) Factory Pattern used within it. The factory classes themselves are not ...
7
votes
2answers
503 views

Calculator using class templates

I've just completed an assignment about class templates in C++. It works fine and produces the correct output. We were given the main function and had to construct and implement the class. I'm ...
3
votes
1answer
63 views

Seeking proper system for pairing types

My code below ensures that only land animals can be a "representatives" for Land while only ocean animals can be representatives for ...
3
votes
0answers
52 views

Text-based Snake game on Window - follow-up

Previous question: Text-based Snake game on Window Summary of improvements: Removed unnecessary functions such as clearScreen() Added new ...
2
votes
0answers
55 views

C++ Maths Library [closed]

I want to create a template library where only header files are provided, very much like Boost. The library will be a mathematics library where calculations such as hypothesis testing can be done. I ...
5
votes
2answers
249 views

Stack implementation using vectors and templates with no overflow version 1.1

I have modified my code as per the suggestion given by some of the developers. Let me know if there are any further concerns or scope for improvements. Original Version ...
6
votes
1answer
100 views

Factory template method for generalized functors

(A quick note on terminology: I use 'generalized functor' to refer to a functor that can be initialized from any callable entity, similar to the definition from Alexandrescu's Modern C++ Design. I use ...
2
votes
0answers
50 views

Counting words in files - follow-up 2

Previous question: Counting words in files - follow-up I have fixed punctuation problems in my previous code by using template, because it is easy to understand and my focus on template mechanism. ...
4
votes
1answer
177 views

Simple mathematical operations (add, sub, mul, div) in C++11 template

I made a simple script to implement basic mathematics operations by using variadic functions. I would like to know if my implementation is correct. The code only works for Visual C++ compiler Nov ...
5
votes
1answer
72 views

Simplifying a class template

I wrote this code over night for a little project that my friend and I have been working on. This class template was created over a year ago during as a class assignment for C++ programming. I ...
16
votes
2answers
320 views

A header-only linear-time C++11 PEG parser generator supporting left-recursion and grammar ambiguity

I've rewritten my original parser generator to a header-only library which uses templates and functionals for better type safety and clarity. The generated parser creates an abstract syntax tree which ...
3
votes
1answer
102 views

Ensure only a single instance of static template class member

I am interacting with a C library, whose documentation states that certain functions are not thread safe. Since its functions deal heterogeneously with multiple types, I have written a template ...
12
votes
2answers
219 views

Object storing and retrieving using wildcard identifier

I'm writing an interpreter for a scripting language which allows objects to: Have an alias Be referenced using a wildcard Contain child objects Combination of all three above For example: ...
5
votes
2answers
178 views

Thread-safe Phoenix Singleton class template with Boost

I've implemented the phoenix-singleton as a class template with boost inspired by Modern C++ Design. The code compiles fine with MSVC 2013 - and it seems to work, but I'm new to multi-threaded ...
8
votes
1answer
87 views

consecutive_find function for returning a consecutive range of elements

consecutive_find() is a function that returns the beginning of a range that contains strictly N consecutive elements. It was part of a SO question that I answered. ...
2
votes
1answer
62 views

Static to Instance method trampolining with templates

I finally have a working trampoline mechanism. Would anyone care to critique it? Ideone ...
4
votes
1answer
298 views

Handling views and templates

My guts tells me that this isn't the proper way to handle views / templates, so that's why I'm asking you what could be done better. Some background: This application I'm building now is for use in a ...
4
votes
0answers
110 views

Wrap function pointers in template classes

I'm working on a C++ library for Arduino and other embedded systems. I'm currently working on wrapping up function pointers and member-function pointers into two C++ template classes (function and ...
1
vote
2answers
130 views

Binary search tree with templates

I am currently attempting to become proficient in C++ and started by implementing a basic binary search tree. Most of the programming I have done is in Ada, Python and C. I would like to be able to ...
3
votes
1answer
166 views

Recode C -> C++ trampoline function macros using templates [closed]

I'm reworking PyCXX (C++ wrapper for Python). I'm currently examining the following macro code, and wondering whether there is a way to write it using templates rather than macros. If so, the ...
6
votes
2answers
94 views

Using a CRTP approach for loading OpenGL programs

I wanted to try using CRTP (also new for me) to try making the loading of shared resources implicit. (Specifically I'm using it for loading OpenGl shader programs) This will also help separate some ...
5
votes
1answer
174 views

Dereference template class

Usually, C++ standard library algorithms have two versions, e.g.: ...
4
votes
2answers
68 views

First WordPress template

I wrote my first template, but didn't include any styling. What do you think? What's good what's bad? ...
10
votes
1answer
103 views

Wrapping types with alignment requirements

Visual Studio 2013 still doesn't support the alignas keyword in C++11. This causes some problems with alignment of types in various situations. Thankfully the ...
2
votes
1answer
38 views

Making empty cells in Underscore template

From the back-end, I am receiving 8 data. The client requires showing that the row per data is 7, so I have 1 data in balance. I have created empty data and made the empty cells, which works fine. But ...
1
vote
0answers
94 views

Writing a universal “call” function: call(f, args…) where “f” might be a member function/data pointer

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
6
votes
1answer
139 views

Image Processing Pipeline

I'm currently toying around with some Computer Vision algorithms and always wanted to learn more about templates, so I came up with the idea to build a templated Image Processing Pipeline. I want the ...
10
votes
2answers
368 views

Templated doubly-linked-list

I've been wanting to revise what I knew on templated classes so thought I'd write a doubly linked list to practice. It works fine, so all is well and good on that front, but is there something I've ...
2
votes
1answer
257 views

Variadic template data pack strucuture designed for debug/trace log (variable-sized records)

I am currently writing this pack template to pack all the values (raw / fundamental + arrays of such, especially c-strings and ...
2
votes
1answer
72 views

C++ messaging using templates

I wanted to allow components of my program to communicate without the components knowing about each other, thus keeping coupling low. So I devised some template classes that implement the observer ...
7
votes
2answers
338 views

Sorted vector (aka flat_set) for objects (pointers) with custom embedded key (functor used)

BEFORE YOU READ: this link should be included when you just don't like the format of the question and for those that read this question for the first time, the link may give you the idea what happened ...
7
votes
1answer
99 views

A tiny switcher for arbitrary types in C++11

I was about to use the awful enum+map trick to switch on std::strings when I thought to see if I could let some variadic templates do the job for me and I started ...
10
votes
1answer
264 views

Template integer range

This is a follow-up of an old question by @LokiAstari, modified for the current community challenge. The idea is to provide a compile-time integer range. I applied all the modifications that I ...
3
votes
3answers
237 views

Simple shared pointer

I wrote a simple shared pointer, which I think works pretty well. I would like to see your review of it. This is the header file: ...
3
votes
1answer
211 views

Wrapping std::bind call in a function returning std::function

Is this code correct? It appears to work in g++ 4.8.3 and clang (bcc64), however appearing to work is no guarantee of correctness :) The aim is to be able to replace a call to a member function: ...
12
votes
5answers
688 views

Stopwatch template

It's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated ...
2
votes
1answer
109 views

After refactoring using template class, PHP file takes forever to load, timeout after 30 seconds at times

I've been learning how to code for the past 3 years about. I have made some really good progress I think, and right now I'm trying myself on creating an MVC framework. I found this awesome idea on ...
6
votes
2answers
4k views

Binary Search Tree implementation using templates

I wrote this implementation using templates. It works fine and as expected. Just want to know if this can be improved. I have some specific questions too at the end. Please feel free to critique to ...