8

Since the maximum size does not depend on particular std::vector objects, I guess it should be a static method. But still, the standard prototypes it as non-static, and I cannot figure out why. Logically, one should check the maximum size before creating any std::vector objects.

Note that this question is different from this one which is basically about constexpr.

Community
  • 1
  • 1
Lingxi
  • 14,579
  • 2
  • 37
  • 93
  • 1
    "Logically, one should check the maximum size before creating any `std::vector` objects." → Really? `max_size` is optimistic, so verifying that you're under doesn't guarantee anything. – Veedrac Feb 19 '16 at 16:55
  • 7
    I would says that it might depend of Allocator. – Jarod42 Feb 19 '16 at 16:55
  • 2
    @LogicStuff Thanks for the mention. That indeed answers my question :-) Always forget the allocator thing. – Lingxi Feb 19 '16 at 16:59

0 Answers0