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

The UT library is messing up the std::ofstream output #86

Closed
rianquinn opened this issue Nov 2, 2019 · 1 comment · Fixed by #88
Closed

The UT library is messing up the std::ofstream output #86

rianquinn opened this issue Nov 2, 2019 · 1 comment · Fixed by #88

Comments

@rianquinn
Copy link
Contributor

Expected Behavior

When I execute:

std::string msg = "The answer is: 42\n";
if (auto strm = std::ofstream("test.txt")) {
    strm << msg;
}

I would expect the following:

The answer is: 42

Actual Behavior

I actually get:

{T, h, e,  , a, n, s, w, e, r,  , i, s, :,  , 4, 2, }

If I comment out the unit test header, the above code works as expected.

Steps to Reproduce the Problem

  1. Run the example above

Specifications

  • Version: master
  • Platform: Fedora 31
  • Subsystem: ???
@rianquinn
Copy link
Contributor Author

It's coming from this:

namespace operators {
template <class TOs, class T,
          type_traits::requires_t<type_traits::is_container_v<T>> = 0>
constexpr auto& operator<<(TOs& os, const T& t) {
  os << '{';
  auto first = true;
  for (const auto& arg : t) {
    os << (first ? "" : ", ") << arg;
    first = false;
  }
  os << '}';
  return os;
}
}  // namespace operators

Based on how this is written, I think this would end up being an issue for any container type. This is likely not a great way to do this.

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 a pull request may close this issue.

1 participant