Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comma between operators in C++

Today I came across this piece of code (inside boost/type_index/type_index_facade.hpp, lines 252-259).

/// noexcept comparison operators for type_index_facade classes.
bool operator ==, !=, <, ... (const type_index_facade& lhs, const type_index_facade& rhs) noexcept;

/// noexcept comparison operators for type_index_facade and it's TypeInfo classes.
bool operator ==, !=, <, ... (const type_index_facade& lhs, const TypeInfo& rhs) noexcept;

/// noexcept comparison operators for type_index_facade's TypeInfo and type_index_facade classes.
bool operator ==, !=, <, ... (const TypeInfo& lhs, const type_index_facade& rhs) noexcept;

Can someone explain me what does it mean? I have never seen before something like "==, !=, <, ..."

like image 339
Mattia F. Avatar asked Jun 14 '16 15:06

Mattia F.


People also ask

What operator is comma?

The comma operator ( , ) evaluates each of its operands (from left to right) and returns the value of the last operand. This lets you create a compound expression in which multiple expressions are evaluated, with the compound expression's final value being the value of the rightmost of its member expressions.

How is the comma operator used in for loop in C?

The comma operator will always yield the last value in the comma separated list. Basically it's a binary operator that evaluates the left hand value but discards it, then evaluates the right hand value and returns it. If you chain multiple of these they will eventually yield the last value in the chain.

What is comma operator with example?

Sometimes we assign multiple values to a variable using comma, in that case comma is known as operator. Example: a = 10,20,30; b = (10,20,30); In the first statement, value of a will be 10, because assignment operator (=) has more priority more than comma (,), thus 10 will be assigned to the variable a.

What is comma and sizeof operator in C?

The comma operator has no special meaning to sizeof . sizeof(b, a) examines the complete expression (b, a) , works out the resultant type, and computes the size of that type without actually evaluating (b , a) .


1 Answers

You'll notice that these are written within:

#if defined(BOOST_TYPE_INDEX_DOXYGEN_INVOKED)
    ...
#endif

This is just a hack to make doxygen use these "simplified" declarations in the documentation. This bit of the code is never compiled.

like image 73
md5i Avatar answered Oct 19 '22 17:10

md5i