struct fs::filesystem_error::_Impl
{
- _Impl(const string& what_arg, const path& p1, const path& p2)
+ _Impl(string_view what_arg, const path& p1, const path& p2)
: path1(p1), path2(p2), what(make_what(what_arg, &p1, &p2))
{ }
- _Impl(const string& what_arg, const path& p1)
+ _Impl(string_view what_arg, const path& p1)
: path1(p1), path2(), what(make_what(what_arg, &p1, nullptr))
{ }
- _Impl(const string& what_arg)
+ _Impl(string_view what_arg)
: what(make_what(what_arg, nullptr, nullptr))
{ }
static std::string
- make_what(const std::string& s, const path* p1, const path* p2)
+ make_what(string_view s, const path* p1, const path* p2)
{
const std::string pstr1 = p1 ? p1->u8string() : std::string{};
const std::string pstr2 = p2 ? p2->u8string() : std::string{};
fs::filesystem_error::
filesystem_error(const string& what_arg, error_code ec)
: system_error(ec, what_arg),
- _M_impl(std::__make_shared<_Impl>(what_arg))
+ _M_impl(std::__make_shared<_Impl>(system_error::what()))
{ }
fs::filesystem_error::
filesystem_error(const string& what_arg, const path& p1, error_code ec)
: system_error(ec, what_arg),
- _M_impl(std::__make_shared<_Impl>(what_arg, p1))
+ _M_impl(std::__make_shared<_Impl>(system_error::what(), p1))
{ }
fs::filesystem_error::
filesystem_error(const string& what_arg, const path& p1, const path& p2,
error_code ec)
: system_error(ec, what_arg),
- _M_impl(std::__make_shared<_Impl>(what_arg, p1, p2))
+ _M_impl(std::__make_shared<_Impl>(system_error::what(), p1, p2))
{ }
fs::filesystem_error::~filesystem_error() = default;
const std::error_code ec = make_error_code(std::errc::is_a_directory);
const std::filesystem::path p1 = "test/path/one";
const std::filesystem::path p2 = "/test/path/two";
+ std::system_error syserr(ec, str);
const filesystem_error e1(str, ec);
- VERIFY( contains(e1.what(), str) );
+ VERIFY( contains(e1.what(), syserr.what()) );
VERIFY( !contains(e1.what(), "[]") ); // no "empty path" in the string
VERIFY( e1.path1().empty() );
VERIFY( e1.path2().empty() );
const filesystem_error e2(str, p1, ec);
VERIFY( e2.path1() == p1 );
VERIFY( e2.path2().empty() );
- VERIFY( contains(e2.what(), str) );
+ VERIFY( contains(e2.what(), syserr.what()) );
VERIFY( contains(e2.what(), p1.string()) );
VERIFY( !contains(e2.what(), "[]") );
VERIFY( e2.code() == ec );
const filesystem_error e3(str, std::filesystem::path{}, ec);
VERIFY( e3.path1().empty() );
VERIFY( e3.path2().empty() );
- VERIFY( contains(e3.what(), str) );
+ VERIFY( contains(e3.what(), syserr.what()) );
VERIFY( contains(e3.what(), "[]") );
VERIFY( !contains(e3.what(), "[] []") );
VERIFY( e3.code() == ec );
const filesystem_error e4(str, p1, p2, ec);
VERIFY( e4.path1() == p1 );
VERIFY( e4.path2() == p2 );
- VERIFY( contains(e4.what(), str) );
+ VERIFY( contains(e4.what(), syserr.what()) );
VERIFY( contains(e4.what(), p1.string()) );
VERIFY( contains(e4.what(), p2.string()) );
VERIFY( !contains(e4.what(), "[]") );
const filesystem_error e5(str, p1, std::filesystem::path{}, ec);
VERIFY( e5.path1() == p1 );
VERIFY( e5.path2().empty() );
- VERIFY( contains(e5.what(), str) );
+ VERIFY( contains(e5.what(), syserr.what()) );
VERIFY( contains(e5.what(), p1.string()) );
VERIFY( contains(e5.what(), "[]") );
VERIFY( e5.code() == ec );
const filesystem_error e6(str, std::filesystem::path{}, p2, ec);
VERIFY( e6.path1().empty() );
VERIFY( e6.path2() == p2 );
- VERIFY( contains(e6.what(), str) );
+ VERIFY( contains(e6.what(), syserr.what()) );
VERIFY( contains(e6.what(), "[]") );
VERIFY( contains(e6.what(), p2.string()) );
VERIFY( e6.code() == ec );