Date: Tue, 19 Jan 2021 15:35:56 +0100
Hi!
I'd like to propose a new attribute to change the default specifiers and
qualifiers in a given scope.
Often there's a lot of boilerplate code involved because the default
specifiers and qualifiers are not the "correct" ones (stress on the
quotation marks).
So we need to explicitly make variables const, functions const, noexcept or
final, etc.
It would be a lot simpler to have a way to switch the default specifiers
and qualifiers, making them more permissive or stricter.
The idea is to create an attribute that would apply to a scope. With that,
we won't mess with back-compatibility and it would allow an easy migration
towards the new standard.
Furthermore, it would help to enforce some good practices like
const-correctness.
For example, the following two codes will be the same.
namespace example [[strict]] {
class Foo : public Bar
{
void do_it(double *ptr) override
{
int x = /* some initialization code here*/
/* more code here */
}
};
}
namespace example {
class Foo final : public Bar
{
void do_it(double * __restrict ptr) const noexcept override final
{
const int x = /* some initialization code here*/
/* more code here */
}
};
}
I'd like to propose a new attribute to change the default specifiers and
qualifiers in a given scope.
Often there's a lot of boilerplate code involved because the default
specifiers and qualifiers are not the "correct" ones (stress on the
quotation marks).
So we need to explicitly make variables const, functions const, noexcept or
final, etc.
It would be a lot simpler to have a way to switch the default specifiers
and qualifiers, making them more permissive or stricter.
The idea is to create an attribute that would apply to a scope. With that,
we won't mess with back-compatibility and it would allow an easy migration
towards the new standard.
Furthermore, it would help to enforce some good practices like
const-correctness.
For example, the following two codes will be the same.
namespace example [[strict]] {
class Foo : public Bar
{
void do_it(double *ptr) override
{
int x = /* some initialization code here*/
/* more code here */
}
};
}
namespace example {
class Foo final : public Bar
{
void do_it(double * __restrict ptr) const noexcept override final
{
const int x = /* some initialization code here*/
/* more code here */
}
};
}
Received on 2021-01-19 08:36:11