I have looked at the clang-format style options https://clang.llvm.org/docs/ClangFormatStyleOptions.html but don't see any reference to c++ concepts and requires clauses. Normally I can configure clang-format to do what I want but I can't figure out how to get it to handle my concepts and requires clauses nicely:
template <typename F, typename P, typename T>
concept Accumulate_Fn = Parser<P>&& std::invocable<F, T, parser_t<P>>&&
std::same_as<T, std::invoke_result_t<F, T, parser_t<P>>>;
But I would like to put each one constraint on its own line (as it does for function arguments that get too long) so that the result would look like:
template <typename F, typename P, typename T>
concept Accumulate_Fn = Parser<P> &&
std::invocable<F, T, parser_t<P>> &&
std::same_as<T, std::invoke_result_t<F, T, parser_t<P>>>;
template <Parser P1, Parser P2, typename T, Accumulate_Fn<P1, parser_t<P1>> F>
requires std::same_as<T, parser_t<P1>> constexpr Parser auto
separated_by(P1&& p1, P2&& p2, T&& init, F&& f)
But I would like something much closer to :
template <Parser P1, Parser P2, typename T, Accumulate_Fn<P1, parser_t<P1>> F>
requires std::same_as<T, parser_t<P1>>
constexpr Parser auto separated_by(P1&& p1, P2&& p2, T&& init, F&& f)
Are there any magical options that will make that work? I'm currently on clang-format 10.0.
clang-format is located in clang/tools/clang-format and can be used to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows. The workflow to format your changed code: Make codes changes in Electron repository.
clang-format file, we need to place it in the project folder or in any parent folder of the file you want to format. clang-format.exe searches for the config file automatically starting with the folder where the file you want to format is located, all the way to the topmost directory.
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the . clang-format or _clang-format file in the project directory.
As of Jul/20, Concepts are not properly supported by clang-format
. There is an open issue in LLVM tracker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With