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

bug in util::join #35

Open
klosworks opened this issue Jul 3, 2019 · 2 comments
Open

bug in util::join #35

klosworks opened this issue Jul 3, 2019 · 2 comments

Comments

@klosworks
Copy link

klosworks commented Jul 3, 2019

The current definition is

  static inline
  std::string join(const std::vector<std::string>& vec,
                   const std::string& sep = " ")
  {
    std::string res;
    for (auto& elem : vec) res.append(elem + sep);
    res.erase(--res.end());
    return res;
  }

It assumes that the separator is exactly 1 character, which doesn't have to be the case because the sep argument is a string.
Specifically this line is buggy:

    res.erase(--res.end());
@arun11299
Copy link
Owner

Agree. Will fix it. Thanks for finding it out!

@p4vook
Copy link

p4vook commented Jan 7, 2024

Shouldn't this be closed?
UPD: no, the bug appears to be still present

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

3 participants