c++20 fixes

v1
Brett 2024-02-04 14:24:25 -05:00
parent b2534baaf0
commit 2f400a6240
4 changed files with 20 additions and 8 deletions

View File

@ -16,10 +16,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef INSANE_DNS_COMPATIBILITY_H #ifndef BLT_COMPATIBILITY_H
#define INSANE_DNS_COMPATIBILITY_H #define BLT_COMPATIBILITY_H
#if __cplusplus >= 202002L #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
#define BLT_CONTAINS(container, value) container.contains(value) #define BLT_CONTAINS(container, value) container.contains(value)
#define BLT_CPP20_CONSTEXPR constexpr #define BLT_CPP20_CONSTEXPR constexpr
#define BLT_USE_CPP20 #define BLT_USE_CPP20
@ -41,4 +51,4 @@
#error Filesystem ops not supported!\ #error Filesystem ops not supported!\
#endif #endif
#endif //INSANE_DNS_COMPATIBILITY_H #endif //BLT_COMPATIBILITY_H

View File

@ -24,6 +24,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <string_view> #include <string_view>
#include <string>
namespace blt::gfx namespace blt::gfx
{ {

View File

@ -30,6 +30,7 @@ namespace blt
class area_allocator class area_allocator
{ {
public: public:
using value = T;
using type = T; using type = T;
using value_type = type; using value_type = type;
using pointer = type*; using pointer = type*;
@ -44,7 +45,7 @@ namespace blt
template<class U> template<class U>
struct rebind struct rebind
{ {
typedef std::allocator<U> other; typedef blt::area_allocator<U, BLOCK_SIZE> other;
}; };
private: private:
/** /**
@ -218,7 +219,7 @@ namespace blt
{ {
if (p >= blk->data && p <= (blk->data + BLOCK_SIZE)) if (p >= blk->data && p <= (blk->data + BLOCK_SIZE))
{ {
blk->unallocated_blocks.push_back({p, n}); blk->unallocated_blocks.push_back(pointer_view{p, n});
break; break;
} }
} }

View File

@ -30,7 +30,7 @@
namespace blt namespace blt
{ {
static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str) static inline std::string demangle(const std::string& str)
{ {
int status; int status;
// only defined for GNU C++11? // only defined for GNU C++11?
@ -45,7 +45,7 @@ namespace blt
#else #else
namespace blt namespace blt
{ {
static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str) static inline std::string demangle(const std::string& str)
{ {
return str; return str;
} }