Skip to content

debug.h ~ debug ~ verify

Baptiste Thémine edited this page Apr 27, 2023 · 9 revisions
bool debug::verify(std::istream &ios) noexcept;

Description

Checks and clears I/O state then flushes input stream.

Typical usage of this function is to apply user input validation inside a loop.

Parameters

  • ios --> reference to an istream object.

Return value

Returns true if input stream has no errors otherwise returns false.

Exceptions

Never throws exception.

Examples

In the following example, we loop until user input is a valid integer.

#include <iostream>
#include <JLC/debug.h>

int main(){
    int num;
    do{
        std::cout << "num = ";
        std::cin >> num;}
    while(!debug::verify(std::cin));
    std::cout << num << std::endl;
}
num = test
num = 42
42

See also

Clone this wiki locally