mardi 4 décembre 2018

Implement select_on_container_copy_construction() for STL Allocator

I would like to provide a custom

select_on_container_copy_construction()

http://www.cplusplus.com/reference/memory/allocator_traits/select_on_container_copy_construction/

for my allocator.

I tried to add it directly to my allocator class like this:

T select_on_container_copy_construction( const T& a ) const {
  ...
}

but it is not called.

I tried to implement it as a type trait:

namespace std {
  template<class T>
  struct allocator_traits<static_allocator<T>> {
    typedef T value_type;
  };
}

but now I have to implement all other trait features as well.

Is there an easier way to just overwrite this function without having to provide a full allocator_traits?

Aucun commentaire:

Enregistrer un commentaire