Questions tagged [template]

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

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
363 views

Observable Object

I have created an observer and an observable object class. The idea being that you can create an observer that does some action whenever object being observed changes value. Design goals: Be able ...
5
votes
0answers
434 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 ...
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 ...
4
votes
0answers
60 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
64 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
842 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
196 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
0answers
15 views

Reference enum values in Angular template without aliasing the enum type

Is there a way to improve this code? I'd like to use the enum type PaymentMethoddirectly in the angular template without renaming it to ...
3
votes
0answers
49 views

Generic Variable Elimination with multiple entry points

I have this algorithm, called Variable Elimination, which is used quite often in my code-base (library). It is an algorithm for factor graphs (a type of bipartite graphs), used to efficiently maximize ...
3
votes
0answers
322 views

Replacing dynamic polymorhism with static polymorphism in C++

Motivated due to the fact, that the avr-g++ places the vtables in RAM, I wrote a replacement using static polymorphy. Consider the following example: ...
3
votes
0answers
50 views

SparseGraph: A representation of a mathematical graph

I'm working on a SparseGraph which reflects the mathematical notion of a graph. All code included here works in all of the basic test cases that I've tried. However, I'm most concerned about the ...
3
votes
0answers
71 views

Template class for an Entity Component System library

I'm working on an Entity Component System library. Right know I'm trying to clean up the Entity/Component part (only the code which manage the data). But I have a class which I think is not really ...
3
votes
0answers
459 views

Rust-like “Result” in C - nicer error handling

There are frequently things I miss when using C; one of them is a nice error-handling (exception-like) system. After trying Rust, I realized I could implement something similar in C itself. So here's ...
3
votes
0answers
91 views

Implementing a templated Array class

I have implemented an Array class using templates. I have used a std::allocator object for memory allocation. Will it be better to use operator new along with placement new for memory allocation? ...
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; ...
3
votes
0answers
1k views

Universal “call” function

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
2
votes
0answers
56 views

Emulating Virtual Registers by experimenting with unions, bitfields, structs and template specialization

To get a better handle and understanding of how bitfields, unions, and the byte alignment of structures work, I'm simulating a template Register structure. The requirements of my Register are as ...
2
votes
0answers
116 views

Observer(Event) system (Signals and Slots), type and template based

Signals are represented as types. You can connect a member function of some instance to the Observer system. This connected function will be called whenever a signal of a type that is the same type as ...
2
votes
0answers
41 views

vb.net Create textfile from template

What is the best approach for creating textfiles from/with a template ? Currently I just read the template from a textfile and Replace all values needed, but I don't think that this is the most solid ...
2
votes
0answers
440 views

Reference wrapper for functions overloadings and universal references

I have design a little class to allow to overload a function with universal references for a known type, but I'm not sure if that class will work as expected in any contexts. The indended purpose is ...
2
votes
0answers
1k views

Creating a binary tree from an array

I want to easily create a binary tree given an array. The array elements are processed in a level order manner. E.g. If the array contains: {19,10,43} Then the root is 19, left child is 7 and right ...
2
votes
0answers
367 views

Registering data types with logger at compile time

I am working on a data recorder in my library for pseudo-realtime systems. I have a default templated record() function to cover basic data types, and library users ...
2
votes
0answers
841 views

Thread-safe LRU cache for C++

I'm working on a simple LRU cache for C++. There's nothing spectacular or unusual about it, but I would like it to be thread safe. (I'm going to be using this for instructional/benchmarking/...
2
votes
0answers
79 views

Any class implementation - follow-up

Based on the previous question, I have improved it to make it insert regular function. Also, I have implemented a new template approach to obtain the signature from any function by testing its ...
2
votes
0answers
60 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 ...
2
votes
0answers
113 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. ...
2
votes
0answers
229 views

Using the Template Design Pattern to reduce code duplication between two algorithms

I have made a Skyline query solver which for now can solve the query with two different algorithms. The first is Block-nested loop (BNL) and the second is Sort filter skyline (SFS). The two are ...
2
votes
0answers
2k 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 ...
1
vote
0answers
17 views

Angular forms - reactive vs. [(ngModel)]

I am developing this angular app and it has big forms with 100 + fields. I was thinking about using [(ngModel)] without reactive forms, so that it's easier to do ...
1
vote
0answers
46 views

Javascript + php system for reusable HTML templates

I have many pieces of HTML code that are used in many parts of the website (controlled by javascript), like edit forms and dialogs. Instead of include-ing the html ...
1
vote
0answers
54 views

Simple dynamic array template

For my game engine I needed a simple templated array class that can be safely passed across module boundaries. It's not supposed to be a replacement for std::vector and thus doesn't need all of its ...
1
vote
0answers
44 views

Value-To-Type Map

Context For one of my projects I have to use a library which works similarly to the following code : ...
1
vote
0answers
34 views

Displaying Singapore bus arrival times using a Go template

I am wondering whether my template usage in main.go could be better. For example in other code I notice: ...
1
vote
0answers
507 views

A simple and efficient packet frame encoder/decoder

I have written a simple packet-framing class, for converting un-encoded 'packets' into encoded/delimited 'frames,' to be sent over a P2P serial connection. The functionality is based on the RFC 1662 "...
1
vote
0answers
33 views

Type conversion between Node, Const_node, and their views

Each node is a location within a layer. A Location may be a pointer or an index. A Layer is a container. There are 4 types of ...
1
vote
0answers
60 views

Type System for Layers and Nodes

Overview The following is a type system of layers (A, B, C, ...
1
vote
0answers
53 views

Creating objects by defined name

I'm trying to write universal factory creating objects by name. I've got some working prototype now but there must be a better way than casting construction methods to void pointer. ...
1
vote
0answers
356 views

WPF “Glowing” button user control

I have created a "wrapper" for a button that "pulses" until the user presses the button. The implementation that I came up with is below, but I'm sure there's a better approach. ...
1
vote
0answers
361 views

A homemade variadic map

A bit of background: some time ago I wrote a piece of code that can be used for memoization with functions taking one parameter. Now I want to extend this to deal with functions with arbitrary number ...
1
vote
0answers
78 views

Fast HashIndex (HashTable) “template” for indexes and arrays C++

Another in the long line of data structures I'm writing for my 2D isometric game. This is a hashtable that only handles indexes, hence eHashIndex. It does not copy ...
1
vote
0answers
43 views

Modular widget that minimizes js and css scope pollution

So, my goal with this is to create a simple login widget that does as close to nothing to the global scope as possible. The login mechanism is less important than the encapsulation. The whole script ...
1
vote
0answers
29 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 ...
1
vote
0answers
230 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. ...
1
vote
0answers
989 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 ...
1
vote
0answers
238 views

Templating 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 attached to the original post. To see the original post and comment see ...
0
votes
0answers
11 views

Twig macro to generate a table

Basically, I'm lazy. And so, since I don't want to write multiple times the same table HTML, I've made a very ... convoluted macro. ...
0
votes
0answers
52 views

Helper to convert arbitrary function into a custom deleter

If you want to use a custom deleter in unique_ptr you either have to pass a functor or the signature of a delete function as template argument. If you have a ...
0
votes
0answers
35 views

Templated JSON parsing methods that work with an element or elements array

Consider the following two Java methods. The first takes a JSON string representing one element, the second representing multiple elements. gson.fromJson() can be ...
0
votes
0answers
29 views

Optimizing Datatables table of tens of thousands of client-provided rows

We have this employees table, that looks like this: that contains 16,530 employee rows. As expected, this table takes more than 30 seconds to load. I have been tasked with speeding it up somehow. ...
0
votes
1answer
1k views

Digital persona fingerprint verification takes a lot of time

I'm using Digital Persona U.are.U 4000b fingerprint reader and I have this function that verifies the fingerprint from SQL server My problem is the loop because it takes a lot of time to compare the ...