What does a fancy pointer look like?

The C ++ link mentions a concept called fancy pointers . I learned of their existence from a recent highly voted and subsequently deleted question.

Definition fuzzy:

If the item type pointer is not a raw pointer type, it is usually called a "fancy pointer".

An example of their use:

An example of a fancy pointer is a map that does not depend on the address of pointer boost :: interprocess :: offset_ptr, which allows you to select node data structures, such as std :: set in shared memory and files with memory mappings displayed at different addresses in each process. Fancy pointers can be used regardless of the distributor that provided them through the class template std :: pointer_traits.

I do not understand this explanation. What is the syntax for creating a fancy pointer, and why can't I use a regular pointer in this case?

+5
source share
1 answer

A fancy pointer is just a term for what acts as a pointer but is not. Take, for example, an iterator. Almost all iterators are types of user classes, but they behave exactly like a pointer (sometimes there are restrictions, and you cannot perform all the operations supported by the pointer, because they do not provide random access, but this is part of the quirkiness.)

In other words: an abstraction that acts like a pointer is a fancy pointer.

+6
source

Source: https://habr.com/ru/post/1266851/


All Articles