Split void_type into its own header and rename it to void_t

This commit is contained in:
Martin Hořeňovský 2021-10-27 19:49:46 +02:00
parent ec2d5013fb
commit f17725a186
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
4 changed files with 30 additions and 9 deletions

View File

@ -140,6 +140,7 @@ set(INTERNAL_HEADERS
${SOURCES_DIR}/catch_translate_exception.hpp ${SOURCES_DIR}/catch_translate_exception.hpp
${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp ${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp
${SOURCES_DIR}/internal/catch_unique_ptr.hpp ${SOURCES_DIR}/internal/catch_unique_ptr.hpp
${SOURCES_DIR}/internal/catch_void_type.hpp
${SOURCES_DIR}/catch_version.hpp ${SOURCES_DIR}/catch_version.hpp
${SOURCES_DIR}/catch_version_macros.hpp ${SOURCES_DIR}/catch_version_macros.hpp
${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp ${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp

View File

@ -106,6 +106,7 @@
#include <catch2/internal/catch_uncaught_exceptions.hpp> #include <catch2/internal/catch_uncaught_exceptions.hpp>
#include <catch2/internal/catch_unique_name.hpp> #include <catch2/internal/catch_unique_name.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_void_type.hpp>
#include <catch2/internal/catch_wildcard_pattern.hpp> #include <catch2/internal/catch_wildcard_pattern.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp> #include <catch2/internal/catch_windows_h_proxy.hpp>
#include <catch2/internal/catch_xmlwriter.hpp> #include <catch2/internal/catch_xmlwriter.hpp>

View File

@ -14,9 +14,11 @@
#include <type_traits> #include <type_traits>
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <catch2/internal/catch_compiler_capabilities.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_config_wchar.hpp> #include <catch2/internal/catch_config_wchar.hpp>
#include <catch2/internal/catch_stream.hpp> #include <catch2/internal/catch_stream.hpp>
#include <catch2/internal/catch_void_type.hpp>
#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp> #include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW #ifdef CATCH_CONFIG_CPP17_STRING_VIEW
@ -474,19 +476,11 @@ namespace Catch {
using std::end; using std::end;
namespace Detail { namespace Detail {
template <typename...>
struct void_type {
using type = void;
};
template <typename... Ts>
using void_type_t = typename void_type<Ts...>::type;
template <typename T, typename = void> template <typename T, typename = void>
struct is_range_impl : std::false_type {}; struct is_range_impl : std::false_type {};
template <typename T> template <typename T>
struct is_range_impl<T, void_type_t<decltype(begin(std::declval<T>()))>> : std::true_type {}; struct is_range_impl<T, void_t<decltype(begin(std::declval<T>()))>> : std::true_type {};
} // namespace Detail } // namespace Detail
template <typename T> template <typename T>

View File

@ -0,0 +1,25 @@
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_VOID_TYPE_HPP_INCLUDED
#define CATCH_VOID_TYPE_HPP_INCLUDED
namespace Catch {
namespace Detail {
template <typename...>
struct make_void { using type = void; };
template <typename... Ts>
using void_t = typename make_void<Ts...>::type;
} // namespace Detail
} // namespace Catch
#endif // CATCH_VOID_TYPE_HPP_INCLUDED