
Andrey Semashev wrote:
catch (basic_filesystem_error& e) { if ( e.code() == system::errc::make_error_code( system::errc::no_space_on_device) #if defined(WIN32) || e.code() == system::windows_error::make_error_code( system::windows_error::disk_full) #endif ) { // out_of_space_error } }
Is this the right way to do this? Is there a portable way to do it?
My understanding of http://www.boost.org/doc/libs/1_40_0/libs/system/doc/reference.html#Non- member-functions is that error_category.equivalent() is there to abstract this. operator== is overloaded on error_code and error_condition to perform that equivalence check, so this should do what you want: catch (const basic_filesystem_error& e){ if (e == make_error_condition(posix_error::no_space_on_device)){ //... } }