How to use Ctags with C++ trailing return types

217 Views Asked by At

I've come to like C++11 style trailing return types, however when I wanted to use vim with my C++ program I noticed that ctags don't mix well with them.

I've tried exuberant ctags and universal ctags and both don't seem to work with trailing return types.

Is there some way to configure ctags to cooperate with trailing return types?

1

There are 1 best solutions below

0
On

The latest Universal ctags can extract the name and the return type of a function with trailing return type:

auto f(void) -> int
{
    return 0;
}
$ ~/bin/ctags --version
Universal Ctags 5.9.0(cbdc5c4b6), Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jun 20 2022, 00:48:48
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript, +pcre2
$ ~/bin/ctags -o - /tmp/foo.cpp 
f   /tmp/foo.cpp    /^auto f(void) -> int$/;"   f   typeref:typename:int