Category "c++14"

How to print a n-dimensional c++ STL container? Container is array of arrays or vectors of vectors

I have a code where I want to display tensor represented as vectors of vectors or std::arrays of std::arrays. The intention is to print them the way numpy print

How to create a simple version of std::function class

Suppose that I want to create a simple version ofstd::function, which has following behaviors: 1. function(){} -> A void constructor 2. function(_ReturnType,

How to store every sequentially increasing sequence in a vector into new vectors

I have a vector with the following elements: std::vector<int> vectorOfInts{ 95, 137, 138, 139, 140, 156, 157, 158, 159 }; Problem: I'm trying to store eac

Find the number of steps a string can be reduced to 0

My assignment: You are given a non-negative integer variable $Z$. There are two actions available that can change its value: if $Z$ is odd, subtract 1

Lvalue-to-rvalue conversion for class types: is there copying involved?

(I asked this question before but didn't give a viable example so I deleted previous one. I hope on this one I got the example right.) Case: #include <iostre

How to avoid the need to specify deleter for std::shared_ptr every time it's constructed or reset?

std::unique_ptr has 2 template parameters, the second of which is the deleter to be used. Thanks to this fact, one can easily alias a unique_ptr to a type, whic

The procedure entry point _ZNSt7_cxx1112basic_stringlcSt11char_traitslcESalcEEC1Ev could not be located in the dynamic link library

I am having immense difficulty trying to use std::string. The program compiles absolutely fine, but when I run the program, I receive this error: error I have

Algorithm to convert std::stack to std::string in C++ STL

In below C++ program I'm deleting a previous character considering '#' as a backspace character. I have used stack to build the string. Is there any C++ STL alg

Basic forward list using unique_ptrs

As an exercise in learning C++, I want to build my own forward list using raw pointers and using unique_ptrs. Using raw pointers, I have: struct node_raw {

How undefined are __builtin_ctz(0) or __builtin_clz(0)?

Background For a long time, gcc has been providing a number of builtin bit-twiddling functions, in particular the number of trailing and leading 0-bits (also f