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
0
votes
0answers
23 views

Minimal Property system in c++17

So I needed to represent by objects in terms in ini format and change their values from the ini as well, so I thought why don't implement a property system for this. I want it to be bit fast so I ...
5
votes
3answers
404 views

Template Matrix Class: implemented some basic functionalities

Basically I have written a matrix class for addition, multiplication and scalar multiplication. I need your review of the class implementation below in terms of efficiency, memory consumption and new ...
1
vote
2answers
54 views

Class template, custom container

So I wrote this class template for a custom container. Basically, it stores elements and their occurences. When an element is pushed into the container, if it ...
1
vote
1answer
44 views

Serializable and extensible API implementing the Command Design Pattern

I am currently trying to implement an extensible way to create commands that can be sent to some type of executor. In my case, there would be two of them (server and client). As I posted here, I had a ...
-1
votes
1answer
76 views

abstract base classes versus the curiously recurring template pattern [closed]

Background Apologies for "burying the lead." The questions are in the next section. In my application, the purpose of inheritance is to abstract away complicated logic in the base class template, so ...
4
votes
3answers
133 views

Binary Search Tree Using Templates in C++

I have made this BST using templates Node.h ...
1
vote
1answer
47 views

Check my usart driver wrapper please

Could you review my usart driver wrapper please? It contains the C language Xilinx usart driver, but I write C++ programs and need to C++ usart driver. How it was designed correctly and what I have ...
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 ...
5
votes
0answers
129 views

Implementation of container searchable by any element

Writing game engine as a hobby, I've come across many situations where I need a container like a map, but searchable by different keys: a block allocator where a block needs to be searched by either ...
2
votes
0answers
73 views

Compile time logical operations for web framework in C++

I'm working on a web framework in C++ and there's this part that I need to do something like this: ...
5
votes
0answers
61 views

Python Project Template

What's up smart people. A little backstory for context: I'm a completely self taught dev, and the only person ever looking at my code for the past 6 years is myself. I realize that's not the best idea ...
11
votes
2answers
186 views

YAAI (Yet another any implementation)

I am a C# game developer currently learning C++ and this is my second big-ish project (the first one being a vector implementation). This time I opted for implementing a mot-a-mot ...
2
votes
0answers
39 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 ...
5
votes
0answers
55 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 ...
16
votes
2answers
255 views

YAVI (Yet another vector implementation)

I am a C# game developer currently learning C++. I am trying to implement some simplified STL containers. Here is my implementation of vector, which does not have the allocator (because ...
0
votes
1answer
46 views

C++ Linked List Template Implementation, Howto Default Compare Function, and Split?

To better learn templates, I have dabbled with a simple linked list implementing the class with a private member compare function (cmp) that is used when adding ...
0
votes
0answers
12 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. ...
1
vote
0answers
50 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 ...
7
votes
2answers
2k views

`printf` improvement with C++ variadic templates

I am currently working through learning C++'s variadic templates and I wanted to create an example use of them that is less trivial than the one in my book. I decided to create a modification of ...
0
votes
0answers
55 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 ...
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
114 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. ...
3
votes
1answer
70 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 ...
4
votes
1answer
72 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
59 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 ...
5
votes
1answer
54 views

Emulating Virtual Registers Part 3

Forward This is a continuation of my work in progress and the last iteration that I posted can be found here. I have designed a compact class template that uses SFINAE with constructor delegation to ...
3
votes
1answer
89 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 ...
4
votes
0answers
41 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 ...
2
votes
0answers
66 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 ...
4
votes
2answers
152 views

Detecting if an element is found inside a container

I just wrote this template to detect if a given element is found inside a container: ...
2
votes
1answer
85 views

Replacing MIN and MAX macros with type-safe, recursive templates of variable arity

I'm currently reading Mastering Perl for Bioinformatics; I'm using the book for learning bioinformatics while implementing the code in C++. I came across a situation where I needed to use the minimum ...
3
votes
1answer
229 views

dc.js and crossfilter app to display multiple charts

Consider the following crossfilter / dc.js app (screenshot): ...
3
votes
0answers
53 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 ...
6
votes
1answer
82 views

Simple bash script creates apache2 virtualhost config for subdomain

Simple bash script to create apache2 virtualhost for localhost. Can be used for public subdomains on developer server with changes - "replace .localhost". Tested on Ubuntu, but should work where ...
4
votes
2answers
140 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. ...
1
vote
0answers
55 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
47 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
1answer
196 views

Calculating array size in C++

This code shows two ways to calculate size of array of any type. I would like to know, which should be preferred? Is there any advantage/disadvantage? ...
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 ...
4
votes
1answer
239 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 ...
6
votes
1answer
79 views

Smart pointer like implementations

For educational purposes I implemented standard library smart pointers like class templates. They are definitely not a full replacement for the library classes but I'd like to get some comments on the ...
0
votes
1answer
52 views

Generate a text file representing an email for a job application followup

Purpose: After you've submitted a resume and cover letter for a job position, you haven't heard anything back, so you decided to send a follow up email. The script generates the follow up e-mail based ...
1
vote
2answers
78 views

Insertion Sort and Selection Sort Implementation

I wanted to practice using templates since I have no experience with them, so I implemented these sorting algorithms. Selection Sort: ...
0
votes
0answers
67 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. ...
2
votes
1answer
62 views

Loop over whole array starting from any index

I recently had to repeatedly iterate over an array but increment the index to start from each time. Since this is quite cumbersome in comparison to a normal for loop I made a small template function ...
3
votes
1answer
282 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
180 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. ...
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: ...
2
votes
0answers
120 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 ...
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 ...

1 2 3 4 5 9