From 7a79cbbc811a643ef193de0790609cd7bfea61fc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 12 Mar 2016 15:27:54 +0000 Subject: Migrate code to c++14 --- src/string.hh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/string.hh') diff --git a/src/string.hh b/src/string.hh index 70a95374..606a9986 100644 --- a/src/string.hh +++ b/src/string.hh @@ -93,10 +93,12 @@ private: const Type& type() const { return *static_cast(this); } }; -[[gnu::optimize(3)]] // this is recursive for constexpr reason constexpr ByteCount strlen(const char* s) { - return *s == 0 ? 0 : strlen(s+1) + 1; + int i = 0; + while (*s++ != 0) + ++i; + return {i}; } class String : public StringOps @@ -406,12 +408,12 @@ to_string(const StronglyTypedNumber& val) namespace detail { -template using IsString = std::is_convertible; +template constexpr bool is_string = std::is_convertible::value; -template::value>::type> +template>> auto format_param(const T& val) -> decltype(to_string(val)) { return to_string(val); } -template::value>::type> +template>> StringView format_param(const T& val) { return val; } } -- cgit v1.2.3