Skip to main content

Questions tagged [c++14]

Code that is written to the 2014 version of the C++ standard. Use in conjunction with the 'c++' tag.

Filter by
Sorted by
Tagged with
20 votes
1 answer
2k views

Compile-time sieve of Eratosthenes

There are many instances of prime number sieve implementation both here and other places on the web, but I wanted something a little different. In particular, I wanted to create a static array of the ...
Edward's user avatar
  • 66.5k
15 votes
1 answer
2k views

Comparing std::vector<bool> to std::vector<char>

A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over ...
Edward's user avatar
  • 66.5k
8 votes
1 answer
124 views

Nisse Server: Part 1 Helper Functions

Getting close to a release of generic server. So a couple of reviews will be coming this way over the next few weeks. Stating with the lowest levels and working up to the main server. The result is ...
Loki Astari's user avatar
  • 95.3k
5 votes
1 answer
90 views

Nisse Server: Part 3 Stream Layer

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Nisse Server: Part 2 Socket Layer Here is the stream layer code. This basically provides a ...
Loki Astari's user avatar
  • 95.3k
5 votes
1 answer
223 views

Overhauled tokenizer for markargs

In the previous post I've started writing a tokenizer for my imaginary programming language (which I decided to name markargs; trivia at the end of the post). Problem definition: Read the line and ...
Incomputable's user avatar
  • 9,504
5 votes
2 answers
130 views

Nisse Server: Part 2 Socket Layer

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Here is the socket layer code. This has previously been reviewed here. But there have been some changes. Socket.h ...
Loki Astari's user avatar
  • 95.3k
11 votes
1 answer
219 views

MAC1 simulator/debugger

In constructing an answer to this question, I wrote a small debugger/simulator for the MAC-1 instruction set. There are a number of simulators already out there, but most are either too old to be ...
Edward's user avatar
  • 66.5k
11 votes
5 answers
3k views

Efficiently counting rooms from a floorplan (version 2)

This is version 2 of Efficiently counting rooms from a floorplan. I had accidentally pasted in the wrong version of the code. Update Final version (version 3) of the code with updated test harness ...
Edward's user avatar
  • 66.5k
9 votes
3 answers
23k views

Simple string joiner in modern C++

(See the next iteration.) I have this small template function for conveniently dumping a sequence into a string such that there is a delimiter between two consecutive elements, and no such after the ...
coderodde's user avatar
  • 28.7k
6 votes
1 answer
490 views

Efficiently counting rooms from a floorplan

Note this was the wrong version of the code. The updated version is here: Efficiently counting rooms from a floorplan (version 2) My apologies! Update Final version 3 with test harness here: ...
Edward's user avatar
  • 66.5k
5 votes
0 answers
2k views

Generic sliding window

The code implements fully generic sliding window with linear complexity. It should usually be paired with transforming iterator to reach full potential. Sliding window is a grouping of elements by ...
Incomputable's user avatar
  • 9,504
4 votes
2 answers
2k views

Platform independant thread pool v3

This is a continuation of this question, v4 can be found here Taking the advise given previously, the deadlock was fixed in the non-yielding code. The next problem comes from the suggestion to make ...
Tom Myles's user avatar
  • 432
3 votes
2 answers
1k views

Platform independant thread pool v2

This is a continuation of this question, v3 can be found here Taking into account the advise given by Loki, an implementation of the threadpool using a ...
Tom Myles's user avatar
  • 432
15 votes
1 answer
1k views

Battleship strategy evaluation framework

In preparation for the May 2015 Community Challenge, I decided to build a Battleship strategy tester. Implementing an ocean First, there is an underlying Ocean ...
Edward's user avatar
  • 66.5k
9 votes
2 answers
964 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 ...
Morwenn's user avatar
  • 20k
7 votes
1 answer
308 views

Preprocessing iterator

After tweaking semantics a lot, it ended up being a very poor object version of std::transform<>() that can be used with other std algorithms. Basically the ...
Incomputable's user avatar
  • 9,504
7 votes
3 answers
4k views

Building abstract syntax tree for markargs

Roadmap I'm trying to follow usual compiler design: Lexical analysis (1, 2) Syntactical analysis <---- you're here Semantic analysis User input Code generation + execution Background I think I ...
Incomputable's user avatar
  • 9,504
6 votes
1 answer
7k views

Generic menu class for console applications

Expanding the title: my goal (for hobby project) was to create simple, generic (customizable) and cross-platform menu class for console applications (mostly simple, text-based games). That's what I ...
Toreno96's user avatar
  • 163
6 votes
1 answer
190 views

Multithreaded testing for counting rooms from a floor plan solution

This is version 3 of Efficiently counting rooms from a floorplan. Version 2 is here Efficiently counting rooms from a floorplan (version 2) It also has a comprehensive test facility that is the ...
Edward's user avatar
  • 66.5k
3 votes
2 answers
1k views

scope_exit macro

This is actually not something new, but I think many people wanted something useful and not incredibly complicated. So, here it is: ...
Incomputable's user avatar
  • 9,504
3 votes
1 answer
2k views

Sending email using libcurl - follow-up

This question is continuation of: Sending email using libcurl I developed a class to send email. Does this code have any problems? Is it thread-safe? ...
Ufx's user avatar
  • 217
3 votes
0 answers
50 views

Nisse Server: Part 4 Server

Getting close to a release of generic server. Nisse Server: Part 1 Helper Functions Nisse Server: Part 2 Socket Layer Nisse Server: Part 3 Stream Layer Here is the server. The basic usage should be ...
Loki Astari's user avatar
  • 95.3k
38 votes
5 answers
5k views

Easier user input in C++

A more proper version of this utility can be found at the following link here: Giveth me thy easier user input in C++ - follow up. I've always been a little bothered by the fact, that in order to get ...
Ethan Bierlein's user avatar
27 votes
4 answers
3k views

RPG skeleton, Part 1 - The Character

I've been on a quest to learn C++, and to learn, I've started building a small Role-Playing-Game skeleton to help myself learn the language. I've tried to make sure that I've followed C++ styles/...
Ethan Bierlein's user avatar
26 votes
1 answer
17k views

Ford-Johnson merge-insertion sort

The Ford-Johnson algorithm, also known as merge-insertion sort (the name was probably given by Knuth) is an in-place sorting algorithm designed to perform as few comparisons as possible to sort a ...
Morwenn's user avatar
  • 20k
25 votes
3 answers
1k views

Gray codes addition

As some of you know, I have been working with Gray codes and am trying to design a good gray_code class in modern C++. I will end up posting several parts of the ...
Morwenn's user avatar
  • 20k
23 votes
5 answers
6k views

Sorting algorithms - Bubble sort

For pure practice purposes, I started implementing different sorting algorithms in modern C++ in a standard library style way (i.e. using templates on iterators). This is my version of bubble sort. ...
Ben Steffan's user avatar
  • 5,228
19 votes
1 answer
3k views

for_each for tuple-likes

I've implemented a C++14 for_each for tuple-like objects. It's similar to std::for_each in that it also returns the functor once ...
Zizheng Tai's user avatar
18 votes
1 answer
920 views

Integer packs (and integer pack utilities) for template meta-programming

Introduction In template meta-programming, integer sequences and ranges are very useful. I've made a couple of utility classes that do various operations on compile-time integer packs. The ...
user2296177's user avatar
  • 3,543
16 votes
2 answers
1k views

C++ SQL wrapper/Connection

Working on my SQL project at last. The concept is easy to use and integrate SQL into C++. ...
Loki Astari's user avatar
  • 95.3k
15 votes
1 answer
6k views

Simple linear equation solver

In working on a review for Solve a set of "restricted" linear equations efficiently, I decided to reimplement from scratch using the method I proposed in my answer. The application I won't ...
Edward's user avatar
  • 66.5k
14 votes
1 answer
3k views

C++ identity function

I've implemented an identity function (well, actually a functor struct) in C++. The goal is that every occurrence of an ...
Zizheng Tai's user avatar
12 votes
1 answer
3k views

Compile-time-fixed templated integer range

This is a follow-up of an old question by @LokiAstari, modified for the current community challenge. The idea is to provide a compile-time integer range. I applied all the modifications that I ...
Morwenn's user avatar
  • 20k
12 votes
1 answer
1k views

A polymorphic callable wrapper for any callable

I recently answered a question that had an interesting problem statement (I've slightly modified the wording): I have an abstract class A which is base for the ...
user2296177's user avatar
  • 3,543
12 votes
1 answer
2k views

Minimal C++ Unit Test Framework

I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros ...
aggsol's user avatar
  • 404
11 votes
1 answer
192 views

Mathematical expressions evaluator with callbacks, the architecture

This question goes hand in hand with another question about a mathematical expressions evaluator in C++. The other question is meant to be read first, this one is but a complement to expose the ...
Morwenn's user avatar
  • 20k
11 votes
1 answer
717 views

Mathematical expressions evaluator with callbacks, the logic

I hesitated quite a bit of time before posting this question since the code to review is more or less a monster (with regards to its size). It is a basic mathematical expressions evaluator, but with ...
Morwenn's user avatar
  • 20k
11 votes
2 answers
2k views

type_list with utilities

The post is follow up to my previous Typelist with extractor. The type_list and extraction feature code is identical to the accepted answer (from user2296177). The ...
Incomputable's user avatar
  • 9,504
11 votes
2 answers
209 views

Dynamically call lambda based on stream input: Try 2

Originally asked here: Dynamically call lambda based on stream input The following version is based heavily on the answer provided by @iavr, though I hope that I have done enough more to make it ...
Loki Astari's user avatar
  • 95.3k
10 votes
1 answer
2k views

Platform independant thread pool

v2 of this question is here and v3 is here To get a better understanding of C++11/C++14, I thought I would develop a thread pool, even if it has been done to death! The only dependency outside of ...
Tom Myles's user avatar
  • 432
9 votes
2 answers
7k views

Filtering variadic template arguments

I wrote some code to implement a way to filter the arguments of a variadic template based on their type. My current solution requires many helper meta-functions and I'm sure that there must be a ...
realloc's user avatar
  • 93
9 votes
2 answers
216 views

Find the min and max elements of a collection, and check whether it is sorted

The function I propose allows to find the minimum and maximum values of a collection and to check that it is sorted up to a certain element. Basically it is a combination of ...
Morwenn's user avatar
  • 20k
9 votes
1 answer
841 views

Quicksort template (for sorting corresponding arrays)

I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays! The really "metaprogrammy" way to do it would be to use ...
Quuxplusone's user avatar
  • 19.4k
9 votes
3 answers
2k views

Platform independant thread pool v4

This is a continuation of this question. Following the previous advise, the thread pool now can handle almost all types of input, except for one key form, where the function/functor requires one of ...
Tom Myles's user avatar
  • 432
9 votes
2 answers
1k views

Gray codes addition — Take 2

For a while, I have tried to find ways (known or new) to do stuff with Gray codes. As some of you probably know, I already tried to implement an algorithm to add two Gray codes without having to ...
Morwenn's user avatar
  • 20k
8 votes
1 answer
3k views

Chain multiple containers

Python has itertools.chain(), but C++ has nothing. This is my attempt to implement such a thing. Looking mainly for comments about potentially smarter ways of doing ...
Barry's user avatar
  • 18.4k
8 votes
1 answer
4k views

constexpr Sin Function C++ 14

I have written a constexpr sin function using c++14 and would like to know what I can do to improve it. I am trying to balance code clarity/maintainability with ...
Alex Zywicki's user avatar
8 votes
1 answer
690 views

HTML Parser (using SAX)

Got bored writing a review on an HTML parser and decided I wanted to try. So I threw this together to see I could parse an Amazon page. ...
Loki Astari's user avatar
  • 95.3k
8 votes
2 answers
3k views

Finding Pattern score

You are given 3 strings: text, pre_text and post_text. Let L be a substring of text. For each substring L of text, we define pattern_score as follows: ...
Steephen's user avatar
  • 1,250
7 votes
1 answer
2k views

Implementation of fixed size queue using a ring (cyclic) buffer

I found myself in need of a fixed size queue and decided to implement one using a ring (cyclic) buffer. I have tried my best to match the API of std::queue with ...
Emily L.'s user avatar
  • 16.6k