#pragma once extern "C" { #include } #include #include namespace av { // Generic error class struct error : public std::runtime_error { using runtime_error::runtime_error; }; // Type of a freeing function (for unique_ptr) template using deleter = void(*)(T*); // Often used type template using unique_ptr = std::unique_ptr>; // Allocator template struct allocator { using value_type = T; using size_type = size_t; T* allocate(size_type n) const { auto ptr = av_malloc(n * sizeof(T)); if(!ptr) throw std::bad_alloc(); return static_cast(ptr); } void deallocate(T* ptr, size_type /*n*/) const noexcept { av_free(ptr); } }; template bool operator==(allocator const &, allocator const &) noexcept { return true; } template bool operator!=(allocator const &, allocator const &) noexcept { return false; } }