Modify

Ticket #11957 (closed Bugs: fixed)

Opened 14 months ago

Last modified 9 months ago

static_vector::max_size() is higher than the capacity

Reported by: anonymous Owned by: igaztanaga
Milestone: To Be Determined Component: container
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

According to the documenetation, both static_vector capacity() and max_size() shall return the static_vector capacity:

static_vector public static functions

  static size_type capacity() noexcept;
    Returns container's capacity.
    Throws. Nothing.
    Complexity. Constant O(1).

  static size_type max_size() noexcept;
    Returns container's capacity.
    Throws. Nothing.
    Complexity. Constant O(1).

This makes sense since the capacity is fixed at compile time.

However it is not actually the case

$ cat svect.cpp 
#include <cstdlib>
#include <boost/container/static_vector.hpp>
#include <iostream>

int main()
{
  boost::container::static_vector<char, 42> sv;
  std::cout << "sv.size(): " << sv.size()
            << "\nsv.capacity(): " << sv.capacity()
            << "\nsv.max_size(): " << sv.max_size() << "\n";
  return (sv.max_size() == sv.capacity()) ? EXIT_SUCCESS : EXIT_FAILURE;
}
$ clang++ --std=c++11 svect.cpp  && ./a.out
sv.size(): 0
sv.capacity(): 42
sv.max_size(): 18446744073709551615
$ echo $?
1

Attachments

Change History

comment:1 Changed 14 months ago by barthelemy@…

subscribe

comment:2 Changed 13 months ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed

comment:3 Changed 9 months ago by jim.king@…

Should the Milestone be set to 1.61 since this appears to have been fixed in 1.61.0 ?

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.