The standard arithmetic operators, such as *
and +
, work as expected on classes like atomic< int >
. However, I can't find any definition of them in the <atomic>
header file and no reference to them in the standard.
Are they defined implicitly somewhere or am I just looking in the wrong place?
For example, where is the multiplication function called in the following code defined?
#include <iostream>
#include <atomic>
using namespace std;
int main() {
atomic< int > i( 42 );
atomic< float > f( 6.66 );
cout << i * f;
//cout << operator*( i, f); //error: ‘operator*’ not defined
return 0;
}
For anyone else reading this question there is a nice discussion of what is going on here.