io/Path: add generic template declaration
authorMax Kellermann <max@musicpd.org>
Mon, 3 Sep 2018 20:38:51 +0000 (22:38 +0200)
committerMax Kellermann <max@musicpd.org>
Mon, 3 Sep 2018 20:39:33 +0000 (22:39 +0200)
Fixes compiler errors with some combinations of arguments.

src/io/Path.hxx

index a6f9f29..e5bab8f 100644 (file)
@@ -80,24 +80,28 @@ Append(std::string &dest, const char *value, size_t length) noexcept
        return dest.append(value, length);
 }
 
+template<typename... Args>
+inline std::string &
+AppendWithSeparators(std::string &dest, const size_t *lengths,
+                    Args&&... args) noexcept;
+
 template<typename First, typename... Args>
 inline std::string &
 AppendWithSeparators(std::string &dest, const size_t *lengths,
                     First &&first, Args&&... args) noexcept
 {
-       return AppendWithSeparators(AppendWithSeparators(dest, lengths,
-                                                        std::forward<First>(first)),
+       dest.push_back(SEPARATOR);
+       return AppendWithSeparators(Append(dest, std::forward<First>(first),
+                                          *lengths),
                                    lengths + 1,
                                    std::forward<Args>(args)...);
 }
 
-template<typename First>
+template<>
 inline std::string &
-AppendWithSeparators(std::string &dest, const size_t *lengths,
-                    First &&first) noexcept
+AppendWithSeparators(std::string &dest, const size_t *) noexcept
 {
-       dest.push_back(SEPARATOR);
-       return Append(dest, std::forward<First>(first), *lengths);
+       return dest;
 }
 
 } // namespace PathDetail