From fd2a7b79293c67cbaf478c7946b65de9425deea1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Nov 2020 13:22:53 +0200 Subject: Add ostream operator<< for vcs enum --- bdep/new-types.hxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bdep/new-types.hxx b/bdep/new-types.hxx index 6cfb2b3..59df3cb 100644 --- a/bdep/new-types.hxx +++ b/bdep/new-types.hxx @@ -43,7 +43,7 @@ namespace bdep // Default is exe with no options. // - cmd_new_type_template (): type (exe) {} + cmd_new_type_template (type_type t = exe): type (t) {} const std::string string () const @@ -62,9 +62,9 @@ namespace bdep } friend ostream& - operator<< (ostream& os, const cmd_new_type_template& t) + operator<< (ostream& os, type_type t) { - return os << t.string (); + return os << cmd_new_type_template (t).string (); } }; @@ -88,7 +88,7 @@ namespace bdep // Default is C++ with no options. // - cmd_new_lang_template (): lang (cxx) {} + cmd_new_lang_template (lang_type l = cxx): lang (l) {} const std::string string (bool lower = false) const @@ -105,9 +105,9 @@ namespace bdep } friend ostream& - operator<< (ostream& os, const cmd_new_lang_template& l) + operator<< (ostream& os, lang_type l) { - return os << l.string (); + return os << cmd_new_lang_template (l).string (); } }; @@ -134,7 +134,7 @@ namespace bdep // Default is git with no options. // - cmd_new_vcs_template (): vcs (git) {} + cmd_new_vcs_template (vcs_type v = git): vcs (v) {} const std::string string () const @@ -149,6 +149,12 @@ namespace bdep return std::string (); // Should never reach. } + + friend ostream& + operator<< (ostream& os, vcs_type v) + { + return os << cmd_new_vcs_template (v).string (); + } }; using cmd_new_vcs = cmd_new_vcs_template<>; -- cgit v1.1