Questions tagged [c++14]
Code that is written to the 2014 version of the C++ standard. Use in conjunction with the 'c++' tag.
472
questions
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-...
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 ...
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 ...
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:
...
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 ...
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 ...
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) \\
&...
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 ...
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* ...
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,...
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 ...
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 ...
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:
<...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
...
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 ...
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 ...
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
...
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 ...
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.
...
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.
...
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 ...
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'...
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 nth number in the Fibonacci series.
I used to solve the problem using a for loop; ...
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) ...
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 ...
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 ...
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 ...
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 ...
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 ...
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?
...
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].
...
2
votes
1
answer
95
views
Generic Type Trait example
I want to check that a some type has some methods:
...
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:
...
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 ...
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
...
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 ...
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 ...
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 ...