Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: swig/Lib/std/std_carray.swg

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/std/std_basic_string.i ('k') | swig/Lib/std/std_char_traits.i » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 %{
2 #include <algorithm>
3 %}
4
5 //
6 // std::carray - is really an extension to the 'std' namespace.
7 //
8 // A simple fix C array wrapper, more or less as presented in
9 //
10 // "The C++ Standarf Library", by Nicolai M. Josuttis
11 //
12 // which is also derived from the example in
13 //
14 // "The C++ Programming Language", by Bjarne Stroustup.
15 //
16
17 %inline %{
18 namespace std {
19 template <class _Type, size_t _Size>
20 class carray
21 {
22 public:
23 typedef _Type value_type;
24 typedef size_t size_type;
25
26 typedef _Type * iterator;
27 typedef const _Type * const_iterator;
28
29 carray() { }
30
31 carray(const carray& c) {
32 std::copy(c.v, c.v + size(), v);
33 }
34
35 template <class _Iterator>
36 carray(_Iterator first, _Iterator last) {
37 assign(first, last);
38 }
39
40 iterator begin() { return v; }
41 iterator end() { return v + _Size; }
42
43 const_iterator begin() const { return v; }
44 const_iterator end() const { return v + _Size; }
45
46 _Type& operator[](size_t i) { return v[i]; }
47 const _Type& operator[](size_t i) const { return v[i]; }
48
49 static size_t size() { return _Size; }
50
51 template <class _Iterator>
52 void assign(_Iterator first, _Iterator last) {
53 if (std::distance(first,last) == size()) {
54 std::copy(first, last, v);
55 } else {
56 throw std::length_error("bad range length");
57 }
58 }
59
60 private:
61 _Type v[_Size];
62 };
63 }
64 %}
OLDNEW
« no previous file with comments | « swig/Lib/std/std_basic_string.i ('k') | swig/Lib/std/std_char_traits.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698