From a87508008dfa1604baf2d4e39bf44704c00f261c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 3 Apr 2022 16:34:10 -0700 Subject: skia WIP --- src/deps/skia/include/private/SkTLogic.h | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/deps/skia/include/private/SkTLogic.h (limited to 'src/deps/skia/include/private/SkTLogic.h') diff --git a/src/deps/skia/include/private/SkTLogic.h b/src/deps/skia/include/private/SkTLogic.h new file mode 100644 index 000000000..a2c2f4cfd --- /dev/null +++ b/src/deps/skia/include/private/SkTLogic.h @@ -0,0 +1,86 @@ +/* + * Copyright 2013 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * + * This header provides some std:: features early in the skstd namespace + * and several Skia-specific additions in the sknonstd namespace. + */ + +#ifndef SkTLogic_DEFINED +#define SkTLogic_DEFINED + +#include +#include +#include +#include "include/private/SkTo.h" + +namespace skstd { + +// C++17, +struct monostate {}; + +// C++17, +template struct conjunction : std::true_type { }; +template struct conjunction : T { }; +template +struct conjunction : std::conditional, T>::type { }; + +// C++17, std::data, std::size +template +constexpr auto data(Container& c) -> decltype(c.data()) { return c.data(); } +template +constexpr auto data(const Container& c) -> decltype(c.data()) { return c.data(); } +template +constexpr auto data(Array(&a)[N]) -> decltype(a) { return a; } +template +constexpr const T* data(std::initializer_list i) { return i.begin(); } + +template +constexpr auto size(Container& c) -> decltype(c.size()) { return c.size(); } +template +constexpr size_t size(Array(&)[N]) { return N; } +template +constexpr const T* size(std::initializer_list i) { return i.end() - i.begin(); } +} // namespace skstd + +// The sknonstd namespace contains things we would like to be proposed and feel std-ish. +namespace sknonstd { + +// The name 'copy' here is fraught with peril. In this case it means 'append', not 'overwrite'. +// Alternate proposed names are 'propagate', 'augment', or 'append' (and 'add', but already taken). +// std::experimental::propagate_const already exists for other purposes in TSv2. +// These also follow the pattern used by boost. +template struct copy_const { + using type = std::conditional_t::value, std::add_const_t, D>; +}; +template using copy_const_t = typename copy_const::type; + +template struct copy_volatile { + using type = std::conditional_t::value, std::add_volatile_t, D>; +}; +template using copy_volatile_t = typename copy_volatile::type; + +template struct copy_cv { + using type = copy_volatile_t, S>; +}; +template using copy_cv_t = typename copy_cv::type; + +// The name 'same' here means 'overwrite'. +// Alternate proposed names are 'replace', 'transfer', or 'qualify_from'. +// same_xxx can be written as copy_xxx, S> +template using same_const = copy_const, S>; +template using same_const_t = typename same_const::type; +template using same_volatile =copy_volatile,S>; +template using same_volatile_t = typename same_volatile::type; +template using same_cv = copy_cv, S>; +template using same_cv_t = typename same_cv::type; + +} // namespace sknonstd + +template +constexpr int SkCount(const Container& c) { return SkTo(skstd::size(c)); } + +#endif -- cgit v1.2.3