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
1 vote
1 answer
68 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-...
user avatar
2 votes
1 answer
40 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 ...
user avatar
  • 21
2 votes
2 answers
81 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 ...
user avatar
  • 225
6 votes
5 answers
1k 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: ...
user avatar
1 vote
1 answer
52 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 ...
user avatar
  • 141
2 votes
1 answer
74 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 ...
user avatar
2 votes
1 answer
123 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) \\ &...
user avatar
  • 123
2 votes
4 answers
969 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 ...
user avatar
3 votes
4 answers
153 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* ...
user avatar
0 votes
2 answers
69 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,...
user avatar
4 votes
1 answer
126 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 ...
user avatar
  • 185
4 votes
3 answers
585 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 ...
user avatar
6 votes
4 answers
529 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: <...
user avatar
  • 225
3 votes
1 answer
90 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 ...
user avatar
  • 225
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 ...
user avatar
  • 233
0 votes
2 answers
213 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 ...
user avatar
  • 103
4 votes
1 answer
178 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 ...
user avatar
  • 962
5 votes
1 answer
163 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 ...
user avatar
0 votes
3 answers
570 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 ...
user avatar
  • 17
0 votes
3 answers
76 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 ...
user avatar
1 vote
1 answer
86 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 ...
user avatar
3 votes
1 answer
112 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 ...
user avatar
9 votes
3 answers
4k 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 ...
user avatar
5 votes
1 answer
326 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 ...
user avatar
3 votes
2 answers
1k 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. ...
user avatar
2 votes
1 answer
693 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. ...
user avatar
2 votes
1 answer
81 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 ...
user avatar
  • 121
7 votes
0 answers
149 views

Implementing GSL synchronized_value

Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
user avatar
5 votes
1 answer
171 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: ...
user avatar
  • 369
2 votes
1 answer
101 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 ...
user avatar
3 votes
1 answer
5k 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 ...
user avatar
2 votes
1 answer
106 views

Generate binary image using coordinate vectors

I have a matrix M of size [n_rows, n_cols] and a list of x and ...
user avatar
  • 1,003
4 votes
2 answers
238 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 ...
user avatar
  • 53.4k
5 votes
2 answers
131 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 ...
user avatar
22 votes
11 answers
10k 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; ...
user avatar
3 votes
1 answer
98 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) ...
user avatar
2 votes
1 answer
840 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 ...
user avatar
  • 375
3 votes
1 answer
96 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 ...
user avatar
  • 53
2 votes
1 answer
266 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 ...
user avatar
  • 123
4 votes
1 answer
170 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 ...
user avatar
  • 141
4 votes
1 answer
229 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 ...
user avatar
  • 962
3 votes
1 answer
447 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? ...
user avatar
2 votes
1 answer
121 views

Subset Component Task

I've solved a problem Subset Component Problem You are given an array with n 64-bit integers: d[0],d[1],….,d[n-1]. ...
user avatar
  • 962
2 votes
1 answer
95 views

Generic Type Trait example

I want to check that a some type has some methods: ...
user avatar
5 votes
2 answers
147 views

BrainF**k interpreter in C++

This question is the adaptation of this question in C++. (I'm the author of that code as well). The code: ...
user avatar
  • 2,710
3 votes
1 answer
150 views

Cave Setup for Hunting the Wumpus

I am a hobbyist programmer trying to learn modern C++. My son had an assignment in his C++ class to fill in some functions that populate draw the cave in the "hunt for the wumpus" game. When I viewed ...
user avatar
  • 447
17 votes
5 answers
12k views

Banking system in C++

I've created a program for Banking System in C++14. You are given 9 options: Open Account Close Account Show All Accounts Deposit in Account Withdraw from Account Transfer to an Account Show Balance ...
user avatar
  • 2,710
4 votes
0 answers
122 views

Tic Tac Toe with different level AI

I've already created a code in python here with almost the same logic: Tic-Tac-Toe with changeable board size (Part 1) Tic-Tac-Toe with changeable board size (Part 2) Here's the code in C++. As I'm ...
user avatar
  • 2,710
2 votes
1 answer
219 views

Prim's Algorithm - Minimum Spanning Tree

I have implemented Prim's Algorithm from Introduction to Algorithms. I have observed that the code is similar to Dijkstra's Algorithm, so I have used my Dijkstra's Algorithm implementation. Please ...
user avatar
  • 2,449
2 votes
0 answers
62 views

A lightweight version of std::shared_ptr<T> V2

This is a lightweight version of std::shared_ptr<T> called res_ptr<T> This post is a continuation of: A lightweight ...
user avatar
  • 2,134

1
2 3 4 5
10