diff options
Diffstat (limited to 'src/spawn/include/spawn/detail/is_stack_allocator.hpp')
-rw-r--r-- | src/spawn/include/spawn/detail/is_stack_allocator.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/spawn/include/spawn/detail/is_stack_allocator.hpp b/src/spawn/include/spawn/detail/is_stack_allocator.hpp new file mode 100644 index 000000000..6f0d85426 --- /dev/null +++ b/src/spawn/include/spawn/detail/is_stack_allocator.hpp @@ -0,0 +1,32 @@ +// +// detail/is_stack_allocator.hpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2019 Casey Bodley (cbodley at redhat dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#pragma once + +#include <type_traits> + +#include <boost/type_traits/make_void.hpp> + +namespace spawn { +namespace detail { + +template <typename T, typename = void> +struct is_stack_allocator : std::false_type {}; + +template <typename T> +struct is_stack_allocator<T, boost::void_t<decltype( + // boost::context::stack_context c = salloc.allocate(); + std::declval<boost::context::stack_context>() = std::declval<T&>().allocate(), + // salloc.deallocate(c); + std::declval<T&>().deallocate(std::declval<boost::context::stack_context&>()) + )>> : std::true_type {}; + +} // namespace detail +} // namespace spawn |