std::make_error_condition(std::errc)

From cppreference.com
< cpp‎ | error‎ | errc
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)
(C++20)
Swap and type operations
(C++20)
(C++14)
(C++11)
(C++23)
(C++11)
(C++23)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++11)
(C++17)
(C++17)
(C++23)



std::errc
Non-member functions
make_error_condition
Helper classes
Defined in header <system_error>
std::error_condition make_error_condition( std::errc e ) noexcept ;
(since C++11)

Creates an error condition for an errc value e. Sets the error value to int(e) and error category to std::generic_category

Parameters

e - standard error value

Return value

Error condition for e.

Example

#include <iostream>
#include <string>
#include <system_error>
 
int main()
{
    auto err = std::make_error_condition(std::errc::invalid_argument);
    std::cout << err.message() << '\n';
}

Possible output:

Invalid argument