From 6ba3b930189168169af366ac5e3eb828549d1aca Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 13 Feb 2017 20:43:23 +0100 Subject: [PATCH] cleaner pipe operator definition for ranges --- ostd/format.hh | 2 +- ostd/range.hh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ostd/format.hh b/ostd/format.hh index 02968af..6c058f3 100644 --- a/ostd/format.hh +++ b/ostd/format.hh @@ -27,7 +27,7 @@ enum FormatFlags { FMT_FLAG_HASH = 1 << 4 }; -struct format_error: public std::runtime_error { +struct format_error: std::runtime_error { using std::runtime_error::runtime_error; }; diff --git a/ostd/range.hh b/ostd/range.hh index 6f90ed4..2f2f559 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -698,8 +698,10 @@ struct InputRange { } }; -template>> -inline auto operator|(R &&range, F &&func) { +template +inline auto operator|(R &&range, F &&func) -> + std::enable_if_t, decltype(func(std::forward(range)))> +{ return func(std::forward(range)); }