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

learn more… | top users | synonyms

1
vote
1answer
37 views

Generic implementation of SiftUp/Down operations on binary heap

Binary heap construction and maintenance boil down to the two basic operations: sift up and sift down. Following are generic template implementations of the two operations. Any comments are welcome. ...
3
votes
3answers
62 views

Bit manipulation tool set

I made a tool set to facilitate bit manipulation as follows. Any comments are welcome, be it about the interface design, the implementation, or even the naming. Also, I want to make sure that the tool ...
1
vote
1answer
32 views

Set openCV basic structures to zero in a unique way

For test cases I need a unique way to set any structure to zero. For openCV I wrote this: ...
3
votes
1answer
88 views

Minimalist Tree

While working on a small project, I tried to implement a super simple tree class in C++. It supports an arbitrary number of branches from each node. In addition to general comments, my main concerns ...
3
votes
1answer
37 views

C++ Template for one to many Registration (pre Gang of Four)

I use this template to lookup clients registered for data. The data is associated by name(key) and clients are shared pointers (value) to a class which will consume the data. ...
0
votes
1answer
47 views

HTML template for win-loss data in Javascript with Mustache

Can anyone suggest a better way to implement my template code? ...
3
votes
0answers
62 views

Console Command module (in-game console or base for script engine)

I've created a console/terminal command handling module that allows the programmer to bind functions to a command name and later execute them from std::string. What's new is that it handles most stuff ...
2
votes
2answers
100 views

Template Binary Search Tree

This is a simple binary search tree implementation written with C++'s templates feature I wrote to learn C++. What improvements would make this cleaner and better as far as C++ practices go, and are ...
4
votes
1answer
76 views

CakePHP change 'miniMap' action and respect template

I have some questions on how I can improve this "action" (method) in "controller": My template has a navbar with dynamic content (if the user is logged in a special button appears, his name appears ...
5
votes
2answers
83 views

Attempt at templates by creating a class for N-dimensional mathematical vectors

Originally I had tried to implement this topic after having learned about Inheritence and posted it on here, but that forced complexity and the main suggestion was that this was ideal for templates. ...
6
votes
1answer
71 views

Text substitution templating function

In a recent interview I was asked to solve the below problem. Problem: Given a string with variables in them, e.g. ...
12
votes
1answer
131 views

Simple Python 3 templating module

The module adds syntactic sugar to Python 3 to allow concise specification of templates. I use it to generate a collection of static web pages from various data sources. I wanted something ...
1
vote
0answers
18 views

Better way to template in simple coffee script

I am looking to see if there is a better way to refactor the creatMessage such that the logic of identifying message elements is outside the actual message ...
3
votes
1answer
113 views

N-ary heap implementation

NaryHeap as a generalization of binary heap. Each node has up to N children. A template specialization for N = 2 (BinaryHeap) ...
5
votes
1answer
135 views

Type erasure and deferred function calls for any function

1. Description 1.1. Functionality The objective of these types is to provide type erasure for any function while maintaining the ability to provide a return value through a combination of ...
14
votes
1answer
182 views

Template UserForm Input - launch, input, validation, error handling

I'm building a template [Process-Tracker] spreadsheet. The idea is that, for any process where we can define what steps should occur in what order (and preferably, how far apart), there will be a ...
0
votes
1answer
59 views

Designing a generic C++1z class [closed]

I'm designing a generic interface for a MessageEntry class for a .h file. I'm looking for guidance on form and terminology (would I call this an interface/template/generic class?): ...
3
votes
0answers
129 views

C++ Finite State Machine - follow-up

This question is a follow-up from Object Oriented Finite State Machine. I vastly improved commenting and followed the suggestions from the answer. Additionally, I improved my tests and did some more ...
2
votes
1answer
107 views

Object Oriented Finite State Machine

I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments. I clearly have little understanding of C++ templates because most ...
1
vote
0answers
65 views

Specialized template methods with complex numbers class

Suppose I have a class of complex numbers called Complex and I wish to implement a class of generic matrices with transpose operation. ...
2
votes
2answers
136 views

C++ Optional Implementation

I haven't done much programming in C++, so I figured I'd try making an Optional class. I'm mainly concerned that I didn't follow good conventions or that I didn't ...
7
votes
2answers
187 views

SQL code reuse with C#

I have some code that allows for SQL reuse for C#. I'm pretty happy with it, but the fact that I can't find anything similar on the web makes me think I'm going about it the wrong way. I have a GitHub ...
2
votes
0answers
48 views

Extremely redundant HTML templating

This is horrendous. I'm using lodash's templating engine for this table. Here's the template for an individual record's row. I've got 5 different table and ...
10
votes
3answers
1k views

C++ Stack using template

I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong. Stack.h ...
10
votes
3answers
494 views

Fastest possible text template for repeated use?

While reviewing Sending templatized e-mail to a million contacts, I wrote this implementation to illustrate an alternate approach. It is designed to be the fastest possible way to generate templated ...
4
votes
1answer
52 views

Making my underscore template code more manageable

I currently have what seems to be a very overly complicated underscore template full of conditionals and as the data grows I'm worried the conditions are going to get more and more extreme. Can anyone ...
3
votes
4answers
113 views

Sending templatized e-mail to a million contacts

This code runs fine without a bug, I need to optimize this code for following interview requirement. Lets say i need to send it to 1 million contacts and emailBody is ~100Kb. What code optimization ...
8
votes
3answers
400 views

n number of x on the y

Everyone knows "99 bottles of beer on the wall". Mat's Mug made a comment about mugs on the wall in The 2nd Monitor and I realized I never wrote a "beer on the wall" program. But that seemed way too ...
0
votes
1answer
47 views

Method of uniquely identifying classes

I have written the following class to allow me to uniquely identify classes in C++, and I was wondering if there are any better ways of going about it. ...
8
votes
2answers
98 views

Template integer range, version 2

This question is a follow-up. The original question was itself a follow-up to an older question by @LokiAstari. The idea is to provide a compile-time integer range. This version incorporates ...
2
votes
2answers
105 views

DataStream interface for reading and writing data

I am writing a C++ library which will interact on files, memory buffers and remote files accessible with the HTTP protocol. To handle that, I've decided to create some classes that will use the ...
3
votes
1answer
80 views

A trait class to detect whether a template is specialized for a given type

Today's question will just be about a small utility that I needed at some point for one of my projects: a template to detect whether a template is specialized for a given type. The utility uses ...
3
votes
1answer
115 views

Draw an ASCII checkerboard

I'm a newcomer to C++, from C#. I wrote a program that prints an ASCII checkerboard with a side length of the number passed to it (link to original Code Golf question). stdafx.h ...
5
votes
2answers
310 views

C++ 2D shape intersections - template reduction

I've created a short piece of code to determine whether or not various 2D shapes (circles/lines/rectangles) intersect. It was a job interview question, but now it's just about self-improvement. I'd ...
4
votes
1answer
162 views

Template Method Checker

I have written some template helpers to check if a class has a certain method with a certain signature. The code is based on this answer. I attempted to extend it for generic methods. An important ...
0
votes
1answer
41 views

User and Score models

I have a couple of models - User & Score. I am displaying data from those models to my template. Data from ...
3
votes
0answers
71 views

Representing trajectory points using inheritance

Problem Background I need to represent trajectory points and trajectories (encapsulating these points) in the form of a collection of classes. All trajectory points have two essential elements: time ...
3
votes
0answers
40 views

Assigning functions for different location classes

Suppose in a School, you can only study, teach, or walk; in a Mall, you can only purchase, walk, or sell; ...
7
votes
2answers
93 views

for_each_cons and for_each_slice, variants of std::for_each working on sliding windows

My goal was to replicate Ruby's each_cons and each_slice: ...
5
votes
1answer
119 views

Thread-Safe Variadic Printing Function

Printing to stdout is thread-safe in many systems when using printf or std::cout, but not in ...
5
votes
1answer
117 views

Linear algebra module

I'm working on a linear algebra module to improve my knowledge with mathematics and, because I'll need a lightweight linear algebra module for my future work with Vulkan! I tried to keep a blas-like ...
1
vote
1answer
64 views

Element selectors for a RepeatButtonView

I have a large application with a wide-reaching amount of views and sub-views. I have a need to decorate DOM elements with identifiers so that my framework of choice can bind views to the DOM ...
2
votes
1answer
92 views

Populate a .txt document with a CSV spreadsheet using multiple templates, outputting documents for each data row

I'm looking for feedback on functionality, PEP8, advice, etc as a learning tool. I'm not sure how to tell if this program should be broken into separate functions or combined as one. While hand ...
1
vote
1answer
92 views

Accessing nested data properties in Handlebars

I am using HandlebarsJS for my templating needs. I have a nested object: ...
2
votes
1answer
113 views

Game engine ObjectFactory class

I've developed as part of a game engine a template class for a factory which manages objects of one specific type. The factory handles initialization, destruction, and accessing previously created ...
4
votes
1answer
258 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
81 views

Templated renderer class

A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash. ...
1
vote
1answer
62 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
394 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
419 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 ...