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

API class Location operator << #78

Closed
andrejpetras opened this issue Jan 7, 2018 · 1 comment
Closed

API class Location operator << #78

andrejpetras opened this issue Jan 7, 2018 · 1 comment
Assignees
Labels

Comments

@andrejpetras
Copy link

operator << for class Location writes to the stream always only the
begin_file and begin_line and not the end_file and end_line.

inline std::ostream &operator<<(std::ostream &out, Location loc) {
    out << loc.begin_file() << ":" << loc.begin_line() << ":" << loc.begin_column();
    bool dash = true;
    bool eq = std::strcmp(loc.begin_file(), loc.end_file()) == 0;
    if (!eq) { out << (dash ? "-" : ":") << loc.begin_file(); dash = false; }
    eq = eq && (loc.begin_line() == loc.end_line());
    if (!eq) { out << (dash ? "-" : ":") << loc.begin_line(); dash = false; }
    eq = eq && (loc.begin_column() == loc.end_column());
    if (!eq) { out << (dash ? "-" : ":") << loc.end_column(); dash = false; }
    return out;
}
@rkaminsk
Copy link
Member

rkaminsk commented Jan 7, 2018

You are right. I am going to fix this.

@rkaminsk rkaminsk self-assigned this Jan 7, 2018
@rkaminsk rkaminsk added the bug label Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants