@@ -174,7 +174,7 @@ but it works the same for all `multi_ptr` types.
174174
175175```cpp
176176using namespace cl::sycl;
177- const global_ptr<int> ptrInt = get_some_global_ptr();
177+ const global_ptr<int> ptrInt = get_some_global_ptr<int> ();
178178
179179// Conversion operator
180180auto ptrFloat1 = static_cast<global_ptr<float>>(ptrInt);
@@ -199,24 +199,44 @@ auto ptrConstInt4 = reinterpret_pointer_cast<const int>(ptrInt);
199199
200200### ` dynamic_pointer_cast `
201201
202- TODO(Peter)
202+ ``` cpp
203+ struct Base {
204+ virtual void foo() const {}
205+ virtual ~ Base(){}
206+ };
207+ struct Derived : public Base {
208+ void foo() const override {}
209+ };
203210
204- ### Passing ` multi_ptr ` to functions
211+ using namespace cl::sycl;
212+ const global_ptr<Base > ptrBase = get_some_global_ptr<int >();
205213
206- TODO(Peter)
214+ auto ptrDerived = dynamic_pointer_cast<Derived >(ptrBase);
215+ auto ptrBase1 = dynamic_pointer_cast<Base >(ptrDerived);
216+ ```
207217
208- Implicit conversion to ` multi_ptr<const ElementType, Space> ` :
218+ ### Passing `multi_ptr` to functions
209219
210220```cpp
211-
212221using namespace cl::sycl;
213222
223+ template <typename ElementType, access::address_space Space>
224+ void function_taking_ptr(const multi_ptr<ElementType, Space>& ptr);
214225template <typename ElementType, access::address_space Space>
215226void function_taking_const_ptr(const multi_ptr<const ElementType, Space>& ptr);
216227
217- const global_ptr<int > ptrInt = get_some_global_ptr();
228+ const global_ptr<int> ptrInt = get_some_global_ptr<int> ();
218229
219- // function_taking_const_ptr(static_cast<const int >(static_cast<void >(ptrInt)));
230+ function_taking_ptr(ptrInt);
231+ // Implicit conversion to global_ptr<const int>:
220232function_taking_const_ptr(ptrInt);
221233
234+ const global_ptr<float> ptrFloat = get_some_global_ptr<float>();
235+
236+ // Convert float to int pointer
237+ function_taking_ptr(reinterpret_ptr_cast<int>(ptrFloat));
238+ // First explicit conversion to global_ptr<int>
239+ // and then implicit conversion to global_ptr<const int>:
240+ function_taking_const_ptr(reinterpret_ptr_cast<int>(ptrFloat));
241+
222242```
0 commit comments