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::pointer
convertiblex::const_pointer
*p
has typet&
,p
of typex::pointer
*q
has typet const&
q
of typex::const_pointer
p->m
has typet::m
(conditioned on(*p).m
being well-defined)q->m
has typet::m
(conditioned on(*q).m
being well-defined)
all of requirements satisfed pointer
being shared_ptr<t>
. in case, pointer
not same value_type*
(which t*
).
Comments
Post a Comment