memory/buffer/traits: add a simple buffer concept
This commit is contained in:
parent
8f2d036123
commit
4e055f5f0b
@ -351,6 +351,7 @@ list (
|
|||||||
matrix.hpp
|
matrix.hpp
|
||||||
memory/buffer/simple.cpp
|
memory/buffer/simple.cpp
|
||||||
memory/buffer/simple.hpp
|
memory/buffer/simple.hpp
|
||||||
|
memory/buffer/traits.hpp
|
||||||
memory/deleter.cpp
|
memory/deleter.cpp
|
||||||
memory/deleter.hpp
|
memory/deleter.hpp
|
||||||
nocopy.hpp
|
nocopy.hpp
|
||||||
|
43
memory/buffer/traits.hpp
Normal file
43
memory/buffer/traits.hpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
||||||
|
namespace cruft::memory::buffer {
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
/// A trait that evaluates to true if the queried type models cruft::allocator
|
||||||
|
template <
|
||||||
|
typename BufferT,
|
||||||
|
typename = std::void_t<>
|
||||||
|
>
|
||||||
|
struct is_buffer
|
||||||
|
: public std::false_type
|
||||||
|
{ };
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template <typename BufferT>
|
||||||
|
struct is_buffer<BufferT,
|
||||||
|
std::void_t<
|
||||||
|
// Provides aligned and unaligned allocation
|
||||||
|
decltype(std::declval<BufferT> ().begin ()),
|
||||||
|
decltype(std::declval<BufferT> ().end ()),
|
||||||
|
decltype(std::declval<BufferT> ().size ()),
|
||||||
|
void
|
||||||
|
>
|
||||||
|
> : public std::true_type
|
||||||
|
{ };
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template <typename BufferT>
|
||||||
|
constexpr auto is_buffer_v = is_buffer<BufferT>::value;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user