1
2
3
4
5
6 using System.Concepts;
7
8 namespace System
9 {
10 public class InsertProxy<C> where C is InsertionSequence
11 {
12 private typedef InsertProxy<C> Self;
13 private typedef C.Iterator Iterator;
14 private typedef C.ValueType ValueType;
15
16 public inline nothrow InsertProxy() : c(null), i()
17 {
18 }
19 public inline nothrow InsertProxy(C* c_, Iterator i_) : c(c_), i(i_)
20 {
21 }
22 public inline void operator=(const ValueType& value)
23 {
24 i = c->Insert(i, value);
25 ++i;
26 }
27 private C* c;
28 private Iterator i;
29 }
30
31 public class InsertIterator<C> where C is InsertionSequence
32 {
33 private typedef InsertIterator<C> Self;
34 private typedef InsertProxy<C> Proxy;
35 public typedef C.ValueType ValueType;
36 public typedef Proxy& ReferenceType;
37 public typedef Proxy* PointerType;
38
39 public inline nothrow InsertIterator() : proxy()
40 {
41 }
42 public inline nothrow InsertIterator(C& c, C.Iterator i) : proxy(&c, i)
43 {
44 }
45 public inline nothrow ReferenceType operator*()
46 {
47 return proxy;
48 }
49 public inline nothrow PointerType operator->()
50 {
51 return &proxy;
52 }
53 public inline nothrow Self& operator++()
54 {
55 return *this;
56 }
57 private Proxy proxy;
58 }
59
60 public nothrow InsertIterator<C> Inserter<C, I>(C& c, I i) where C is InsertionSequence and I is C.Iterator
61 {
62 return InsertIterator<C>(c, i);
63 }
64 }