From Jason Turner

[readable.traits]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpacl2l2h2/{from.md → to.md} +70 -0
tmp/tmpacl2l2h2/{from.md → to.md} RENAMED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Indirectly readable traits <a id="readable.traits">[[readable.traits]]</a>
2
+
3
+ To implement algorithms only in terms of indirectly readable types, it
4
+ is often necessary to determine the value type that corresponds to a
5
+ particular indirectly readable type. Accordingly, it is required that if
6
+ `R` is the name of a type that models the `indirectly_readable` concept
7
+ [[iterator.concept.readable]], the type
8
+
9
+ ``` cpp
10
+ iter_value_t<R>
11
+ ```
12
+
13
+ be defined as the indirectly readable type’s value type.
14
+
15
+ ``` cpp
16
+ template<class> struct cond-value-type { }; // exposition only
17
+ template<class T>
18
+ requires is_object_v<T>
19
+ struct cond-value-type<T> {
20
+ using value_type = remove_cv_t<T>;
21
+ };
22
+
23
+ template<class> struct indirectly_readable_traits { };
24
+
25
+ template<class T>
26
+ struct indirectly_readable_traits<T*>
27
+ : cond-value-type<T> { };
28
+
29
+ template<class I>
30
+ requires is_array_v<I>
31
+ struct indirectly_readable_traits<I> {
32
+ using value_type = remove_cv_t<remove_extent_t<I>>;
33
+ };
34
+
35
+ template<class I>
36
+ struct indirectly_readable_traits<const I>
37
+ : indirectly_readable_traits<I> { };
38
+
39
+ template<class T>
40
+ requires requires { typename T::value_type; }
41
+ struct indirectly_readable_traits<T>
42
+ : cond-value-type<typename T::value_type> { };
43
+
44
+ template<class T>
45
+ requires requires { typename T::element_type; }
46
+ struct indirectly_readable_traits<T>
47
+ : cond-value-type<typename T::element_type> { };
48
+
49
+ template<class T> using iter_value_t = see below;
50
+ ```
51
+
52
+ Let R_`I` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes
53
+
54
+ - `indirectly_readable_traits<R_I>::value_type` if
55
+ `iterator_traits<R_I>` names a specialization generated from the
56
+ primary template, and
57
+ - `iterator_traits<R_I>::value_type` otherwise.
58
+
59
+ Class template `indirectly_readable_traits` may be specialized on
60
+ program-defined types.
61
+
62
+ [*Note 1*: Some legacy output iterators define a nested type named
63
+ `value_type` that is an alias for `void`. These types are not
64
+ `indirectly_readable` and have no associated value types. — *end note*]
65
+
66
+ [*Note 2*: Smart pointers like `shared_ptr<int>` are
67
+ `indirectly_readable` and have an associated value type, but a smart
68
+ pointer like `shared_ptr<void>` is not `indirectly_readable` and has no
69
+ associated value type. — *end note*]
70
+