Closed jwakely closed 4 years ago
This produces a screenful of errors because you're not using std::allocator_traits to access members of the allocator, as required since C++11:
std::allocator_traits
#include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> #include <memory> template <class Tp> struct SimpleAllocator { typedef Tp value_type; SimpleAllocator() noexcept { } template <class T> SimpleAllocator(const SimpleAllocator<T>&) { } Tp *allocate(std::size_t n) { return std::allocator<Tp>().allocate(n); } void deallocate(Tp *p, std::size_t n) { std::allocator<Tp>().deallocate(p, n); } }; template <class T, class U> bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&) { return true; } #if __cpp_impl_three_way_comparison < 201907L template <class T, class U> bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&) { return false; } #endif int main () { using namespace boost::numeric::ublas; matrix<int, row_major, unbounded_array<int, SimpleAllocator<int>>> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; std::cout << m << std::endl; }
See also #96 where the problem occurs even for std::allocator, and my comments on #100.
std::allocator
Resolved by #103. Thanks @jwakely .
This produces a screenful of errors because you're not using
std::allocator_traits
to access members of the allocator, as required since C++11:See also #96 where the problem occurs even for
std::allocator
, and my comments on #100.