class span<class _ElementType, size_t+ _Extent = dynamic_extent> : private pan_extent_type<_ElementType, _Extent>
I would also propose the following, which also helps readability of header files, but also solves the "namespace indentation problem" without macros, and saves you from typing prototypes twice:
- When declaring something at global scope outside of an active namespace{ block, an existing namespace name may be placed at the beginning of the identifier followed by ::. This will have the effect of inserting the declaration into that namespace as if the block had been surrounded by a namespace{ block:
class std::span<class _ElementType, size_t _Extent = dynamic_extent> : private _Span_extent_type<_ElementType, _Extent> {
This has the benefit effect that the name of the thing being declared really stands out now, and when you see the prototype, you know exactly where it is. You cannot tell at all what namespace this class is in by examining the header file as is, because:
- you'd have to look backward for a namespace declaration
- you wouldn't guess that it was inside of one because there is no indentation, because indenting for namespace blocks sucks and obscures the scope of the declaration.
- there's no namespace declaration at all! Because indentation sucks in namespace blocks, this file uses a preprocessor macro instead, _STD_BEGIN. You would have to look at the definition of this macro to figure out that span is std::span
This has no compatibility with existing code, as it is an error to do this in c++20.
Now, the name of the class, what namespace it is is prominently at the beginning, and the declaration is just plain shorter, without losing any capabilities.
There are other possibilities in the same vein:
Could:
template <typename T> concept bool HasFunc1 = requires(T t) { { t.func1() } -> int;};