BLT/include/blt/compatibility.h

55 lines
1.8 KiB
C
Raw Permalink Normal View History

2023-10-26 19:44:44 -04:00
/*
* BLT C++ 20 / C++ 17 Compatability helper file
* Copyright (C) 2023 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2024-02-04 14:24:25 -05:00
#ifndef BLT_COMPATIBILITY_H
#define BLT_COMPATIBILITY_H
2023-10-26 19:44:44 -04:00
2024-02-04 14:24:25 -05:00
#define BLT_CPP23 202302L
#define BLT_CPP20 202002L
#define BLT_CPP17 201703L
#define BLT_CPP14 201402L
#define BLT_CPP11 201103L
#if __cplusplus >= BLT_CPP23
#endif
#if __cplusplus >= BLT_CPP20
2023-10-26 19:44:44 -04:00
#define BLT_CONTAINS(container, value) container.contains(value)
2023-10-27 00:00:01 -04:00
#define BLT_CPP20_CONSTEXPR constexpr
2023-11-02 16:02:40 -04:00
#define BLT_USE_CPP20
2023-10-26 19:44:44 -04:00
#else
#include <algorithm>
#define BLT_CONTAINS(container, value) std::find(container.begin(), container.end(), value) != container.end()
2023-10-27 00:00:01 -04:00
#define BLT_CPP20_CONSTEXPR
2023-11-02 16:02:40 -04:00
#undef BLT_USE_CPP20
2023-10-26 19:44:44 -04:00
#endif
#define BLT_CONTAINS_IF(container, value) std::find_if(container.begin(), container.end(), value) != container.end()
2023-10-26 20:01:01 -04:00
#define INCLUDE_FS \
#if defined(CXX17_FILESYSTEM) || defined (CXX17_FILESYSTEM_LIBFS) \
#include <filesystem>\
#elif defined(CXX11_EXP_FILESYSTEM) || defined (CXX11_EXP_FILESYSTEM_LIBFS)\
#include <experimental/filesystem>\
#else\
#error Filesystem ops not supported!\
#endif
2024-02-04 14:24:25 -05:00
#endif //BLT_COMPATIBILITY_H