Skip to content

Instantly share code, notes, and snippets.

@twof
Created February 6, 2019 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twof/2f979088bdddafff72f7df8ce63f3c2b to your computer and use it in GitHub Desktop.
Save twof/2f979088bdddafff72f7df8ce63f3c2b to your computer and use it in GitHub Desktop.
template<typename... Extensions>
auto with_extension(WaylandExtensions const& wayland_extensions,
std::string const& name, std::function<std::shared_ptr<void>(wl_display*)> builder, // This line contains two function arguments, where the others have one. This makes it harder to quickly visually scan down the argument list
Extensions... extensions) -> WaylandExtensions // This line and the one below it are one space behind the inidentation level of the function argument above it. Also shares this line with the return type
{
return with_extension(with_extension(wayland_extensions, name, builder), extensions...);
}
// suggestion
template<typename... Extensions>
auto with_extension(
WaylandExtensions const& wayland_extensions, // Each function argument gets its own line, and only one per line. Makes it easy to visually scan the list in a verticle fashion
std::string const& name, // All arguments at the same indentation level. Easy to distinguish name, arguments, return type, and body at a glance
std::function<std::shared_ptr<void>(wl_display*)> builder,
Extensions... extensions
) -> WaylandExtensions { // Return type on its own line and indentation level. Acts as a visual seperator between arguments and function body
return with_extension(with_extension(wayland_extensions, name, builder), extensions...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment