i have doubt regarding question, in particular this answer.
there part is left exercise reader (it not problem itself), in particular jonathan wakely (the author of answer) said that:
this code asserts allocator::pointer allocator::value_type*
that expressed in code as:
static_assert(std::is_same<typename at::pointer, typename at::value_type*>::value, "allocator doesn't use fancy pointers"); at time, got answer , that's all.
when reading again after while, found myself asking aloud: fancy pointers?
here (documentation of allocator_traits), pointer defined as:
alloc::pointer if present, otherwise value_type*
the question arose: what's realistic case in allocator::pointer , allocator::value_type* differ?
the requirements allocator laid out in [allocator.requirements]. allocator class x type t, relevant requirements see are:
x::pointerconvertiblex::const_pointer*phas typet&,pof typex::pointer*qhas typet const&qof typex::const_pointerp->mhas typet::m(conditioned on(*p).mbeing well-defined)q->mhas typet::m(conditioned on(*q).mbeing well-defined)
all of requirements satisfed pointer being shared_ptr<t>. in case, pointer not same value_type* (which t*).
Comments
Post a Comment