Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [template]

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

Filter by
Sorted by
Tagged with
4
votes
3answers
159 views

Using a template to cycle through a sequence of containers

I'm trying to implement a template that takes a container as parameter. The template has a getnext method that cycles through the elements in the parameter. Take ...
4
votes
2answers
124 views

C++ Pixel/Array manipulation libs

I was tired to always perform pixel manipulation one by one, so I started to create my own templated header to perform computation over pixel (RGB, or RGBA), but I also make it for ND for some cases. ...
4
votes
1answer
110 views

A basic multi-dimensional array

I have been lurking on the C++ side of stack-overflow only long enough to know there are a lot of beginners and intermediate programmers baffled by multi-dimensional arrays. I've seen a lot of ...
4
votes
2answers
119 views

Templated string formatting

This function formats a string by replacing every occurrence of '{n}' with the corresponding argument that was passed to the function where n is an index that ...
4
votes
1answer
7k views

C++ template Partial Specialization Member Function; Am I doing right?

I'm trying to improve my C++ template metaprogramming skills. From my understanding, I can't partially specialize a function(either member function or not). So, I need to define another class that can ...
4
votes
2answers
2k views

Platform independant thread pool v3

This is a continuation of this question, v4 can be found here Taking the advise given previously, the deadlock was fixed in the non-yielding code. The next problem comes from the suggestion to make ...
4
votes
3answers
1k 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 ...
4
votes
1answer
126 views

Templated byte streaming

I often have the need to take some type and stream it to something as a sequence of character byte values, so I came up with this to accomplish the task: ...
4
votes
3answers
1k views

C++ instance counter

I have created template class to easily get the current number of instances a class has. It's threadsafe and I tried to make it as hard as possible to abuse. ...
4
votes
2answers
334 views

Separate Declaration and Definition of private Node implementation in template Linked List

I was practicing implementing a template Linked List with a private node implementation. I know one of the methods to define template class member functions is to keep the declaration and definition ...
4
votes
1answer
2k 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 ...
4
votes
2answers
184 views

basic jQuery plugin template

I would like to know if I'm writing a plugin for jquery correctly. I followed the official guide and also added some tweaks that I've found from various sources over time. While this works perfectly, ...
4
votes
1answer
1k views

HashTable implementation using bucket lists

I wrote an implementation of a HashTable that uses bucket lists to store the key-value pairs implemented with a linked list. Here's the header: ...
4
votes
2answers
135 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: ...
4
votes
1answer
2k views

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 ...
4
votes
1answer
743 views

More generic sorting algorithm: using namespaces

I am currently reading The C++ Programming Language (Special Edition) and am learning about using templates. One of the exercises asks you to program a generic version of quicksort. I am hoping to ...
4
votes
1answer
113 views

Email Generator

I've made a email generator, that uses a HTML template and replaces keywords in the template with information taken from a database. I'm looking to see if there is a way to improve the coding. ...
4
votes
1answer
68 views

A Versatile Algebraic Variable Class Template with full operator support

I've been working on this concept for the past few days where a variable_t is of any type T; assuming that it is at least ...
4
votes
1answer
44 views

C++ wrapper around uniform mt19937 SequenceContainer [closed]

With the following interface in mind EasyRandom<unsigned int> prng(a, b); auto x = prng(); // scalar auto v = prng(10); // vector I wrote the following ...
4
votes
1answer
236 views

Variadic Datablocks

I would like to have my variadic template class reviewed. First some explanation what it should do: I'm writing an application where I read in blocks of data. I know before i read in the data which ...
4
votes
1answer
170 views

Math Vector Header Library Templated on Data Type and Size

I have created a vector math header library where the size and data type stored are template values, and I'd like it peer-reviewed please. I have a few main questions: Will using my SizedVectorBase ...
4
votes
1answer
736 views

Generic message system using variadic templates

in my spare time I´m creating a hobby game engine as decided to write some of my systems on my own. As the time passes I´ve decided to start publishing it as a independent libraries for use (so ...
4
votes
1answer
182 views

C++ template functions to partially implement Python numpy ndarray limited to 1d and 2d

I just read a book on creating a neural network. The book uses Python. I wanted to port this to C++. In order to do that I had to create template functions to implement some of the ...
4
votes
1answer
831 views

Circular doubly linked list with templates

I tried to write some code namely "Circular doubly linked list" and I would like to use templates to do this. This is the first time I use templates and throws some exceptions. I would like to know ...
4
votes
1answer
1k views

Normalize integer types to float range

I wrote two template functions to take an integer type and output a float in the given range. One function takes signed integers and the other takes unsigned ...
4
votes
1answer
203 views

A “policy-based” design for a generic CUDA kernel

I am faced with a design issue that has been discussed on SO several times, the most similar question being this one. Essentially, I want polymorphism for a CUDA kernel in the form of a "generic" ...
4
votes
2answers
1k 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 ...
4
votes
1answer
369 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
1answer
548 views

Plugin system for calling methods

I have a small "plugin system" (I'm not sure this is the right name). It allow you to store objects (plugins), and then call some methods from each of them. With this approach we have absolutely no ...
4
votes
1answer
29 views

toggleSaveStream button template

I've got a view which has a corresponding template. The template looks something like like: ...
4
votes
1answer
673 views

GPU and CPU templated matrix classes

I'm learning CUDA C++ (and C++). Can you guys give me some feedback on my basic templated matrix implementation? A brief explanation of my decisions: First things first: I can't use STL classes/...
4
votes
1answer
689 views

Jinja2 template loader

I am playing around with building my own back end with python 2.7 and jinja2/cgi. Originally I was defining some of my environment and loader variables at the top but figured this was not the best ...
4
votes
1answer
521 views

A template-fixed-size unsigned integer class

For some reason or another, I want to have available unsigned integers of sizes other than 1, 2, 4 and 8 (e.g. an unsigned integer with 3 bytes). For most platforms, compilers don't make those ...
4
votes
1answer
232 views

Markdown parser, template engine, and then some

I've got my own website! Woo! It's got HTML and everything! But after struggling for a while with HTML and keeping my navbar consistent across pages, I gave up and wrote a program which: Searches for ...
4
votes
2answers
502 views

Data structure to store large numbers of runtime-dependent arithmetic types

Warning: lots of code. If it's too much, please focus primarly on channel.h and channel.hpp. This is my first time posting on ...
4
votes
1answer
2k views

Heavily templated mathematical vector class

I started to write a library for linear algebra for personal use, but also for revitilization of my C++. Below is the first class of this library, a templated vector class, which is templated over ...
4
votes
1answer
462 views

C++ template to randomly choose from N elements with uniform distribution

There is a nice algorithm to randomly choose an element from a list in a single pass: Pass through the list keeping the element chosen so far (X) and the number of elements processed (N). When ...
4
votes
1answer
98 views

A class to encapsulate a pair of ints with range-checking

The goal is to have a helper class to wrap the concept of a resolution safely, encapsulating the range check into the class, since otherwise it can get lost by a client not so cautious. I think this ...
4
votes
1answer
2k views

C++ time types and format conversions

I wrote a small header-only C++11 header for converting between various C++ time formats: ...
4
votes
1answer
98 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. ...
4
votes
1answer
129 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 ...
4
votes
1answer
2k 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 ...
4
votes
1answer
268 views

Template with boost::operators extremely verbose and repeating

I got the following ugly code: ...
4
votes
1answer
6k 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
1answer
462 views

Flask web application, with handling for user login status

I am trying to change some variable in base html-template which other html pages inherite from after entering user in personal account. The idea is as follows: there is base html template and there ...
4
votes
1answer
479 views

A generic “manual” loop unroller

I want to force my compiler (C++ or perhaps CUDA) to unroll certain loops that it would rather not unroll. So, I've written the following: ...
4
votes
1answer
130 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 ...
4
votes
1answer
244 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: <...
4
votes
1answer
752 views

Rendering and re-rendering a Mustache template

I want to ask whether my following implementation is good in the view of good practice and performance. I have an app where I have to show another page or template html in an iframe. I get that ...
4
votes
0answers
39 views

Emulating Virtual Registers Part 2

This is a follow up of my original question in which I'd still like to have some answers, opinions etc. but after looking through some of the standard library's features I have come across ...