Use std::as_const (C++17 feature)

This commit is contained in:
Mat Sutcliffe
2021-04-17 22:21:18 +01:00
parent 6d617f40a4
commit 33209fa1eb
42 changed files with 92 additions and 103 deletions

View File

@@ -27,18 +27,6 @@ namespace BlackMisc
{
template <class> class CRange;
/*!
* Own implementation of C++17 std::as_const. Adds const to any lvalue.
* Useful with non-mutating range-for loops to avoid unnecessary detachment of Qt implicitly shared containers.
* Does not allow rvalues, as that could easily lead to undefined behaviour.
*/
//! @{
template <class T>
constexpr std::add_const_t<T> &as_const(T &v) noexcept { return v; }
template <class T>
void as_const(const T &&) = delete;
//! @}
/*!
* Any container class with begin and end iterators can inherit from this CRTP class
* to gain some useful algorithms as member functions.