Factorial operator

Purely academic, so I put it in bar sport.

Does the ! operator do anything when it comes behind a number? Like 4!. Would it be possible to redefine it somehow to return the factorial of a number when used with a single argument to the left.

Even if not in C++, I've been trying to think through possible use cases in my head where it could be ambiguous with the one with a rhs argument. It seems like it would mostly show up in expressions with another operator to one side or the other depending on use. But I'm not sure I'm thinking through all of them. Anybody see one?

I don't believe that the language supported by the Gnu C++ compiler has a factorial operator but a recursive function that computes a factorial is trivial to write as a beginning programming exercise.

Delta_G: Does the ! operator do anything when it comes behind a number? Like 4!.

No. ! is purely prefix.

Would it be possible to redefine it somehow to return the factorial of a number when used with a single argument to the left.

Not currently. A change to the language then a change to the compiler are needed to add postfix-!.

Anybody see one?

There is not.

If you could overload postfix-! you would be good. (Being able to overload undefined operators would be an interesting language feature.)

Thanks CB. That answered the question perfectly. I didn't know if the prefix/postfix - ness of an operator was set in stone or if it could be defined.