a design structure for creating several things that are almost identical but need different values. Not template-meta-programming.
0
votes
1answer
49 views
Designing a generic C++1z class [closed]
I'm designing a generic interface for a MessageEntry class for a .h file.
I'm looking for guidance on form and terminology (would I call this an interface/template/generic class?):
...
2
votes
0answers
50 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 ...
2
votes
1answer
58 views
Object Oriented Finite State Machine
I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments.
I clearly have little understanding of C++ templates because most ...
1
vote
0answers
49 views
Code repetition in specialized template methods
Suppose I have a class of complex numbers called Complex and I wish to implement a class of generic matrices with transpose operation.
...
2
votes
2answers
54 views
C++ Optional Implementation
I haven't done much programming in C++, so I figured I'd try making an Optional class. I'm mainly concerned that I didn't follow good conventions or that I didn't ...
7
votes
2answers
124 views
SQL code reuse with C#
I have some code that allows for SQL reuse for C#. I'm pretty happy with it, but the fact that I can't find anything similar on the web makes me think I'm going about it the wrong way. I have a GitHub ...
2
votes
0answers
45 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 ...
6
votes
3answers
606 views
C++ Stack using template
I'm learning C++, so I wrote a stack with the help of templates. I'm wondering if there is anything I can improve or if I did something vastly wrong.
Stack.h
...
10
votes
3answers
470 views
Fastest possible text template for repeated use?
While reviewing Sending templatized e-mail to a million contacts, I wrote this implementation to illustrate an alternate approach. It is designed to be the fastest possible way to generate templated ...
4
votes
1answer
40 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 ...
2
votes
4answers
84 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 ...
8
votes
3answers
379 views
n number of x on the y
Everyone knows "99 bottles of beer on the wall".
Mat's Mug made a comment about mugs on the wall in The 2nd Monitor and I realized I never wrote a "beer on the wall" program. But that seemed way too ...
0
votes
1answer
32 views
Method of uniquely identifying classes
I have written the following class to allow me to uniquely identify classes in C++, and I was wondering if there are any better ways of going about it.
...
5
votes
0answers
42 views
Template integer range, version 2
This question is a follow-up. The original question was itself a follow-up to an older question by @LokiAstari.
The idea is to provide a compile-time integer range.
This version incorporates ...
2
votes
2answers
70 views
DataStream interface for reading and writing data
I am writing a C++ library which will interact on files, memory buffers and remote files accessible with the HTTP protocol.
To handle that, I've decided to create some classes that will use the ...
3
votes
1answer
45 views
A trait class to detect whether a template is specialized for a given type
Today's question will just be about a small utility that I needed at some point for one of my projects: a template to detect whether a template is specialized for a given type. The utility uses ...
3
votes
1answer
50 views
Draw an ASCII checkerboard
I'm a newcomer to C++, from C#. I wrote a program that prints an ASCII checkerboard with a side length of the number passed to it (link to original Code Golf question).
stdafx.h
...
5
votes
2answers
135 views
C++ 2D shape intersections - template reduction
I've created a short piece of code to determine whether or not various 2D shapes (circles/lines/rectangles) intersect. It was a job interview question, but now it's just about self-improvement.
I'd ...
4
votes
1answer
95 views
Template Method Checker
I have written some template helpers to check if a class has a certain method with a certain signature. The code is based on this answer. I attempted to extend it for generic methods. An important ...
0
votes
1answer
32 views
User and Score models
I have a couple of models - User & Score. I am displaying data from those models to my template. Data from ...
3
votes
0answers
57 views
Representing trajectory points using inheritance
Problem Background
I need to represent trajectory points and trajectories (encapsulating these points) in the form of a collection of classes. All trajectory points have two essential elements: time ...
3
votes
0answers
39 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; ...
7
votes
2answers
83 views
for_each_cons and for_each_slice, variants of std::for_each working on sliding windows
My goal was to replicate Ruby's each_cons and each_slice:
...
5
votes
1answer
79 views
Thread-Safe Variadic Printing Function
Printing to stdout is thread-safe in many systems when using printf or std::cout, but not in ...
5
votes
1answer
113 views
Linear algebra module
I'm working on a linear algebra module to improve my knowledge with mathematics and, because I'll need a lightweight linear algebra module for my future work with Vulkan!
I tried to keep a blas-like ...
1
vote
1answer
62 views
Element selectors for a RepeatButtonView
I have a large application with a wide-reaching amount of views and sub-views. I have a need to decorate DOM elements with identifiers so that my framework of choice can bind views to the DOM ...
2
votes
1answer
86 views
Populate a .txt document with a CSV spreadsheet using multiple templates, outputting documents for each data row
I'm looking for feedback on functionality, PEP8, advice, etc as a learning tool. I'm not sure how to tell if this program should be broken into separate functions or combined as one.
While hand ...
1
vote
1answer
42 views
Accessing nested data properties in Handlebars
I am using HandlebarsJS for my templating needs.
I have a nested object:
...
2
votes
1answer
79 views
Game engine ObjectFactory class
I've developed as part of a game engine a template class for a factory which manages objects of one specific type. The factory handles initialization, destruction, and accessing previously created ...
4
votes
1answer
171 views
C++ custom memory allocator
I'm working on a C++ custom memory allocator, that would be kind of a replacement for the C flexible array syntax, you know, the stuff like that:
...
3
votes
1answer
72 views
Templated renderer class
A class that matches the rendered objects shader and render function(sets shader resources) based on its typeid hash.
...
0
votes
1answer
49 views
Simple Batch Templating Utility in Python
I would like to present for review my (much) revised batch templating utility which had it's humble beginnings here in a previous post. As I mentioned there, this program is my entry into python ...
3
votes
2answers
233 views
Email Template Parser PHP Class
This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into ...
3
votes
1answer
137 views
Fully Generic C++ Stack Implementation Without Lists, Arrays, or Vectors
I'm trying to write a fully generic Stack in C++. I'm not sure if this is the best way to do this.
Right now I know that the Pop method needs improvement since ...
4
votes
1answer
111 views
Generic container assignment
For setters that set a member collection, I write template functions so as to accept any collection type as input:
...
8
votes
2answers
103 views
Type-safe cartesian co-ordinates
I've recently been fiddling around with a type safe implementation of cartesian co-ordinates (and a few operations on those co-ordinates). Often it's easy to get units mixed up: is something in ...
5
votes
3answers
293 views
“Set” your expectations low for this ADT
For my third assignment in CS2, I was given the following:
A set is a special bag that does not allow duplicates. Specify each
operation for a set of objects by stating its purpose, by ...
0
votes
1answer
31 views
Prefered Style Container for the Components in the DataTemplate
The following XAML is a close (tidied up) version of what I have use in my WPF application. If you have noticed there are two Styles applied to the same component ...
14
votes
4answers
1k views
Smart as a bag of rocks
For my second project in CS2, I was given the following assignment:
Implement a new ADT called a bag with receipts.
The specification for the class of bag with receipts differs from a
...
8
votes
1answer
640 views
Create New C++ Class
I'm currently developing a new version of ExpressGenGen Using TDD. While I'm rewriting the new version of my Code Generator Generator.
I'm using its old version to generate code to be used by the new ...
3
votes
0answers
81 views
Generating all permutations of a template pack
AllPermutedPacks<Pack<Types...>>::type is to be the pack of packs consisting of all permutations of Types.... For ...
2
votes
1answer
178 views
Loading template file and replacing placeholders
I have an HTLP template file called "template.tmpl". In the template I have a few placeholders like {{NAME}} and {{USERNAME}}. I ...
3
votes
1answer
140 views
Generating a zoo of animals
The pattern I've come up here is for the AnimalGenerator itself, outside of the (abstract) Factory Pattern used within it. The factory classes themselves are not ...
9
votes
2answers
2k views
Calculator using class templates
I've just completed an assignment about class templates in C++. It works fine and produces the correct output. We were given the main function and had to construct and implement the class. I'm ...
3
votes
1answer
65 views
Seeking proper system for pairing types
My code below ensures that only land animals can be a "representatives" for Land while only ocean animals can be representatives for ...
3
votes
0answers
84 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 ...
5
votes
2answers
461 views
Stack implementation using vectors and templates with no overflow version 1.1
I have modified my code as per the suggestion given by some of the developers. Let me know if there are any further concerns or scope for improvements.
Original Version
...
6
votes
1answer
171 views
Factory template method for generalized functors
(A quick note on terminology: I use 'generalized functor' to refer to a functor that can be initialized from any callable entity, similar to the definition from Alexandrescu's Modern C++ Design. I use ...
2
votes
0answers
71 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. ...
4
votes
1answer
332 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 ...