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

Correct table filled area shape method #107

Open
lngsv opened this issue Sep 20, 2023 · 0 comments
Open

Correct table filled area shape method #107

lngsv opened this issue Sep 20, 2023 · 0 comments

Comments

@lngsv
Copy link

lngsv commented Sep 20, 2023

Hi!

I expect this code to print "1 1"

#include <iostream>
// The header file from single_include
#include "tabulate.hpp"
 
using namespace tabulate;

int main() {
    Table table;
    table.add_row({"cell"});
    auto [rows, cols] = table.shape();
    std::cout << rows << " " << cols << std::endl;
}

In my environment it prints "8 3".

$ g++ test_tabulate.cpp -o test
$ ./test
8 3

I don't think that matters but I use g++ (GCC) 12.2.0 on CentOS 7

I didn't go deep into details but I believe it prints some numbers that depend on the size of the buffer that is created in TableInternal::shape() method.

Is it possible to fix/add a method that would return an actual number of rows and columns that were added to the table?

This worked for me.

// tabulate::Table
std::pair<size_t, size_t> sizes()
{
    return {rows_, cols_};
}
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

No branches or pull requests

1 participant