From Jason Turner

[range.utility.conv.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphtoc_v9x/{from.md → to.md} +17 -9
tmp/tmphtoc_v9x/{from.md → to.md} RENAMED
@@ -29,28 +29,36 @@ constexpr bool reservable-container = // exposition only
29
  { c.capacity() } -> same_as<decltype(n)>;
30
  { c.max_size() } -> same_as<decltype(n)>;
31
  };
32
  ```
33
 
34
- Let *`container-insertable`* be defined as follows:
35
 
36
  ``` cpp
37
  template<class Container, class Ref>
38
- constexpr bool container-insertable = // exposition only
39
  requires(Container& c, Ref&& ref) {
40
- requires (requires { c.push_back(std::forward<Ref>(ref)); } ||
 
 
41
  requires { c.insert(c.end(), std::forward<Ref>(ref)); });
42
  };
43
  ```
44
 
45
- Let *`container-inserter`* be defined as follows:
46
 
47
  ``` cpp
48
- template<class Ref, class Container>
49
- constexpr auto container-inserter(Container& c) { // exposition only
50
- if constexpr (requires { c.push_back(declval<Ref>()); })
51
- return back_inserter(c);
 
 
 
 
 
52
  else
53
- return inserter(c, c.end());
 
54
  }
55
  ```
56
 
 
29
  { c.capacity() } -> same_as<decltype(n)>;
30
  { c.max_size() } -> same_as<decltype(n)>;
31
  };
32
  ```
33
 
34
+ Let *`container-appendable`* be defined as follows:
35
 
36
  ``` cpp
37
  template<class Container, class Ref>
38
+ constexpr bool container-appendable = // exposition only
39
  requires(Container& c, Ref&& ref) {
40
+ requires (requires { c.emplace_back(std::forward<Ref>(ref)); } ||
41
+ requires { c.push_back(std::forward<Ref>(ref)); } ||
42
+ requires { c.emplace(c.end(), std::forward<Ref>(ref)); } ||
43
  requires { c.insert(c.end(), std::forward<Ref>(ref)); });
44
  };
45
  ```
46
 
47
+ Let *`container-append`* be defined as follows:
48
 
49
  ``` cpp
50
+ template<class Container>
51
+ constexpr auto container-append(Container& c) { // exposition only
52
+ return [&c]<class Ref>(Ref&& ref) {
53
+ if constexpr (requires { c.emplace_back(declval<Ref>()); })
54
+ c.emplace_back(std::forward<Ref>(ref));
55
+ else if constexpr (requires { c.push_back(declval<Ref>()); })
56
+ c.push_back(std::forward<Ref>(ref));
57
+ else if constexpr (requires { c.emplace(c.end(), declval<Ref>()); })
58
+ c.emplace(c.end(), std::forward<Ref>(ref));
59
  else
60
+ c.insert(c.end(), std::forward<Ref>(ref));
61
+ };
62
  }
63
  ```
64