mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:34:45 +01:00
Restructure CHECK to provide a stream (#660)
This commit is contained in:
@@ -73,7 +73,7 @@ struct Stack {
|
||||
//
|
||||
// - Requires: !this->IsEmpty()
|
||||
auto Pop() -> T {
|
||||
CHECK(!IsEmpty() && "Can't pop from empty stack.");
|
||||
CHECK(!IsEmpty()) << "Can't pop from empty stack.";
|
||||
auto r = head->curr;
|
||||
head = head->next;
|
||||
return r;
|
||||
@@ -83,9 +83,9 @@ struct Stack {
|
||||
//
|
||||
// - Requires: n >= 0 && n <= Count()
|
||||
void Pop(int n) {
|
||||
CHECK(n >= 0 && "Negative pop count disallowed.");
|
||||
CHECK(n >= 0) << "Negative pop count disallowed.";
|
||||
while (n--) {
|
||||
CHECK(head != nullptr && "Can only pop as many elements as stack has.");
|
||||
CHECK(head != nullptr) << "Can only pop as many elements as stack has.";
|
||||
head = head->next;
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ struct Stack {
|
||||
//
|
||||
// - Requires: !this->IsEmpty()
|
||||
auto Top() const -> T {
|
||||
CHECK(!IsEmpty() && "Empty stack has no Top().");
|
||||
CHECK(!IsEmpty()) << "Empty stack has no Top().";
|
||||
return head->curr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user