I'm trying to meter std::function< > into a std::set< > . For this, we need a function that compares the values entered.
As std::function does not provide any comparison operator, I thought about this:
I'm using templates in C ++ and I'm new to this, so I do not quite understand how to "reuse" functions regardless of the type of data.
I have the code shown below:
const T &min(const T &a, const T &b)...
How the compiler resolves the case in which it can substitute more than one template and does not give ambiguity using the SFINAE principle.
template<typename T, typename U>
U cast(T x)...
I have this code in which I try to approximate the natural logarithm of a number, but I can not use if , while or for , only the if ternario, but at the time it compiles I'm shot errors that T is ambiguous and th...
I have a simple program that uses a variable template of type std::initializer_list that stores pairs that contain a type and a text:
using name_t = const char *;
template <typename key_t>
using key_name_t = std::pair<key_t, n...
I want to extract a data from a class; Currently, I use an auxiliary variable for it.
To work, it works ... but I was wondering if it could be done in another way, saving me the variable inside the function Envoltura::result( ) :
I'm doing a program in C ++ that overload the operators. For example, for the operator * you would like it to be multiplied:
Triangulo x= a * b * c
I have created the operation Cuad...
I am creating a method member of a class, that allows me to receive an object and save the information of the object in a file.
Specifically, I need to save three objects that are derived fro...
A design pattern not very well known is the PassKey pattern that is used mainly to restrict access to certain public functions (the option would be to use friend in the main classes and that produces too much coupling).
A basic implementation...