xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/fuchsia/trailing-return.rst (revision 6b95787acc5b2628a3d544c70cb0727a1975150d)
1.. title:: clang-tidy - fuchsia-trailing-return
2
3fuchsia-trailing-return
4=======================
5
6Functions that have trailing returns are disallowed, except for those using
7``decltype`` specifiers and lambda with otherwise unutterable return types.
8
9For example:
10
11.. code-block:: c++
12
13  // No warning
14  int add_one(const int arg) { return arg; }
15
16  // Warning
17  auto get_add_one() -> int (*)(const int) {
18    return add_one;
19  }
20
21Exceptions are made for lambdas and ``decltype`` specifiers:
22
23.. code-block:: c++
24
25  // No warning
26  auto lambda = [](double x, double y) -> double {return x + y;};
27
28  // No warning
29  template <typename T1, typename T2>
30  auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
31    return lhs + rhs;
32  }
33
34
35See the features disallowed in Fuchsia at https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/cxx?hl=en
36