Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table: Provide size() function returning row counts #97

Merged

Conversation

edisonhello
Copy link
Contributor

Providing a function returning the number of rows is useful for me - I can format the table's rows at once after the table is built according to the number of rows, instead of setting a counter aside. I also saw that the size() function is already provided in TableInternal, so I think just returning the return value of table_->size() is fine.

Since there is no test, here's the testing code that I used to test the feature after I implemented it:

#include <cassert>
#include <iostream>
#include <tabulate/table.hpp>

int main() {
  tabulate::Table table;
  assert(table.size() == 0);
  table.add_row({"a", "b"});
  assert(table.size() == 1);
}

Also runs clang-format script in table.hpp file.

@p-ranav p-ranav merged commit ef7bee3 into p-ranav:master Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants