Is it possible to specialize the std::allocator_traits, template like this?
namespace falloc_ {
template<class Tp> class FAllocator ;
}
// partial spec for all falloc_::FAllocator<U>, std::allocator_traits
template<typename Tp>
struct std::allocator_traits<falloc_::FAllocator<Tp> > {
using allocator_type = falloc_::FAllocator<Tp> ;
using value_type = typename allocator_type::value_type ;
// ...
// All the components I need here, I will include all the code if You need them.
// ...
} ;
namespace falloc_ {
template<class Tp> class FAllocator {
public:
using value_type = Tp ;
} ;
}
The complete code compiles and runs in the std++20 allocator class and allocator, feature class (std::allocator_traits) specifications. In that case, my question is actually about practical correctness, whether according to people who know more about the standard, whether similar feature class overloading is forbidden, or simply assume that since the (complete) code is compileable and executable and works according to the intended plan - can I consider that I can use it?
Additionally, I tested the allocator with the code:
std::vector<int, falloc_::FAllocator<int> > mv ;
for (size_t i = 0 ; i < 5 ; i++) {
mv.push_back(i) ;
}
for (int i = 4 ; i > -1 ; i--) {
std::cout << "mv[" << i << "]: " << mv[i] << '\n' ;
}
Memory was allocated and freed correctly, I also checked with, Valgrind. Using Gdb, I checked and all functions were called from
std::allocator_traits<falloc_::FAllocator<U> > // U aka int for std::vector<int, falloc_::FAllocator<int> >
Thank You in advance for any insights, suggestions and advice.