https://llvm.org/bugs/show_bug.cgi?id=23852
Marshall Clow (home) <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID Assignee|unassignedclangbugs@nondot. |[email protected] |org | --- Comment #1 from Marshall Clow (home) <[email protected]> --- The standard says the requirement for push_back is that the value type (T) of a vector needs to be "T shall be CopyInsertable into X." (where X is the container) [Table 100] What does that mean? [23.2.1/15] says: Given a container type X having an allocator_type identical to A and a value_type identical to T and given an lvalue m of type A, a pointer p of type T*, an expression v of type (possibly const) T ... (skip ahead to p15.4) T is CopyInsertable into X means that, in addition to T being MoveInsertable into X, the following expression is well-formed: allocator_traits<A>::construct(m, p, v) and its evaluation causes the following postcondition to hold: The value of v is unchanged and is equivalent to *p. So, it needs to be able to this: std::allocator<const int> a; const int *p; int v = 17; std::allocator_traits<std::allocator<const int>>::construct(m, p, v); but p is a pointer to const int - and so the allocator cannot construct a new int there. Hence, the compile failure. In general, containers of const types is a bad idea. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
