Here is simple example of using std::function In the main function, there are three function calls. The first one and the last one works. Whereas t ...
Here is simple example of using std::function In the main function, there are three function calls. The first one and the last one works. Whereas t ...
I want to create this function: However, I get that the identifier "tortuga" is undefined. I tried to modify the function like this: I get that ...
I am pretty new to std::variant and C++17 feature. I know that variant can store multiple types, but maybe it would not allow the user defined templat ...
I am implementing a Monte Carlo simulation, where I need to run multiple realisations of some dynamics and then take an average over the end state for ...
I need to hook into C++'s exception throwing mechanism like this: If you're wondering "Why would you do that?" I have this simple example of throw ...
I see this post: c++ - Why doesn't std::string_view have assign() and clear() methods? - Stack Overflow, so string_view does not contain clear functio ...
I have a code. The code prints 1236 (g++ 7.5.0) Does the output depend on the compiler? (e.g. output can be 3216) ...
The instructor in the C++ course I'm following used this code here, and I copied it exactly:Code the course instructor used But I get this error. Not ...
If I have a map like But if i invoke std::get<string>(m[1]) by mistake instead of std::get<int>(m[1]), it will raise bad_variant_access ...
I want to have a map to save different types of value, so I have a map like And Now I want to design a function to get the value by its key like ...
I have a class Foo that can be constructed from C-style strings, string views and non-temporary strings (in reality it contains other members and meth ...
I can find surprisingly little useful information about how an overridden std::streambuf::overflow function should look like to simply get each charac ...
How can I specialized a template function to return true if objects belong to certain templates/classes and false for other templates/classes no class ...
I know that need mutex when try to delete an element from a vector. so, I wrote a sample code to check this. If I proceed with erase() without usi ...
I have a std::tuple< std::optional<Args> ... >, need to check that every element has a value. I have implemented it with std::index_sequen ...
I have a Base class, and a Derived template that inherits from it. Both of these define a static method calculateSize() but with different method sign ...
I'm not sure what I want to achieve is possible, but I need my templated function (my_func) to be able to take both variable arguments as well as a tu ...
I have a struct like: Now I want to initialize the struct using initializer list as following: However, this doesn't work. How do I initialize t ...
I'm new to C++. I am initializing a class object Node in another class LCache. When I try to compile my code, I get the following error: Line 22: Cha ...
Is it possible to get the captured values of a lambda without using std::function? I'm asking because I want to place the captured copies into my own ...