mirror of
https://github.com/spnda/dds_image.git
synced 2026-01-10 15:29:28 +01:00
Fix: Test _MSVC_LANG macro for C++17/20 support
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus >= 201703L && defined(DDS_USE_STD_FILESYSTEM)
|
||||
#include "dds_formats.hpp"
|
||||
|
||||
#if DDS_CPP_17 && defined(DDS_USE_STD_FILESYSTEM)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 202002L
|
||||
#if DDS_CPP_20
|
||||
#include <concepts>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "dds_formats.hpp"
|
||||
|
||||
namespace dds {
|
||||
// Not going to include <algorithm> just for std::max and std::min
|
||||
template <typename T>
|
||||
#if __cplusplus >= 202002L
|
||||
#if DDS_CPP_20
|
||||
requires std::is_arithmetic_v<T>
|
||||
#endif
|
||||
inline constexpr const T& max(const T& a, const T& b) {
|
||||
@@ -25,7 +25,7 @@ namespace dds {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
#if __cplusplus >= 202002L
|
||||
#if DDS_CPP_20
|
||||
requires std::is_arithmetic_v<T>
|
||||
#endif
|
||||
inline constexpr const T& min(const T& a, const T& b) {
|
||||
@@ -294,7 +294,7 @@ namespace dds {
|
||||
}
|
||||
#endif // #ifdef VK_VERSION_1_0
|
||||
|
||||
#if __cplusplus >= 201703L && defined(DDS_USE_STD_FILESYSTEM)
|
||||
#if DDS_CPP_17 && defined(DDS_USE_STD_FILESYSTEM)
|
||||
DDS_NO_DISCARD inline dds::ReadResult readFile(const fs::path& filepath, dds::Image* image) {
|
||||
#else
|
||||
DDS_NO_DISCARD inline dds::ReadResult readFile(const std::string& filepath, dds::Image* image) {
|
||||
|
||||
@@ -7,15 +7,26 @@
|
||||
static_cast<uint32_t>(char1) | (static_cast<uint32_t>(char2) << 8) | (static_cast<uint32_t>(char3) << 16) | \
|
||||
(static_cast<uint32_t>(char4) << 24)
|
||||
|
||||
#define UNDO_FOUR_CHARACTER_CODE(x, name) \
|
||||
std::string name; \
|
||||
name.reserve(4); \
|
||||
name.push_back(x >> 0); \
|
||||
name.push_back(x >> 8); \
|
||||
name.push_back(x >> 16); \
|
||||
name.push_back(x >> 24);
|
||||
#define UNDO_FOUR_CHARACTER_CODE(x, name) \
|
||||
unsigned char name[4]; \
|
||||
name[0] = x >> 0; \
|
||||
name[1] = x >> 8; \
|
||||
name[2] = x >> 16; \
|
||||
name[3] = x >> 24;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
||||
#define DDS_CPP_17 1
|
||||
#else
|
||||
#define DDS_CPP_17 0
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
|
||||
#define DDS_CPP_20 1
|
||||
#else
|
||||
#define DDS_CPP_20 0
|
||||
#endif
|
||||
|
||||
#if DDS_CPP_17
|
||||
#define DDS_NO_DISCARD [[nodiscard]]
|
||||
#else
|
||||
#define DDS_NO_DISCARD
|
||||
@@ -153,7 +164,7 @@ enum DXGI_FORMAT {
|
||||
// clang-format on
|
||||
|
||||
namespace dds {
|
||||
#if __cplusplus >= 202002L
|
||||
#if DDS_CPP_20
|
||||
template <typename T>
|
||||
using span = std::span<T>;
|
||||
#else
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <span>
|
||||
|
||||
#define DDS_USE_STD_FILESYSTEM 1
|
||||
#include <filesystem>
|
||||
#include <dds.hpp>
|
||||
|
||||
TEST_CASE("Read DDS and write PPM") {
|
||||
|
||||
Reference in New Issue
Block a user