.. _program_listing_file__tmp_ws_src_proxsuite_include_proxsuite_linalg_veg_type_traits_alloc.hpp: Program Listing for File alloc.hpp ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/proxsuite/include/proxsuite/linalg/veg/type_traits/alloc.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef VEG_ALLOC_HPP_QHYOV5XDS #define VEG_ALLOC_HPP_QHYOV5XDS #include "proxsuite/linalg/veg/internal/has_asan.hpp" #include "proxsuite/linalg/veg/ref.hpp" #include "proxsuite/linalg/veg/type_traits/constructible.hpp" #include "proxsuite/linalg/veg/type_traits/assignable.hpp" #include "proxsuite/linalg/veg/internal/typedefs.hpp" #include "proxsuite/linalg/veg/internal/macros.hpp" #include "proxsuite/linalg/veg/memory/placement.hpp" #include "proxsuite/linalg/veg/internal/prologue.hpp" #include namespace proxsuite { namespace linalg { namespace veg { namespace mem { template struct Alloc {}; template struct Cloner {}; } // namespace mem namespace _detail { #if VEG_HAS_ASAN extern "C" void __sanitizer_annotate_contiguous_container /* NOLINT */ ( const void* begin, const void* end, const void* old_mid, const void* new_mid); #endif [[noreturn]] HEDLEY_NEVER_INLINE void throw_bad_alloc(); [[noreturn]] inline void terminate() noexcept; namespace _mem { struct DeferUnreachable /* NOLINT */ { bool is_unreachable; VEG_INLINE ~DeferUnreachable() { if (is_unreachable) { HEDLEY_UNREACHABLE(); } } }; } // namespace _mem } // namespace _detail namespace mem { inline auto memmove(void* dest, void const* src, usize nbytes) noexcept -> void* { if (dest != nullptr) { return std::memmove(dest, src, nbytes); } else { return dest; } } using byte = unsigned char; struct AllocBlock { void* data; usize byte_cap; }; struct Layout { usize byte_size; usize align; }; struct RelocFn { void* (*fn)(void*, void const*, usize); VEG_INLINE void operator()(void* dst, void* src, usize n) const noexcept { _detail::_mem::DeferUnreachable _{ true }; (*fn)(dst, src, n); _.is_unreachable = false; } VEG_INLINE auto is_trivial() const noexcept -> bool { return fn == &mem::memmove; } }; } // namespace mem namespace concepts { namespace alloc { VEG_CONCEPT_EXPR((typename A), (A), dealloc, mem::Alloc::dealloc( // VEG_DECLVAL(RefMut), VEG_DECLVAL(void*), VEG_DECLVAL(mem::Layout)), true); VEG_CONCEPT_EXPR((typename A), (A), alloc, mem::Alloc::alloc(VEG_DECLVAL(RefMut), VEG_DECLVAL(mem::Layout)), VEG_CONCEPT(same)); VEG_CONCEPT_EXPR((typename A), (A), owns_alloc, mem::Alloc::owns(VEG_DECLVAL(Ref), VEG_DECLVAL(mem::Layout)), VEG_CONCEPT(same)); VEG_CONCEPT_EXPR((typename A), (A), grow, mem::Alloc::grow(VEG_DECLVAL(RefMut), VEG_DECLVAL(void*), VEG_DECLVAL(mem::Layout), VEG_DECLVAL(usize), VEG_DECLVAL(mem::RelocFn)), VEG_CONCEPT(same)); VEG_CONCEPT_EXPR((typename A), (A), shrink, mem::Alloc::shrink(VEG_DECLVAL(RefMut), VEG_DECLVAL(void*), VEG_DECLVAL(mem::Layout), VEG_DECLVAL(usize), VEG_DECLVAL(mem::RelocFn)), VEG_CONCEPT(same)); VEG_CONCEPT_EXPR((typename C, typename T, typename A), (C, T, A), destroy, mem::Cloner::destroy( // VEG_DECLVAL(RefMut), VEG_DECLVAL(T*), VEG_DECLVAL(RefMut)), true); VEG_CONCEPT_EXPR((typename C, typename T, typename A), (C, T, A), clone, mem::Cloner::clone( // VEG_DECLVAL(RefMut), VEG_DECLVAL(Ref), VEG_DECLVAL(RefMut)), VEG_CONCEPT(same)); VEG_CONCEPT_EXPR((typename C, typename T, typename A), (C, T, A), clone_from, mem::Cloner::clone_from(VEG_DECLVAL(RefMut), VEG_DECLVAL(RefMut), VEG_DECLVAL(Ref), VEG_DECLVAL(RefMut)), true); } // namespace alloc } // namespace concepts } // namespace veg } // namespace linalg } // namespace proxsuite #include "proxsuite/linalg/veg/internal/epilogue.hpp" #endif /* end of include guard VEG_ALLOC_HPP_QHYOV5XDS */