commit 6c64ae840367889d3679509c84be9a815b515a85
parent 7852e9fd6c7eac589da3817564df9bb2b022df15
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Mon, 5 Sep 2016 10:32:05 +0300
Update CoMeta to latest version
Diffstat:
4 files changed, 42 insertions(+), 48 deletions(-)
diff --git a/include/kfr/base/kfr.h b/include/kfr/base/kfr.h
@@ -8,13 +8,6 @@
#include "../cident.h"
-#ifdef __cplusplus
-namespace kfr
-{
-using ::cid::arraysize;
-}
-#endif
-
#define KFR_VERSION_STRING "1.2.0"
#define KFR_VERSION_MAJOR 1
#define KFR_VERSION_MINOR 2
diff --git a/include/kfr/cident.h b/include/kfr/cident.h
@@ -397,31 +397,6 @@ extern char* gets(char* __s);
#endif
#endif
-#if __cplusplus >= 201103L || CMT_MSC_VER >= 1900 || CMT_HAS_FEATURE(cxx_constexpr)
-
-#include <cstdint>
-namespace cid
-{
-template <typename T, size_t N>
-constexpr inline static size_t arraysize(const T (&)[N]) noexcept
-{
- return N;
-}
-}
-
-#define CMT_ARRAYSIZE(arr) ::cid::arraysize(arr)
-#elif CMT_COMPILER_MSVC
-#define CMT_ARRAYSIZE(arr) _countof(arr)
-#elif __cplusplus >= 199711L && \
- (defined(__INTEL_COMPILER) || defined(__clang__) || \
- (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))))
-template <typename T, size_t N>
-char (&COUNTOF_REQUIRES_ARRAY_ARGUMENT(T (&)[N]))[N];
-#define CMT_ARRAYSIZE(x) sizeof(COUNTOF_REQUIRES_ARRAY_ARGUMENT(x))
-#else
-#define CMT_ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0])
-#endif
-
#ifdef CMT_COMPILER_MSVC
#define CMT_FUNC_SIGNATURE __FUNCSIG__
#else
diff --git a/include/kfr/cometa.hpp b/include/kfr/cometa.hpp
@@ -11,8 +11,8 @@
#include <type_traits>
#include <vector>
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
namespace cometa
{
@@ -20,6 +20,33 @@ namespace cometa
using std::size_t;
using std::ptrdiff_t;
+#if __cplusplus >= 201103L || CMT_MSC_VER >= 1900 || CMT_HAS_FEATURE(cxx_constexpr)
+
+template <typename T, size_t N>
+constexpr inline static size_t arraysize(const T (&)[N]) noexcept
+{
+ return N;
+}
+
+template <typename T, size_t N>
+constexpr inline static std::integral_constant<size_t, N> carraysize(const T (&)[N]) noexcept
+{
+ return {};
+}
+
+#define CMT_ARRAYSIZE(arr) decltype(carraysize(arr))::value
+#elif CMT_COMPILER_MSVC
+#define CMT_ARRAYSIZE(arr) _countof(arr)
+#elif __cplusplus >= 199711L && \
+ (defined(__INTEL_COMPILER) || defined(__clang__) || \
+ (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))))
+template <typename T, size_t N>
+char (&COUNTOF_REQUIRES_ARRAY_ARGUMENT(T (&)[N]))[N];
+#define CMT_ARRAYSIZE(x) sizeof(COUNTOF_REQUIRES_ARRAY_ARGUMENT(x))
+#else
+#define CMT_ARRAYSIZE(arr) sizeof(arr) / sizeof(arr[0])
+#endif
+
using pvoid = void*;
template <typename...>
@@ -1454,12 +1481,11 @@ struct function<Result(Args...)>
fn = temp;
return *this;
}
- CMT_INTRIN Result operator()(Args... args) const
+ CMT_INTRIN Result operator()(Args... args) const { return (*fn)(std::forward<Args>(args)...); }
+ template <typename TResult>
+ CMT_INTRIN Result call(TResult&& default_result, Args... args) const
{
- if (fn)
- return (*fn)(args...);
- else
- return details::return_val<Result>();
+ return fn ? (*fn)(std::forward<Args>(args)...) : std::forward<TResult>(default_result);
}
CMT_INTRIN explicit operator bool() const noexcept { return !!fn; }
@@ -1960,7 +1986,7 @@ constexpr size_t typename_postfix = sizeof("]") - 1;
template <size_t... indices, size_t Nout = 1 + sizeof...(indices)>
constexpr cstring<Nout> gettypename_impl(const char* str, csizes_t<indices...>) noexcept
{
- return cstring<Nout>{ (str[indices])..., 0 };
+ return cstring<Nout>{ { (str[indices])..., 0 } };
}
}
@@ -2021,4 +2047,4 @@ constexpr inline type_id_t ctypeid(T x)
}
}
-#pragma gcc diagnostic pop
+#pragma GCC diagnostic pop
diff --git a/include/kfr/cometa/string.hpp b/include/kfr/cometa/string.hpp
@@ -9,10 +9,10 @@
#include <string>
#include <utility>
-#pragma clang diagnostic push
+#pragma GCC diagnostic push
#if CMT_HAS_WARNING("-Wformat-security")
-#pragma clang diagnostic ignored "-Wformat-security"
-#pragma clang diagnostic ignored "-Wused-but-marked-unused"
+#pragma GCC diagnostic ignored "-Wformat-security"
+#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
#endif
namespace cometa
@@ -232,8 +232,8 @@ CMT_INLINE details::fmt_t<T, static_cast<char>(-1), width, prec> fmtwidth(const
return { value };
}
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template"
constexpr auto build_fmt_str(cchars_t<>, ctypes_t<>) { return make_cstring(""); }
@@ -293,7 +293,7 @@ constexpr CMT_INLINE print_t<chars...> operator""_print()
return {};
}
-#pragma clang diagnostic pop
+#pragma GCC diagnostic pop
template <typename... Args>
CMT_INLINE void printfmt(const std::string& fmt, const Args&... args)
@@ -405,4 +405,4 @@ inline std::string join(T x, U y, Ts... rest)
}
}
-#pragma clang diagnostic pop
+#pragma GCC diagnostic pop