File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -148,8 +148,9 @@ int main()
148148 NativeReadWriter native_read_writer;
149149 InherritedReadWriter inherrited_read_writer;
150150 AbstractWriter * base_ptr = new DerivedReadWriter ();
151- std::vector<writable::view> views (4 );
152151
152+ // Creating standard views
153+ std::vector<writable::view> views (4 );
153154 views[0 ].bind (composed_read_writer);
154155 views[1 ].bind (native_read_writer);
155156 views[2 ].bind (inherrited_read_writer);
@@ -159,6 +160,11 @@ int main()
159160 view.write (" hello\r\n " , 7 );
160161 }
161162
163+ // Creating views with pointer syntax
164+ writable::ptr<> view_ptr;
165+ view_ptr.bind (native_read_writer);
166+ view_ptr->write (" hello from view_ptr\r\n " , 21 );
167+
162168
163169 delete base_ptr;
164170 return 0 ;
Original file line number Diff line number Diff line change @@ -129,9 +129,16 @@ template <typename W> struct StatefulWriteAPI : public W {
129129 size += this ->write (buf, strlen (buf));
130130 return size;
131131 }
132+
133+ int get_count (){ return count; }
134+ private:
132135 int count = 0 ;
133136};
134137
138+
139+ template <typename T>
140+ using ReadWriteAPI = ReadAPI<StatefulWriteAPI<T>>;
141+
135142int main ()
136143{
137144
@@ -184,6 +191,15 @@ int main()
184191 stateful_augmented_view.write_api (" Hello from stateful augmentation\r\n " );
185192 stateful_augmented_view.write_api (" Hello from stateful augmentation\r\n " );
186193
194+
195+ // Augment pointers with mixins
196+ readwritable::ptr<ReadWriteAPI> read_write_ptr;
197+ read_write_ptr.bind (composed_read_writer_instance);
198+ char buf[5 ];
199+ int read_size;
200+ while (read_write_ptr->get_count () < 3 ){
201+ }
202+
187203 return 0 ;
188204
189205}
You can’t perform that action at this time.
0 commit comments