aboutsummaryrefslogtreecommitdiff
path: root/libbutl/path.txx
diff options
context:
space:
mode:
Diffstat (limited to 'libbutl/path.txx')
-rw-r--r--libbutl/path.txx18
1 files changed, 14 insertions, 4 deletions
diff --git a/libbutl/path.txx b/libbutl/path.txx
index 45b62bd..60e0f1a 100644
--- a/libbutl/path.txx
+++ b/libbutl/path.txx
@@ -1,7 +1,7 @@
// file : libbutl/path.txx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
-LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
+namespace butl
{
template <typename C, typename K>
basic_path<C, K> basic_path<C, K>::
@@ -103,8 +103,8 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
#endif
template <typename C, typename K>
- basic_path<C, K> basic_path<C, K>::
- relative (basic_path<C, K> d) const
+ optional<basic_path<C, K>> basic_path<C, K>::
+ try_relative (basic_path<C, K> d) const
{
dir_type r;
@@ -118,12 +118,22 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
// Roots of the paths do not match.
//
if (d.root ())
- throw invalid_basic_path<C> (this->path_);
+ return nullopt;
}
return r / leaf (d);
}
+ template <typename C, typename K>
+ basic_path<C, K> basic_path<C, K>::
+ relative (basic_path<C, K> d) const
+ {
+ if (optional<basic_path<C, K>> r = try_relative (std::move (d)))
+ return std::move (*r);
+
+ throw invalid_basic_path<C> (this->path_);
+ }
+
#ifdef _WIN32
// Find the actual spelling of a name in the specified dir. If the name is
// found, append it to the result and return true. Otherwise, return false.