In my work's codebase, I see the following
class custom {
auto set_data_type(custom_type_t type_t) -> custom & {
// set some stuff
// return *this;
}
}
Why can't we simply just do
class custom {
custom & set_data_type(custom_type_t type_t) {
// set some stuff
// return *this;
}
}
What is the point of using auto in this case when you already know the return type and already wrote it out in the ->... place?
It seems auto would only be beneficial if it is used with decltype(arg) and where arg may have varying return types?
I would say style.
Moreover, it allows to be consistent in any contexts,
decltype(arg), scoping(-> iteratorinstead oftypename C::iterator)