tags:

views:

394

answers:

4

Are there any operators in D that are not in C++?

+3  A: 

I didn't program D in a long time, but I think it has opApply for use in foreach - I don't know if you count it as an operator, but it sure is documented as such :)

LukeN
Ok, Thanks Sadface.
Winter
+5  A: 
  • ^^ and ^^= for exponentiation
  • ~ and ~= for concatenation
  • >>> and >>>= for signed (or is it unsigned) bit shift
BCS
D has exponentiation? Wasn't ^ xor?
CyberShadow
oops, it's `^^` and `^^=`
BCS
+5  A: 

Here is a list of some D tokens

/=
.
..
...
&
&=
&&
|
|=
||
-
-=
--
+
+=
++
<
<=
<<
<<=
<>
<>=
>
>=
>>=
>>>=
>>
>>>
!
!=
!<>
!<>=
!<
!<=
!>
!>=
(
)
[
]
{
}
?
,
;
:
$
=
==
*
*=
%
%=
^
^=
~
~=

Those for example:

<>
<>=
!<>
!<>=
!<
!<=
!>
!>=

are special operators to compare floating point variables. You can find the description of them here http://www.digitalmars.com/d/1.0/expression.html

There are also the

is 
!is
in
!in
typeof

operators.

Maciej Hehl
Super, thats a great list. Thanks.
Winter
`in` and `!in`.
KennyTM
Walter Bright said that the floating-point comparisons with NaN support (!<> !<>= !< !<= !> !>=) will be deprecated.
ponce
+3  A: 

Similar to Sadface's opApply there is also opCall for overloading when () is used, useful in structs. In fact on the Operator Overloading page there is a number of these:

opIndex
opIndexAssign
opSlice
opSliceAssign
opDispatch -- Rather interesting addition in D2
he_the_great
opDispatch is amazing. It's like overloading the '.' operator is c++.
caspin