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
3
votes
1answer
57 views

Assignment function as alternative to std::tie

What do you think about this assignment "idiom"? ...
10
votes
3answers
791 views

C++20 Vector2D Template

Pretty simple 2-Dimensional Vector template with operators and two utility functions making use of C++20 concepts. Header-only templates, function inlining and operator overloading, etc. is not ...
-1
votes
2answers
74 views

Using a lambda to generically create an arbitrary class wrapper around some object of type T [closed]

While experimenting with some of C++'s language features, I was able to successfully design an invokable nameless function call through the use of a lambda that generically creates an arbitrary class ...
3
votes
1answer
66 views

Board game design in C++

I'm trying to build a board game and solve it using algorithms such as Monte Carlo Tree Search in C++. My current design follows this python project, in which I have a class hierarchy for ...
4
votes
1answer
80 views

Alternative std::function implementation for lambdas

I was trying to implement a faster, alternative implementation of std::function. I came up with the code below: ...
1
vote
0answers
15 views

Using (templated) function-scope static address as Unique ID [closed]

typedef const bool* const TypeID; template<typename> TypeID TypeIdOf() noexcept { static const bool idLoc(0); return &idLoc; } I'm using ...
1
vote
1answer
87 views

Vector Implementation C++ using RAII

I have attempted to implement a similar version of the STL Vector; several functions are missing but I'd like a few words of advice on whether I am indeed on the right track or whether I should change ...
0
votes
1answer
29 views

Html Templating for a WIP static site generator, written in Javascript

I wrote this to go in my simple static site generator. it takes any plaintext file (but meant for html) and injects the specified file contents and other data at matching tags. This is my first "...
1
vote
2answers
146 views

C++ Shared_Ptr implementation

I reinvented a c++ smart pointer, shared_ptr to be precise. It is meant for practice purpose and does not attempt to replace the standard implementation. To the ...
0
votes
2answers
42 views

struct,template arguments, C++ [closed]

I am writing color model logic in C++. I ask review in defining limits for the color model, by saying Limits I mean this. Consider a struct which represents ...
5
votes
1answer
55 views

wrapper class for random access iterator to hide template method implementation from header file

I have a set of template functions that have itrator types as template parameters, so can be used with any kind of iterators. std::find can be a good example. Also ...
3
votes
2answers
55 views

C++ PixelComponent struct

Hey I wrote a struct in C++ trying to represent a Pixel Component of a color Here it is ...
8
votes
1answer
135 views

Generic test case templates

I often find that when I am writing, refactoring, or reviewing code that I want to do some simple testing. There are many existing test frameworks such as gtest and cppunit but my desire was to ...
1
vote
2answers
57 views

Magic Static in Singleton Template

I recently was reading an article labeled "Modern C++ Singleton Template". The proposed solution used C++11 feature of Magic Statics (N2660). I wanted to adapt it for an own project in "...
12
votes
3answers
91 views

Suggestions on cleaning up Flask app

I've written a little bit of code to pull data out of my FitBit and store it in a GCP database for further analysis. The project is available here, but what I'd like to ask about specifically is the ...
5
votes
1answer
123 views

Template Metaprogramming - Multidimensional Vector Declaration

[EDIT] The question has been edited. Please make sure to read the summary at the end of the post. If you'd like me to make a new post with a cleaner explanation and better examples, tell me to do so ...
7
votes
2answers
328 views

Doubly Linked List Data Structure ADT in C++

I'm trying to implement a Doubly Linked List data structure in C++. Please give me suggestions on how this code can be improved. Try to remain in C++11 because that's what I know atm. ...
6
votes
2answers
78 views

Cleanly passing in a large number of mutable parameters through a python class

I want to create two classes, one for attributes and one for functional behaviors. The point of the attributes class was to hold all of the attributes along with property methods (setters/getters), ...
3
votes
2answers
133 views

Linked List Queue Implementation

I implemented a Queue using linked list data structure. This is also my first time using templates in C++. OVERVIEW Queue is a data-structure that supports only ...
6
votes
2answers
93 views

C++17 static templated ini file reader

I've written a modern C++17 INI file reader to get access parameters values from an INI configuration file anywhere in a source file by simply included ...
2
votes
1answer
482 views

Generic Doubly Linked-list implementation in C++

I am just learning about C++ templates and generic types, I decided it would be nice to try to create a generic container class as a challenge and test my knowledge in the process. Here is what I have ...
6
votes
2answers
327 views

Templated palindrome

I'm trying to implement a palindrome check for each element in a vector and return a vector with only the palindromes. This should work for different type .e.g strings int vector of ints.I have done a ...
2
votes
0answers
17 views

Liquid includes Share Page

This week I published a project that aims to enable sharing Jekyll built pages on various social media platforms, without unnecessarily degrading client privacy; ie. it does not call-out to those ...
6
votes
2answers
276 views

A proxy replacement for getters and setters

Have you ever written proxy objects, instead of using a setter and a getter method? In that case, I'm interested in your opinion on the following design for a templated proxy: ...
1
vote
0answers
22 views

Liquid includes HCard module

The source code of this project aims to enable defining contact information either via FrontMatter or named parameters, and having that information then formatted to HTML that is both human and ...
2
votes
1answer
19 views

Building content templates with javascript and no 3rd party library

I had a need to build a standardized layout for content on many of the pages of my website based on data returned from my web service but the project I'm doing this on is already bloated with stuff ...
6
votes
1answer
193 views

Checking if a value is in a container

I quite often find myself checking whether a given value is present in a given, possibly nested, container. For example, is int val present in the nested container <...
3
votes
2answers
84 views

Is this good c++ code for a pin/socket for a node editor?

I'm trying to create a node editor "framework" (IDK what to call it, but essentially there is no GUI and should be implemented using these classes), similar to rete.js, blueprints(maybe an exception ...
0
votes
2answers
166 views

Union find using unordered map and templates in C++

I tried to implement union find (disjoint set data structure) algorithm in C++. There I used unordered_map data structure. Is there a better way of doing this using any other data structure. While ...
0
votes
1answer
50 views

Implementation of a vector of pairs

In a personal project I was working on, I had a vector of std::vector< std::pair<unsigned,char>>'s that represented a character and its position in the ...
5
votes
0answers
65 views

Custom template system with introspection in Perl

I know I never have to reinvent the wheel, but I did, because I need speed performance, also I need this features: introspection or metaprogramming actuate like api backend private variables ...
6
votes
1answer
435 views

C++ Template to implement the Factory Pattern

Design A template class that will create a concrete instance of an interface class when given the name (as a string) of the concrete class. This design is often seen in code, so the purpose of this ...
4
votes
3answers
62 views

Copy and in-place transformation of strings to lowercase/uppercase

I have the following code that transforms a string to upper/lowercase: ...
2
votes
2answers
362 views

Publisher Subscriber Pattern Template

This is the first time that I have tried programming in such a general way using c++. I have tackled this pattern before in other languages such as ...
4
votes
2answers
102 views

What changes should I implement in my templated sorter class so that it performs efficiently?

I have a college assignment to implement a class called sorter, whose object is a sorted vector (the user is allowed to sort it by the method he/she desires). I have been able to implement it as ...
5
votes
1answer
138 views

`zip` operator to iterate on multiple container in a sign

I worked out a zip operator similar to Python's, because I didn't find one in std. It allows to use range-based ...
2
votes
1answer
78 views

template iterable numeric range class with multiple min/max inclusion modes

Problem my code solves: Lack of lightweight numeric range classes which can tell if arbitrary values lie inside them, supporting more than just simple exclusive max modes and integers, and that ...
2
votes
0answers
47 views

Python class for helping template SQL queries when working with psycopg2

While working on a project to do some spatial data processing in PostgreSQL, I found it cumbersome to use the psycopg2.sql objects to safely compose queries. I ...
2
votes
2answers
94 views

Lock-free multi producer logging/profiling, multi file descriptors

I am developing (for fun) a Utilities & Logging library Can someone please help me to improve: Github link Pros Thread-safe, no mutex. Use lock-free ring buffer (the idea is inherited from ...
0
votes
0answers
24 views

PHP View Templating and Handling Cache

I am trying to create a template framework similar to Laravel Blade template, but using Pure PHP (without forking / extensions) that is backward compatible with PHP5. I am currently trying to find ...
1
vote
1answer
73 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
523 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
60 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 ...
2
votes
1answer
67 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
98 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
735 views

Binary Search Tree Using Templates in C++

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

usart driver wrapper

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
72 views

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

I created this package PXP. PXP enables markup to instantiate objects, call methods, and generate HTML. It works similar to a server-side templating engine, but rather than enforcing braces it ...
6
votes
0answers
139 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
74 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: ...

1
2 3 4 5
9