semantics

The void type in C

落爺英雄遲暮 提交于 2020-12-29 12:03:22
问题 The void type in C seems to be strange from various different situations. Sometimes it behaves like a normal object type, such as int or char , and sometimes it just means nothing (as it should). Look at my snippet. First of all, it seems strange that you can declare a void object, meaning you just declare nothing. Then I created an int variable and casted its result to void , discarding it: If an expression of any other type is evaluated as a void expression, its value or designator is

When is a `value_type` of an iterator used?

Deadly 提交于 2020-12-08 07:06:40
问题 I am trying to understand when an iterator::value_type is actually used. Because, all operators of iterators, seem to use only iterator::pointer and iterator::reference . Question: Is iterator::value_type actually used for something? Extra question: Would an iterator inherited from std::iterator<std::random_access_iterator_tag, int, std::ptrdiff_t, bool*, bool&> raise some semantic issues? EDIT: To understand why I am asking this question, it's because I am working on an iterator for a type