// -*- c++ -*- #ifndef _LIB_VOLK_ALLOCATOR_HPP_ #define _LIB_VOLK_ALLOCATOR_HPP_ #include #include #include namespace gr { namespace digitalhf { // see https://en.cppreference.com/w/cpp/named_req/Allocator template struct volk_allocator { typedef T value_type; volk_allocator() = default; template constexpr volk_allocator(const volk_allocator&) noexcept {} T* allocate(std::size_t n) { if (n > std::numeric_limits::max() / sizeof(T)) throw std::bad_alloc(); if (auto p = static_cast(volk_malloc(n*sizeof(T), volk_get_alignment()))) return p; throw std::bad_alloc(); } void deallocate(T* p, std::size_t) noexcept { volk_free(p); } } ; template bool operator==(const volk_allocator&, const volk_allocator&) { return true; } template bool operator!=(const volk_allocator&, const volk_allocator&) { return false; } } // namespace digitalhf } // namespace gr #endif // _LIB_VOLK_ALLOCATOR_HPP_