From bc5df38d08cb0dbe5b55c145ecce93581de77fee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 30 Jul 2016 17:21:30 +0200 Subject: Make (foo / "bar") always result in path and not dir_path --- butl/path | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'butl') diff --git a/butl/path b/butl/path index 8148b00..d5b4407 100644 --- a/butl/path +++ b/butl/path @@ -872,24 +872,6 @@ namespace butl template inline basic_path - operator/ (const basic_path& x, const std::basic_string& y) - { - basic_path r (x); - r /= y; - return r; - } - - template - inline basic_path - operator/ (const basic_path& x, const C* y) - { - basic_path r (x); - r /= y; - return r; - } - - template - inline basic_path operator+ (const basic_path& x, const std::basic_string& y) { basic_path r (x); @@ -940,8 +922,32 @@ namespace butl // template inline basic_path> - operator/ (basic_path> const& x, - basic_path> const& y) + operator/ (const basic_path>& x, + const basic_path>& y) + { + basic_path> r (x); + r /= y; + return r; + } + + + // Note that the result of (foo / "bar") is always a path, even if foo + // is dir_path. An idiom to force it dir_path is this: + // + // dir_path foo_bar (dir_path (foo) /= "bar"); + // + template + inline basic_path> + operator/ (const basic_path& x, const std::basic_string& y) + { + basic_path> r (x); + r /= y; + return r; + } + + template + inline basic_path> + operator/ (const basic_path& x, const C* y) { basic_path> r (x); r /= y; -- cgit v1.1