Why can you implement std::is_function in terms of std::is_const and std::is_reference?

Let’s go over the conditions as they appear: If const T isn’t const (const doesn’t really apply to function types since functions aren’t objects), and T isn’t a reference (const doesn’t apply to references either for the same reason), it’s a function type. int (or any other non-function-non-reference type) wouldn’t fit in because is_const<const int>::value … Read more

When to use std::invoke instead of simply calling the invokable?

If the invocable is a pointer to a member function, then you need to do one of these: (arg1->*f)(arg2,…); (arg1.*f)(arg2,…); Depending on what arg1 is. INVOKE (and its official library counterpart std::invoke) was pretty much designed to simplify such messes. You’d use std::invoke to support the caller of your code passing any callable, and not … Read more

std::mem_fun vs std::mem_fn

std::mem_fun is deprecated. std::mem_fn can do everything it does, and it does it more conveniently. The relation between the two is the same as the relation between std::bind1st/std::bind2nd and the C++11 std::bind. Both std::mem_fn and std::bind were developed and mastered after std::bind1st and std::mem_fun were made into the C++98 Standard. So that means we had … Read more

What is the difference between using a struct with two fields and a pair?

std::pair provides pre-written constructors and comparison operators. This also allows them to be stored in containers like std::map without you needing to write, for example, the copy constructor or strict weak ordering via operator < (such as required by std::map). If you don’t write them you can’t make a mistake (remember how strict weak ordering … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)