Beginners - June 2024

by zzzhhh
Why is const gone in the return type?
 
template <typename T> const T&& Test(T&& t) { return t; } ...... int i = 0; int&& irr = std::move(i); decltype(Test(irr)) t = i; Since there is a `const` ...
[5 replies] Last: @Peter87: Thank you for referring me to the relevant Standard. I think... (by zzzhhh)
Convert binary to base 58
 
I want to convert a long binary number, 256 bits, into a base 58 char array using c code. I cannot find a simple explanation. The Bing tool insists on convert...
[10 replies] Last: I get the same result on those 2 sites (dcode only accepts decimal inp... (by DizzyDon)
by Ch1156
Best way to modify a variable in a class (1,2,3,4)
 
So whats the best way to modify a variable in a class? Below I have a version that does so through a pointer, but is it better to just make a function that modi...
[63 replies] Last: I suggest you look into OOP class design using UML etc. This will give... (by seeplus)
Finding minimum element of a tuple on the basis of first element
 
Hello everyone, I do not know, if it is possible to find the minimum first element in a tuple without using sort function. I have a tuple like this : data=[...
[5 replies] Last: I have a tuple like this : data=[ ( 23, a, 3.78, d), ( 11, x, 5.8, w)... (by seeplus)
by zzzhhh
Which ctor of std::unique_ptr is used, when there is a user-defined deleter which is a function?
 
Following is excerpted from section 12.1.5 of text "C++ Primer", which contains text and code constructing `std::unique_ptr` with a user-defined deleter which i...
[1 reply] : The code calls constructor 3 or 4. When the cppreference page writes ... (by Peter87)
txt file to vector giving wrong values
 
I'm loading a txt file into a vector using the code I've written below. It works great except for one BIG issue i'm having. First I'll give a very small exampl...
[11 replies] Last: There's a good (and free) set of C++ tutorials and lessons available o... (by deleted account xyzzy)
by zzzhhh
Why can't assign an overloaded function to std::function?
 
int add(int i, int j) { return i + j; } std::string add(const std::string& s1, const std::string& s2) { return s1 + s2; } ... std::function<int(int, int)>...
[1 reply] : There is a constructor template and a class template in play here, and... (by mbozzi)
  Archived months: [may2024] [jul2024]

This is an archived page. To post a new message, go to the current page.