I cannot understand why this code segfault. I allocate enough space for n element of a giving type with an allocator, and then fill the space with a copy of the default constructed type with std::fill.
#define TESTED_TYPE std::string
size_t n = 5;
std::allocator<TESTED_TYPE> my_alloc;
TESTED_TYPE *data = my_alloc.allocate(n);
TESTED_TYPE val = TESTED_TYPE();
std::fill(data, data + n, val);
This code compile fine and doesnt crash with basic type like int, char etc... but not with std::string. If I give to std::fill a not empty string the code doesnt segfault either. Why ?