Message from C, C++ discussions

December 2019

— Why someone who wants to help you should read your mind or guess what you need

— 

If you want to separate logic for different type parameters, you need to overload or use SFINAE if you want sane function to set of types
if constexpr allows you to make logic of templated function in one place without making several SFINAE overloads

— Or you can separate logic to some "impl" template functions (without SFINAE logic) and select which function to call in main function with help of if constexpr

Message permanent page

— I hope it makes sense

— The program doesnt print the total cost of a function

https://pastebin.com/fpkic6gL

— Like

private: TheFunc();
public:
void Func()
{
if constexpr (template_bool_param)
TheFunc();
else
:/ idk
}


Or based on this idea

void Func()
{
static_assert(t_bool_param,
"Func not defined"
);
TheFunc();
}

Message permanent page

— Or even more const's 😬

constexpr void Func()
{
static_assert(t_bool_param,
"Func not defined"
);
TheFunc();
}

Message permanent page

— So I guess I'll implement a private function with a separate template parameter and use this, so that there is a block to write static_assert in it!
Hope the compiler to be happy with this
Thanks a lot! unterumarmung

Message permanent page

— Hello guys

— Else is not obligatory, is it?

— Else the function should warn user that it doesn't exist

— Why isn't gnome-shell memory leak fixed yet 🤦🏻‍♀
I can't do anything because of that