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
1answer
100 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
100 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
133 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
541 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
245 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
808 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
52 views

Enables markup to instantiate objects, call methods, and generate HTML

I'm looking for a code review for the package PXP. https://github.com/hxtree/PXP/ PXP enables markup to instantiate objects, call methods, and generate HTML. It works similar to a server-side ...
4
votes
0answers
43 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 ...
4
votes
0answers
61 views

Tracker for object construction, copy, and movement

I made an object tracker for debugging and testing purposes called ccm_counter (construction, copy, move counter). It counts constructor, copy and move calls. It ...
4
votes
0answers
66 views

Implementing a StringEnum

This is to be used like an Enum (as parameter mostly), but for string (Using .NET 3.5) Actual implementation: ...
4
votes
0answers
880 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 ...
4
votes
0answers
197 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 ...
3
votes
3answers
2k views

C++ Node class template

I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens ...
3
votes
4answers
734 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 ...
3
votes
3answers
209 views

Template class to demonstrate array manipulation

Today I didn't pass the test task for the position C++ junior/middle developer. What i did wrong? Please help improve myself. Task: Description. Write a template class - an array of any type ...
3
votes
3answers
493 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 ...
3
votes
2answers
309 views

Generic sliding average in C++

I tried hard to come up with a function template computing a sliding average. A sliding average over data \$x_1, x_2, \dots, x_n\$ with window length \$k \leq n\$ is a sequence \$y_1, y_2, \dots, y_{n ...
3
votes
3answers
2k views

Template 3d vector class

I've created this 3D vector class and would like it to be reviewed. I wonder if there are still some improvements that can be made. This is a header only implementation. ...
3
votes
3answers
774 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
117 views

Generic implementation of an HeapArray and StackArray

I present my implementation of an HeapArray and StackArray. Similar to the implementation of my ArrayView which justs open a ...
3
votes
1answer
99 views

Elevation to power function using class templates

I attached below a small working example of a function that is able to perform x^y. As it is possible to see the base (x) takes ...
3
votes
2answers
224 views

Simple Matrix Template Class

I wanted to make a matrix template class to see if I can learn how to use templates, work on figuring out the indexing in loops, and making an interface so the user can know if an operation will work. ...
3
votes
2answers
390 views

C++ finalizer template

Consider, please, my code of the finalizer template: ...
3
votes
1answer
823 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 ...
3
votes
1answer
1k 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. ...
3
votes
1answer
73 views

Predefined values for some values in a template function like with a #define macro (e.g. template<int foo, typename bar>)

I want to overload an operator (e.g. operator<<) with different types, but also change only 1 or 2 values in the function itself. I want to get some fancy output of a vector with the primitive ...
3
votes
1answer
354 views

Implementation of static_vector using an array of std::aligned_storage, with std::launder and forwarding

I'm trying to expand on the implementation of static_vector on the std::aligned_storage reference page, but would like to split it into two parts. First, an ...
3
votes
2answers
124 views

C++ Vector with templates

I am learning about templates in C++ so I decided to implement an N-dimensional vector. The code seems to work fine, but there are a few things that I am unsure about. To stop ...
3
votes
1answer
47 views

D minMax function implementation

I happened to need to find both the maximum and the minimum of an array, so I decided to implement a minMax function in D. Questions: Is this an efficient ...
3
votes
2answers
454 views

Triple-type template container

I made a triple-type container, that is, a single type that can store a value, under one of the three types used. It's somewhat similar to Boost::Variant. The header file (multitype.hpp): ...
3
votes
1answer
157 views

Templated renderer class

A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash. ...
3
votes
1answer
53 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 ...
3
votes
1answer
74 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 ...
3
votes
1answer
379 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
3answers
209 views

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
2answers
3k 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 ...
3
votes
1answer
3k views

Template system with master layout

Here is my template code ...
3
votes
1answer
99 views

JavaScript module to filter data and render it as a table

I want to organize some JavaScript code using module pattern. The scenario is as follows: Having the following html table created dynamically ...
3
votes
1answer
3k views

C++ Registry pattern implementation

I created a template registry class. It supports custom factory functions and custom constructors. Any kind of feedback is welcome (style, performance, bugs) registry.hpp: ...
3
votes
1answer
390 views

Check balanced brackets in a text

Given an input text that is a combination of {, }, [, ], (, ) characters, check whether the input text has balanced brackets or not. This was a question from hackerrank, and the code below solves it ...
3
votes
1answer
411 views

C++ Policy-based object pool

Description This is an improved implementation for a previous post My goal was to implement a decent object pool using templates and policy based design. The object pool behaviour can be customized ...
3
votes
1answer
93 views

Checking for a palindrome in any sub-range of a range

This is my attempt at answering "Palindrome from all the substrings" which asks to detect if a string contains a palindrome as a substring. The algorithm implemented here is the one described in its ...
3
votes
1answer
222 views

Internal Zip-like Iterator

My goal was to create an zip-like iterator to selectively iterator over a subset of arrays in a larger manager object, compare itself to any other zip-like iterator, but can be copy constructed from ...
3
votes
1answer
1k views

Using simple HTML template to create HTML formatting rules

One of my tools that renders HTML needs some rules about document formatting. The renderer can format the output so that it is indented and contains appropriate line-breaks. In the first version I ...
3
votes
1answer
1k views

Cloning Windows Forms controls from a template

In a recent project I needed a way to clone windows forms controls from a template which had predefined Size, Font, etc. Since ...

1
3 4
5
6 7
9