diff --git a/include/stdshims.h b/include/stdshims.h index 5eee6543cac..c12254e1506 100644 --- a/include/stdshims.h +++ b/include/stdshims.h @@ -5,11 +5,12 @@ #define STDSHIMS_H #include +#include #include #if (__cplusplus >= 201402L || _MSC_VER) #ifndef _MSC_VER -#warning "This file should now be removed! The functions it provides are part of the C++14 standard." +#warning "This part of this file should now be removed! The functions it provides are part of the C++14 standard." #endif using std::make_unique; @@ -30,5 +31,24 @@ std::unique_ptr make_unique(Args&&... args) } #endif +#if (__cplusplus >= 201703L || _MSC_VER >= 1914) +#ifndef _MSC_VER +#warning "This part of this file should now be removed! The functions it provides are part of the C++17 standard." +#endif +using std::as_const; + +#else + +/// Shim for http://en.cppreference.com/w/cpp/utility/as_const +template +constexpr typename std::add_const::type& as_const(T& t) noexcept +{ + return t; +} + +template +void as_const(const T&&) = delete; +#endif + #endif // include guard diff --git a/src/gui/widgets/ControlLayout.cpp b/src/gui/widgets/ControlLayout.cpp index afd4e68e42e..ce2e9e4ef9b 100644 --- a/src/gui/widgets/ControlLayout.cpp +++ b/src/gui/widgets/ControlLayout.cpp @@ -73,6 +73,8 @@ #include "ControlLayout.h" +#include "stdshims.h" + #include #include #include @@ -208,7 +210,7 @@ QSize ControlLayout::minimumSize() const // get maximum height and width for all children. // as Qt will later call heightForWidth, only the width here really matters QSize size; - for (const QLayoutItem *item : qAsConst(m_itemMap)) + for (const QLayoutItem *item : as_const(m_itemMap)) { size = size.expandedTo(item->minimumSize()); }