Skip to content

Instantly share code, notes, and snippets.

@kammce
Last active May 12, 2026 13:35
Show Gist options
  • Select an option

  • Save kammce/084b8660a79692cefd6719beb7cbe7be to your computer and use it in GitHub Desktop.

Select an option

Save kammce/084b8660a79692cefd6719beb7cbe7be to your computer and use it in GitHub Desktop.
std::errc to string_view
std::string_view to_string_view(std::errc p_errc)
{
switch (p_errc) {
case std::errc::address_family_not_supported:
return "address_family_not_supported";
case std::errc::address_in_use:
return "address_in_use";
case std::errc::address_not_available:
return "address_not_available";
case std::errc::already_connected:
return "already_connected";
case std::errc::argument_list_too_long:
return "argument_list_too_long";
case std::errc::argument_out_of_domain:
return "argument_out_of_domain";
case std::errc::bad_address:
return "bad_address";
case std::errc::bad_file_descriptor:
return "bad_file_descriptor";
case std::errc::bad_message:
return "bad_message";
case std::errc::broken_pipe:
return "broken_pipe";
case std::errc::connection_aborted:
return "connection_aborted";
case std::errc::connection_already_in_progress:
return "connection_already_in_progress";
case std::errc::connection_refused:
return "connection_refused";
case std::errc::connection_reset:
return "connection_reset";
case std::errc::cross_device_link:
return "cross_device_link";
case std::errc::destination_address_required:
return "destination_address_required";
case std::errc::device_or_resource_busy:
return "device_or_resource_busy";
case std::errc::directory_not_empty:
return "directory_not_empty";
case std::errc::executable_format_error:
return "executable_format_error";
case std::errc::file_exists:
return "file_exists";
case std::errc::file_too_large:
return "file_too_large";
case std::errc::filename_too_long:
return "filename_too_long";
case std::errc::function_not_supported:
return "function_not_supported";
case std::errc::host_unreachable:
return "host_unreachable";
case std::errc::identifier_removed:
return "identifier_removed";
case std::errc::illegal_byte_sequence:
return "illegal_byte_sequence";
case std::errc::inappropriate_io_control_operation:
return "inappropriate_io_control_operation";
case std::errc::interrupted:
return "interrupted";
case std::errc::invalid_argument:
return "invalid_argument";
case std::errc::invalid_seek:
return "invalid_seek";
case std::errc::io_error:
return "io_error";
case std::errc::is_a_directory:
return "is_a_directory";
case std::errc::message_size:
return "message_size";
case std::errc::network_down:
return "network_down";
case std::errc::network_reset:
return "network_reset";
case std::errc::network_unreachable:
return "network_unreachable";
case std::errc::no_buffer_space:
return "no_buffer_space";
case std::errc::no_child_process:
return "no_child_process";
case std::errc::no_link:
return "no_link";
case std::errc::no_lock_available:
return "no_lock_available";
case std::errc::no_message:
return "no_message";
case std::errc::no_protocol_option:
return "no_protocol_option";
case std::errc::no_space_on_device:
return "no_space_on_device";
case std::errc::no_such_device_or_address:
return "no_such_device_or_address";
case std::errc::no_such_device:
return "no_such_device";
case std::errc::no_such_file_or_directory:
return "no_such_file_or_directory";
case std::errc::no_such_process:
return "no_such_process";
case std::errc::not_a_directory:
return "not_a_directory";
case std::errc::not_a_socket:
return "not_a_socket";
case std::errc::not_connected:
return "not_connected";
case std::errc::not_enough_memory:
return "not_enough_memory";
case std::errc::not_supported:
return "not_supported";
case std::errc::operation_canceled:
return "operation_canceled";
case std::errc::operation_in_progress:
return "operation_in_progress";
case std::errc::operation_not_permitted:
return "operation_not_permitted";
case std::errc::operation_not_supported:
return "operation_not_supported";
case std::errc::operation_would_block: // resource_unavailable_try_again
return "resource_unavailable_try_again";
case std::errc::owner_dead:
return "owner_dead";
case std::errc::permission_denied:
return "permission_denied";
case std::errc::protocol_error:
return "protocol_error";
case std::errc::protocol_not_supported:
return "protocol_not_supported";
case std::errc::read_only_file_system:
return "read_only_file_system";
case std::errc::resource_deadlock_would_occur:
return "resource_deadlock_would_occur";
case std::errc::result_out_of_range:
return "result_out_of_range";
case std::errc::state_not_recoverable:
return "state_not_recoverable";
case std::errc::text_file_busy:
return "text_file_busy";
case std::errc::timed_out:
return "timed_out";
case std::errc::too_many_files_open_in_system:
return "too_many_files_open_in_system";
case std::errc::too_many_files_open:
return "too_many_files_open";
case std::errc::too_many_links:
return "too_many_links";
case std::errc::too_many_symbolic_link_levels:
return "too_many_symbolic_link_levels";
case std::errc::value_too_large:
return "value_too_large";
case std::errc::wrong_protocol_type:
return "wrong_protocol_type";
default:
return "unknown";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment