gcc, clang, and msvc all reject the following code:
#include <memory>
#include <vector>
int main() {
auto _ = std::vector<int const>{}; // error
auto _ = std::vector<int volatile>{}; // error
auto _ = std::vector<int&>{}; // error
}
See also https://godbolt.org/z/3GY9E66xh
This is because std::allocator<T> doesn't accept T if it is qualified by const, volatile, or reference. I just wonder:
Is it required by the C++ standard that T must not be qualified by
const, volatile, or reference in std::allocator<T>?
static_assert(std::is_object_v<Key>, "The C++ Standard forbids containers of non-object types because of [container.requirements].");static_assertto ensure value_type is unqualified. I just wonder if that is also explicitly required by the C++ standard.