[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/hsutter/cppfront/main/docs/cpp2/expressions.md [Back]  [Original]

# Common expressions

##  Calling functions: `f(x)` syntax, `x.f()` UFCS syntax, and `x..f()` members-only syntax

A function argument list is a [list](common.md#lists) of arguments enclosed by `(` `)` parentheses.

A function call like `f(x)` is a normal function call that will call non-member functions only, as usual in C++.

A function call like `x.f()` is a unified function call syntax (aka UFCS) call. It will call a member function if one is available, and otherwise will call `f(x)`. Having UFCS is important for generic code that may want to call a member or a non-member function, whichever is available. It's also important to enable fluid programming styles and natural IDE autocompletion support.

An operator notation call like `#!cpp a + b` will call an overloaded operator function if one is available, as usual in C++.

A function call like `x..f()` will consider member functions only.

For example:

``` cpp title="Function calls" hl_lines="3 7 11 16 19 20"
//  Generic function to log something
//  This calls operator

Web Proxy Viewer  |  New URL  |  Original Page