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
5
votes
2answers
116 views

C++ template class to caculate CRC

Here is a template class to calculate various CRC checksums. I go out my way to achieve a good C++ encapsulation for a C style code . Any advice or suggestion is welcome. ...
3
votes
1answer
67 views

Abstract wrapper for fundamental types

I have created this interface as part of my C++ learning path. This post inspired me a lot. The idea is to use its concrete implementations to perform some actions before and after any change of the ...
2
votes
3answers
225 views

C++ logger by template

If the log file is not available, then output the log message to the console. Any improvement or suggestion for this implementation for the logger by the template? Any potiencial problem that I should ...
0
votes
1answer
48 views

Unit Tests for the operators of image template class with Boost.Test framework in C++

This is a follow-up question for Tests for the operators of image template class in C++. As G. Sliepen's answer mentioned, I am attempting to use Boost.Test and several test cases are created with <...
1
vote
0answers
42 views

template Matrix class with Static or dynamic size

I started implementing the folowing Matrix class in order to get a better understanding of templates classes in general. For now, it lacks a lot of features, it does very basic things: addition ...
2
votes
1answer
58 views

splitting a tuple into N-element tuples

This nice hack should allow you to split a tuple into N-element tuples, thereby effectively splitting a tuple into pairs, triples, ... For example, this allows you to split an input parameter pack, ...
0
votes
1answer
70 views

Image pixelwise operation function with multiple inputs in C++

This is a follow-up question for Tests for the operators of image template class in C++ and A recursive_transform template function for the multiple parameters cases in C++. I appreciated G. Sliepen's ...
3
votes
0answers
75 views

A Compile-time templated event system and dispatch manager

Problem I would like to make an efficient, extensible, and potentially asynchronous parallelizable event system using modern features in c++20. My solution I've ...
2
votes
1answer
60 views

A recursive_transform template function for the multiple parameters cases in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++. Thanks for G. Sliepen's answer. Based on the mentioned suggestion, I am attempting to ...
1
vote
0answers
60 views

A recursive_transform template function for the binary operation cases with execution policy in C++

This is a follow-up question for A recursive_transform template function for the binary operation cases in C++, A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary ...
2
votes
1answer
84 views

A recursive_transform template function for the binary operation cases in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_print Function For Various ...
2
votes
1answer
63 views

Tests for the operators of image template class in C++

This is a follow-up question for Two dimensional gaussian image generator in C++. Thanks for Cris Luengo's answer and JDługosz's answer. I am attempting to update the implementation of ...
7
votes
2answers
172 views

Two dimensional gaussian image generator in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C++ and Two dimensional gaussian image generator in C. Based on user673679's answer, another file ...
3
votes
1answer
150 views

Two dimensional bicubic interpolation implementation in C++

This is a follow-up question for Two dimensional bicubic interpolation implementation in C and A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable ...
-1
votes
1answer
59 views

Passing a partial application as an argument of an other function with no overhead [closed]

I am trying to find a way to pass a partial application as an argument of an other application with no overhead. I think I have find a way to do it (which might be dirty). The templated structure &...
0
votes
0answers
56 views

Is this a good way to construct the class for a C++ template partial specialisation of a member function?

I am teaching myself c++ by doing a series of exercises. I liked the idea of working out how hash tables could be done using just the language and no std calls. I discovered that you cant do "...
1
vote
1answer
77 views

Check if two types are the same without template instantiations

Below is my attempt to check if two types are the same without template instantiations. ...
8
votes
2answers
152 views

re-implementation of std::vector

I've implemented a simple vector-like structure. I would appreciate all criticism relevant to code. I have also published code under github. Here is the link to source code + unit test for most ...
3
votes
1answer
69 views

Assignment function as alternative to std::tie

What do you think about this assignment "idiom"? ...
10
votes
3answers
833 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
87 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
289 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
211 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
162 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
31 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
329 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
311 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 ...
4
votes
1answer
145 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
56 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
167 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
247 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
100 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
168 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
363 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. ...
7
votes
2answers
191 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
313 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
161 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
666 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
337 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
428 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
506 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
91 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
314 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
66 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
79 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
1k 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 ...

1
2 3 4 5
10