stdshims.h 657 B

12345678910111213141516171819202122232425262728293031
  1. //! Shims for std:: functions that aren't available in the current C++ versions
  2. //! we target.
  3. #ifndef STDSHIMS_H
  4. #define STDSHIMS_H
  5. #include <type_traits>
  6. #include <utility>
  7. #if (__cplusplus >= 201703L || _MSC_VER >= 1914)
  8. #ifndef _MSC_VER
  9. #warning "This part of this file should now be removed! The functions it provides are part of the C++17 standard."
  10. #endif
  11. using std::as_const;
  12. #else
  13. /// Shim for http://en.cppreference.com/w/cpp/utility/as_const
  14. template <typename T>
  15. constexpr typename std::add_const<T>::type& as_const(T& t) noexcept
  16. {
  17. return t;
  18. }
  19. template <typename T>
  20. void as_const(const T&&) = delete;
  21. #endif
  22. #endif // include guard