struct Stuff {
int i;
//What is this type/classification of operator called?
operator int&() {return i;}
};
Pedantic C++ Take 3
I've found a few instances of them informally/incorrectly being refered to as "cast operators", however a "cast operator" would be static_cast<>() and friends (and the C-style cast), as distinct from what you are refering to.
I was wondering if anyone would respond cast operators because it's used so much to describe that type of operator. I've seen them called that almost everywhere. Since I was looking for conversion operator, I had trouble tracking down 'conversion function'.
Seems like conversion operator isn't too far off the mark though, but as Andrew notes cast operators really are something else!
Seems like conversion operator isn't too far off the mark though, but as Andrew notes cast operators really are something else!
I call it a cast operator because it is an operator that is called when casting. Just like operator + is called when applying + on an object.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement