Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

C++ 14 Whitespace overloading


Marsh
 Share

Recommended Posts

C++14 Whitespace Overloading

This is an old idea from Bjarne Stroustrup (Creator of c++) finally making it into the standard.  The idea is to be able to write:

x y

to mean "multiply x by y".  The implementation is simple:

```

float operator (float a, float b) { return a * b; }
```

or more explicitly:

```

float operator ' '(float a, float b) { return a * b; }
```

There are actually much more to Stroustrup proposal, which I suggest you to read: [http://www.stroustrup.com/whitespace98.pdf](http://www.stroustrup.com/whitespace98.pdf).  It's an interesting and good read, and depending on your mindset and personality, it can also be a good laugh.

Even if not all the compilers on the floor actually fully support C++14, You should use whitespace overloading anyway.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...