/src/skia/include/private/base/SkTLogic.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2013 Google Inc. |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | * |
7 | | * |
8 | | * This header provides some std:: features early in the skstd namespace |
9 | | * and several Skia-specific additions in the sknonstd namespace. |
10 | | */ |
11 | | |
12 | | #ifndef SkTLogic_DEFINED |
13 | | #define SkTLogic_DEFINED |
14 | | |
15 | | #include <iterator> |
16 | | #include <type_traits> |
17 | | #include "include/private/base/SkTo.h" |
18 | | |
19 | | // The sknonstd namespace contains things we would like to be proposed and feel std-ish. |
20 | | namespace sknonstd { |
21 | | |
22 | | // The name 'copy' here is fraught with peril. In this case it means 'append', not 'overwrite'. |
23 | | // Alternate proposed names are 'propagate', 'augment', or 'append' (and 'add', but already taken). |
24 | | // std::experimental::propagate_const already exists for other purposes in TSv2. |
25 | | // These also follow the <dest, source> pattern used by boost. |
26 | | template <typename D, typename S> struct copy_const { |
27 | | using type = std::conditional_t<std::is_const<S>::value, std::add_const_t<D>, D>; |
28 | | }; |
29 | | template <typename D, typename S> using copy_const_t = typename copy_const<D, S>::type; |
30 | | |
31 | | template <typename D, typename S> struct copy_volatile { |
32 | | using type = std::conditional_t<std::is_volatile<S>::value, std::add_volatile_t<D>, D>; |
33 | | }; |
34 | | template <typename D, typename S> using copy_volatile_t = typename copy_volatile<D, S>::type; |
35 | | |
36 | | template <typename D, typename S> struct copy_cv { |
37 | | using type = copy_volatile_t<copy_const_t<D, S>, S>; |
38 | | }; |
39 | | template <typename D, typename S> using copy_cv_t = typename copy_cv<D, S>::type; |
40 | | |
41 | | // The name 'same' here means 'overwrite'. |
42 | | // Alternate proposed names are 'replace', 'transfer', or 'qualify_from'. |
43 | | // same_xxx<D, S> can be written as copy_xxx<remove_xxx_t<D>, S> |
44 | | template <typename D, typename S> using same_const = copy_const<std::remove_const_t<D>, S>; |
45 | | template <typename D, typename S> using same_const_t = typename same_const<D, S>::type; |
46 | | template <typename D, typename S> using same_volatile =copy_volatile<std::remove_volatile_t<D>,S>; |
47 | | template <typename D, typename S> using same_volatile_t = typename same_volatile<D, S>::type; |
48 | | template <typename D, typename S> using same_cv = copy_cv<std::remove_cv_t<D>, S>; |
49 | | template <typename D, typename S> using same_cv_t = typename same_cv<D, S>::type; |
50 | | |
51 | | } // namespace sknonstd |
52 | | |
53 | | template <typename Container> |
54 | 25.5k | constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); } int SkCount<SkSpan<SkPoint const> >(SkSpan<SkPoint const> const&) Line | Count | Source | 54 | 21.0k | constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); } |
Unexecuted instantiation: int SkCount<SkSpan<SkRSXform const> >(SkSpan<SkRSXform const> const&) int SkCount<SkSpan<sktext::gpu::GlyphVector::Variant> >(SkSpan<sktext::gpu::GlyphVector::Variant> const&) Line | Count | Source | 54 | 704 | constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); } |
int SkCount<SkSpan<sktext::gpu::Glyph const*> >(SkSpan<sktext::gpu::Glyph const*> const&) Line | Count | Source | 54 | 1.22k | constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); } |
Unexecuted instantiation: int SkCount<SkSpan<SkPoint> >(SkSpan<SkPoint> const&) int SkCount<SkSpan<unsigned short const> >(SkSpan<unsigned short const> const&) Line | Count | Source | 54 | 2.53k | constexpr int SkCount(const Container& c) { return SkTo<int>(std::size(c)); } |
|
55 | | |
56 | | #endif |