Add const_pointer_cast(global_ptr<U>)
We currently allow explicit conversions between global_ptr<T>
and global_ptr<char>
. I propose we remove this and instead follow the pattern of std::shared_ptr
to introduce a full set of pointer casts (http://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast). This would also enable polymorphic casts.
Proposed API:
namespace upcxx {
template<typename T, typename U>
global_ptr<T> static_pointer_cast(global_ptr<U> ptr);
template<typename T, typename U>
global_ptr<T> dynamic_pointer_cast(global_ptr<U> ptr);
template<typename T, typename U>
global_ptr<T> const_pointer_cast(global_ptr<U> ptr);
template<typename T, typename U>
global_ptr<T> reinterpret_pointer_cast(global_ptr<U> ptr);
} // namespace upcxx
We would specify similar semantics and constraints as in http://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast. For dynamic_pointer_cast
, we would additionally require ptr.is_local()
.
On a tangential note, we should also add a type member global_ptr<T>::element_type
that aliases T
.
Comments (12)
-
reporter -
reporter Added
global_ptr<T>::element_type
in 01a04cc. -
- changed component to Global Pointers
-
- changed milestone to 2017.12.31 release
-
- changed milestone to 2018.09.30 release
-
- marked as minor
This issue was triaged at the 2018-06-13 Pagoda meeting and assigned a new milestone/priority.
-
reporter I'm not in favor of providing
dynamic_pointer_cast
, as it cannot be done locally. The others are doable without any communication. -
const_pointer_cast
doesn't seem terribly useful until we resolve issue#51, as users would be wise to avoidglobal_ptr<const T>
entirely until then -
reporter Merged
static_pointer_cast
in d57cd44. -
- changed milestone to 2019.03.31 release
- changed version to Development branch (master)
- changed title to Add const_pointer_cast(global_ptr<U>)
The only remaining conversion we might implement is
const_pointer_cast(global_ptr<U>)
, once issue#51is resolved to makeglobal_ptr<const T>
usable in practice. -
- changed milestone to Deferred indefinitely
This issue was triaged at the 2019-07-24 Pagoda issue meeting and assigned a new milestone.
-
reporter - changed status to resolved
Resolved by PR #42.
- Log in to comment
Removed conversions between
global_ptr<T>
andglobal_ptr<char>
and addedreinterpret_pointer_cast
in dbe1a3a.