File indexing completed on 2025-01-18 09:54:05
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
0009 #define CATCH_CONTAINER_NONMEMBERS_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_compiler_capabilities.hpp>
0012
0013 #include <cstddef>
0014 #include <initializer_list>
0015
0016
0017
0018
0019
0020 #if defined(CATCH_CPP17_OR_GREATER) || defined(_MSC_VER)
0021
0022
0023
0024
0025 #include <string>
0026
0027 # if !defined(__cpp_lib_nonmember_container_access)
0028 # define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
0029 # endif
0030
0031 #else
0032 #define CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS
0033 #endif
0034
0035
0036
0037 namespace Catch {
0038 namespace Detail {
0039
0040 #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS)
0041 template <typename Container>
0042 constexpr auto empty(Container const& cont) -> decltype(cont.empty()) {
0043 return cont.empty();
0044 }
0045 template <typename T, std::size_t N>
0046 constexpr bool empty(const T (&)[N]) noexcept {
0047
0048
0049 (void)N;
0050 return false;
0051 }
0052 template <typename T>
0053 constexpr bool empty(std::initializer_list<T> list) noexcept {
0054 return list.size() > 0;
0055 }
0056
0057
0058 template <typename Container>
0059 constexpr auto size(Container const& cont) -> decltype(cont.size()) {
0060 return cont.size();
0061 }
0062 template <typename T, std::size_t N>
0063 constexpr std::size_t size(const T(&)[N]) noexcept {
0064 return N;
0065 }
0066 #endif
0067
0068 }
0069 }
0070
0071
0072
0073 #endif