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

using from_Index function could lose columns for std::string #1

Open
Aperjump opened this issue Jun 16, 2019 · 1 comment
Open

using from_Index function could lose columns for std::string #1

Aperjump opened this issue Jun 16, 2019 · 1 comment
Assignees
Labels
invalid This doesn't seem right

Comments

@Aperjump
Copy link
Collaborator

Aperjump commented Jun 16, 2019

data_frame df2;
df2.from_tuples(std::vector{std::make_tuple(1, 3.3, "hello"), 
                                std::make_tuple(2, 2.2, "world"), 
                                std::make_tuple(3, 1.1, "bili")}, 
                    {"int_vec", "double_vec", "str_vec"});
df2.print_index<int, double, std::string>({0, 1, 2});

This will only print 2 columns and omit the std::string.

@Aperjump
Copy link
Collaborator Author

The problem is caused by type deduction. When calling make_tuple("hello") the type deduction for "hello" is const char*, but in print_index function we are passing std::string for induction, thta column cannot be found in type_map.
On solution is to use using namespace std::string_literals; and add s operator for each string literal
like

using namespace std::string_literals;
data_frame df2;
df2.from_tuples(std::vector{std::make_tuple(1, 3.3, "hello"s), 
                                std::make_tuple(2, 2.2, "world"s), 
                                std::make_tuple(3, 1.1, "bili"s)}, 
                    {"int_vec", "double_vec", "str_vec"});
df2.print_index<int, double, std::string>({0, 1, 2});

@Aperjump Aperjump self-assigned this Jun 16, 2019
@Aperjump Aperjump added bug Something isn't working invalid This doesn't seem right and removed bug Something isn't working labels Jun 16, 2019
@Aperjump Aperjump changed the title using from_Index function could lose one column for std::string using from_Index function could lose columns for std::string Jun 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant