diff --git a/example/ex3/ex3.cpp b/example/ex3/ex3.cpp index 05a3c9e4..b4d1e9e1 100644 --- a/example/ex3/ex3.cpp +++ b/example/ex3/ex3.cpp @@ -6,13 +6,13 @@ using namespace xo; int fib(int n) { - scope log(XO_ENTER0(), xtag("n", n)); + scope log(XO_ENTER0(), tag("n", n)); int retval = 1; if (n >= 2) { retval = fib(n - 1) + fib(n - 2); - log(xtag("n", n)); + log(tag("n", n)); } log.end_scope("<-", xtag("retval", retval)); diff --git a/include/nestlog/tag.hpp b/include/nestlog/tag.hpp index 16a3e21a..7ac62023 100644 --- a/include/nestlog/tag.hpp +++ b/include/nestlog/tag.hpp @@ -25,6 +25,8 @@ namespace xo { struct tag_impl { tag_impl(Name const & n, Value const & v) : name_{n}, value_{v} {} + tag_impl(Name && n, Value && v) + : name_{std::move(n)}, value_{std::move(v)} {} Name const & name() const { return name_; } Value const & value() const { return value_; } @@ -67,6 +69,20 @@ namespace xo { return tag_impl(n, ""); } /*xtag_pre*/ + template + tag_impl + tag(Name && n, Value && v) + { + return tag_impl(n, v); + } /*tag*/ + + template + tag_impl + tag(char const * n, Value && v) + { + return tag_impl(n, v); + } /*tag*/ + template inline std::ostream & operator<<(std::ostream &s,