Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::full_extent_t Class Reference

tag class specifying the full extent of an mdspan More...

Public Member Functions

 full_extent_t ()=default
 explicit default constructor
 

Related Symbols

(Note that these are not member symbols.)

#define ARENE_CPP14_INLINE_VARIABLE(type, name)
 Emulates C++17's inline variable declarations for function objects.
 

Detailed Description

tag class specifying the full extent of an mdspan

Constructor & Destructor Documentation

◆ full_extent_t()

arene::base::full_extent_t::full_extent_t ( )
explicitdefault

explicit default constructor

Friends And Related Symbol Documentation

◆ ARENE_CPP14_INLINE_VARIABLE

#define ARENE_CPP14_INLINE_VARIABLE ( type,
name )
related
Value:
namespace { /* NOLINT(google-build-namespaces) explicitly want per-TU instantiations*/ \
/* NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, bugprone-macro-parentheses) */ \
ARENE_MAYBE_UNUSED constexpr auto& name = ::arene::base::detail::cpp14_inline_static_const<type>::value; \
} \
#define ARENE_MAYBE_UNUSED
An alias for [[maybe_unused]] , or a no-op if the attribute is not supported.
Definition maybe_unused.hpp:25
#define ARENE_REQUIRE_SEMICOLON
Definition require_semicolon.hpp:15

Emulates C++17's inline variable declarations for function objects.

Parameters
typeThe type of the function object to instantiate
nameThe name the instantiated object should have in the containing namespace.

This macro is used to correctly declare the instantiation of function objects in a way compatible with both C++14 and >= C++17 contexts, inspired by Eric Niebler's original paper here: https://ericniebler.com/2014/10/21/customization-point-design-in-c11-and-beyond/

In a <= C++17 context, the type is simply declared as inline constexpr type name{} . In C++14 contexts, where inline variable declarations are not permitted, the same effect is achieved by indirecting through the arene::base::detail::cpp14_inline_static_const helper template. The usage looks like so:

namespace foo {
namespace fancy_add_impl {
/// @brief A function object that adds two values.
class fancy_add {
public:
/// @brief Adds two values.
/// @tparam T The type of the values to add.
/// @param lhs The left-hand side of the addition.
/// @param rhs The right-hand side of the addition.
/// @return The result of the addition.
///
/// Note that we use the @c def and @c copydoc tags to copy the documentation of the overload and attach it to the
/// definition of the inline variable produced by the macro in order to make it display correctly in doxygen.
template <typename T>
constexpr auto operator()(T const& lhs, T const& rhs) const -> decltype(lhs + rhs) {
return lhs + rhs;
}
};
} // namespace fancy_add_impl
/// @def foo::fancy_add
/// @copydoc fancy_add_impl::fancy_add::operator()
ARENE_CPP14_INLINE_VARIABLE(fancy_add_impl::fancy_add, fancy_add);
} // namespace foo

The documentation for this class was generated from the following file: