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

Improved input validation function

A week ago I posted this question and after reading the answers and accepting one I decided to refactor my code quite heavily. I would like to get some feedback on this newer version. The changes No ...
globalturist's user avatar
2 votes
3 answers
164 views

Making an input validator function

NOTICE: I refactored the code and made a new question like was advised. I'm making an input validator function that is inspired by @JDługosz from the following post so that other new C++ programmers ...
globalturist's user avatar
3 votes
1 answer
127 views

Custom single-header C++ logging library

I started learning C++ recently for game development, and decided to write my own little library for debugging. Here is the library (snoop.hpp) ...
Marc's user avatar
  • 33
2 votes
1 answer
60 views

Force acquiring R/W lock

I am trying to build an abstraction that forces lock acquisition before data can be accessed. This seems to work, but please tell me if what I am doing horribly wrong, and what I could improve. I am ...
optimistic's user avatar
3 votes
2 answers
355 views

Concurrent Handle Table

I'm writing a data structure to solve a problem related to servicing hardware interrupts. I have to translate a 64-bit pointer to a 16-bit handle and back again. Unfortunately the hardware completions ...
BlamKiwi's user avatar
  • 181
1 vote
1 answer
418 views

Make C++ Task class similiar to C#'s Task

I am enjoying making various programs with C++. This is my first code review request. And I hope I can get some insights or might have good advice to make my code better. I make a task class using C++...
Y.frank's user avatar
  • 29
4 votes
3 answers
307 views

Optimize memory and disk usage for sequences of n-bit values

Motivation: I am working with sequences of n-bit values coming from an ADC. I was initially using a std::vector<unsigned short> to store these values (12 bit ...
lobis's user avatar
  • 61
9 votes
1 answer
1k views

Porting C-style socket to CPP class

I am porting the C-style socket to design a simple wrapper around the telnet client in CPP. The telnet protocol is accomplished by using libtelnet in C. The C-style code for this wrapper is reviewed ...
ravi's user avatar
  • 429
1 vote
1 answer
128 views

Simple networking framework in C++

Question: What do you think about this design and the implementation? This is a simple networking framework for IPv4, IPv6 TCP client and TCP server for Linux and MS-Windows in C++14. It uses a single-...
Andre Adrian's user avatar
2 votes
1 answer
465 views

Binding move-only objects to functions (for a thread pool implementation)

I recently implemented a thread pool using std::functions. I only supported functions taking no arguments on the assumption that there would be no need to have them ...
jezza's user avatar
  • 205
2 votes
2 answers
175 views

Nop class which can get optimized away

I designed a class for debug builds which does not incur any overhead in release mode. A usecase is for example: I have a function and I want to count how often it is called. For this I could write ...
tommsch's user avatar
  • 243
6 votes
5 answers
2k views

TString - An implementation of std::string

I wanted to make a feature rich string in C++. Similar to one in python. I am using C++14. I have not added much yet, I just want to get my code reviewed to ensure I am going the right way. Features: ...
Random_Pythoneer59's user avatar
1 vote
1 answer
92 views

One-time dynamic, many-time *almost* static type dispatch

Annoyed at the tension between good software design principles that require well-defined delimitations between interface and implementations, and the requirements for critical code to run fast, which ...
lurscher's user avatar
  • 141
2 votes
1 answer
181 views

C++ template and inheritance - Generic Sqrt Decomposition

So I tried implementing a easily extendable solution for Sqrt decompostion, I deduced that only identity value, operation and block update logic change and rest of the code is same. So i created 3 ...
Abhay Raj Singh's user avatar
2 votes
1 answer
254 views

Simple Lagrange interpolation

I wrote a Lagrange polynomial interpolation class. It works fine. At the beginning some definitions: $$ \begin{align} &nodes:\qquad x_0, \dots, x_n \\ &values:\qquad f(x_0), \dots, f(x_n) \\ &...
Interpolated's user avatar
2 votes
4 answers
1k views

Fantasy Character Creation Tool (early prototype)

I recently started studying C++ programming; while attending the course I'm writing a program on the side as a personal project to familiarize with what I'm learning. It is still very basic and I'm ...
Davide Marchi's user avatar
3 votes
4 answers
473 views

Improving my implementation of a unique_ptr - PPP Stroustrup book

This question is an improvement of this one here: Implementing a unique_ptr - PPP Stroustrup exercise Here's my new code, following the suggestions by @JDługosz. I agree with the fact that T* ...
bobinthebox's user avatar
0 votes
2 answers
137 views

Implementing a unique_ptr - PPP Stroustrup exercise

I'm doing the following exercise from PPP - Bjarne Stroustrup, Chapter 19, ex.10. Implement a simple unique_ptr supporting only a constructor, destructor,...
bobinthebox's user avatar
4 votes
1 answer
155 views

Nullable array wrapper class with small size optimization

I have an array wrapper class that I'd like to get reviewed. There are two differences with other common questions on this site. First, my class needs to be "nullable", where a "null ...
thc's user avatar
  • 185
4 votes
3 answers
614 views

Compute shortest path in undirected graph

In a recent coding interview I was asked to write a program which takes as input two text lines: The first one represents a graph, formatted as a sequence of undirected edges like ...
InfiniteSnow's user avatar
6 votes
4 answers
1k views

Packing and unpacking values in a buffer

I have to deal with raw memory manipulation. For that I wrote a function which stores data one after another, and another function which reads this data and stores it into variables. More precisely: <...
tommsch's user avatar
  • 243
3 votes
2 answers
438 views

Fixed Point Type

I am implementing a fixed point type, which mostly is used to be able store numbers as multiples of some base (power of 2). Apart from that, the type should be able to replace double/float values ...
tommsch's user avatar
  • 243
13 votes
1 answer
1k views

Simple NAPI wrapper around self written C++ msgpack, horrible performance

I have written a relatively small msgpack implementation in C++, with performance that is not too bad, so I decided to write a NAPI wrapper around it, but the performance is just horrible. I am ...
t348575's user avatar
  • 233
0 votes
2 answers
269 views

C++ Simple Shared Pointer Implementaion

I wrote an implementation of a shared pointer. I would like a review of it. It seems to work, but running it through Valgrind shows that that it leaks memory somewhere in my tests, but I don't know ...
Ragov's user avatar
  • 103
4 votes
1 answer
286 views

Contacts programming challenge

I successfully solved a problem on Hackerrank called Contacts, but I'm curious if my code in C++ looks good to C++ developers. If not, how it should be improved. Below is the short description of the ...
Anatolii's user avatar
  • 982
5 votes
1 answer
341 views

lazy_map implementation in C++ | Similar to unordered_map but O(1) copyable

I implemented lazy_map - https://github.com/tinytrashbin/lazy_map. Can someone help with reviews ? lazy_map is an implementation of unordered_map that has O(1) cost of copying irrespective of the ...
Mohit Saini's user avatar
0 votes
3 answers
1k views

sorting vector of pair in efficient way

I'm trying to solve the sorting problem but I always get TLE(Time Limit Exceeded/ 1s) so... can you guys suggest a more efficient way to solve this problem? (i can't link the exercise because it is on ...
Blue339's user avatar
  • 19
0 votes
3 answers
96 views

Reversing an array in C++ 14, my second array requires an extra element

Hackerrank problem to reverse an array of size n. https://www.hackerrank.com/challenges/30-arrays/ Sample Input: 4 1 4 3 2 ...
Shashank V M's user avatar
1 vote
1 answer
167 views

The Next Palindrome - CodeChef

This is codechef beginner problem. How I can make it efficient, It is taking 2.09 sec while time limit is 2.0764 secs. Problem is: For a given positive integer K of not more than 1000000 digits, write ...
Javed I.'s user avatar
3 votes
1 answer
261 views

Solving Tents puzzles using a SAT solver

I built a solver for Tents puzzles using the CaDiCaL SAT solver. The code works and runs quickly, it takes less than 0.1 seconds for a ...
raskolnikov's user avatar
9 votes
3 answers
5k views

A Tic Tac Toe game in C++

I am a beginner programmer and have made a tic tac toe program in c++. I need some help with my memory management can anyone review and help me. This is my code ...
Vedant Matanhelia's user avatar
5 votes
1 answer
473 views

Using Euler-Maruyama method to solve Ornstein-Uhlenbeck equation (SDE)

I am trying to implement the Euler–Maruyama method and use it to solve the Ornstein–Uhlenbeck process. I am basing my code on the wikipedia page where a python implementation is shown. More generally ...
Iwan Phillips's user avatar
3 votes
2 answers
3k views

Reactor pattern in modern C++. Please comment on coding improvements to be done

The reactor possesses its own thread to wait for messages in an event loop. Users should be able to start or stop the reactor at any point. These two operations are not required to be thread-safe. ...
Vijayendar Sridharan's user avatar
2 votes
1 answer
2k views

Implementing toggle button using Qt

I have below code for implement toggle button. After including below code, processing power consumed over 90% in my embedded application. Is there any way to reduce this processing power. ...
user3559721's user avatar
2 votes
1 answer
86 views

Code to sort based on quantities of a data member occuring

The setup is that I have a vector of a class, and I need to sort it by the quantity of a data member value, not the value itself. The below code exhibits the correct behavior, and part of that ...
sweenish's user avatar
  • 121
8 votes
0 answers
326 views

Implementing GSL synchronized_value

Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
Sergey Kolesnik's user avatar
5 votes
1 answer
174 views

Meta functions for sequences of exponents of 2

I have implemented some meta functions to create sequence for exponents of 2. I would love to know if there is any way to make the code more optimized. Note: ...
starrk's user avatar
  • 369
2 votes
1 answer
129 views

C++ reactor bad implementation

folks. I have recently started writing software using Modern C++ 11-14. I have been developing software for more than a decade and just wanted to broaden my skillset. I am practicing building some ...
slaventos's user avatar
3 votes
1 answer
10k views

Simple C++ Telegram Bot

Hi :) I am a beginner coder who just learnt C++ and I wanted to apply it in projects to solidify my learning process. However, I only took a short tutorial before trying this out hence I'm pretty ...
Jess Lim's user avatar
2 votes
1 answer
170 views

Generate binary image using coordinate vectors

I have a matrix M of size [n_rows, n_cols] and a list of x and ...
Gilfoyle's user avatar
  • 1,125
4 votes
2 answers
323 views

Benchmarking insertion sort

More than once I claimed that using binary search doesn't improve performance of the insertion sort. For example, see answer here and comments here). Now I have time to substantiate my claim. The ...
vnp's user avatar
  • 55.9k
5 votes
2 answers
147 views

Rolling median function (Daily Coding Problem 377)

Given an array of numbers arr and a window of size k, print out the median of each window of size k starting from the left and moving right by one position each time. For example, given the ...
Furch Radeon's user avatar
23 votes
11 answers
11k views

Find nth Fibonacci Number, using iteration and recursion

I'm a beginner programmer and I came upon this problem which is to find the n​th number in the Fibonacci series. I used to solve the problem using a for loop; ...
David Peterson's user avatar
3 votes
1 answer
600 views

Substitution Cipher: Which One?

I'm a beginner and I have a question (somehow silly and stupid :) ). Today I decided to challenge myself and I came around the challenge that wanted me to create a program that ciphers (or encrypts) ...
David Peterson's user avatar
2 votes
1 answer
1k views

Get word frequency of a txt file and save it to linked list

I'm a novice in C++. I want to do three things: Get the number of lines in the file Get the number of total words in the file Get each frequency of each "unique ...
gust's user avatar
  • 375
4 votes
1 answer
122 views

Unique and shared resource owner

I need a unique_ptr and shared_ptr like structure, but instead of pointers, I would like to store some kind of reference to a ...
Adam's user avatar
  • 63
2 votes
1 answer
524 views

Header only HTTP client library that is a wrapper around CURL

For learning purposes, I wanted to create a header-only C++ wrapper library around HTTP CURL functionality. At the moment the library only implements GET and POST, but I will add other HTTP methods ...
sptrks's user avatar
  • 123
4 votes
1 answer
448 views

Signal slot mechanism in C++14

Implementing signal slot mechanism again seems quite dumb because there are so many people already done this before but it is for learning and I intended some specific goals. I had some library in ...
Gustavo's user avatar
  • 141
4 votes
1 answer
290 views

Find positive integer with a minimum number of binary 1's such that its bitwise AND with all array elements is not 0

Task You have an array of positive integers. Your task is to find an integer x such that the following are true: Bitwise AND between ...
Anatolii's user avatar
  • 982
3 votes
1 answer
752 views

Matrix class with overloaded `operator[]`

I have implemented a Matrix class that allocates memory using unique_ptr. How to make it more diverse and optimized in terms of memory usage and efficiency? ...
Mayukh Sarkar's user avatar

1
2 3 4 5
10