Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Correct table filled area shape method #107

Copy link
Copy link
Open
@lngsv

Description

@lngsv
Issue body actions

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_};
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.