Both Google and Microsoft, like many other companies and organizations, have published coding guidelines for C++ to ensure consistency and readability. Let's explore what their coding standards might suggest regarding the question at hand. Keep in mind that the interpretations of these guidelines might vary, and adherence to local consistency within your own codebase is also important.
Google C++ Style Guide:
Google's C++ Style Guide suggests preferring a maximum line length of 80 characters but allows up to 120 characters if necessary for readability. It does not explicitly state how to handle single-line versus multi-line template declarations, but given the emphasis on readability and avoiding long lines, Google's guidelines would likely suggest breaking up the declaration if it exceeds the comfortable line length.
For example, if the declaration is short, it could be on a single line:
template <typename T> void Foo(T t);
But for longer declarations, Google's style would favor breaking it into multiple lines:
template <typename DrawFunction>
void WithColor(const Color& color, DrawFunction draw);
Microsoft C++ Coding Conventions:
While Microsoft's C++ Coding Conventions do not explicitly dictate how to write template declarations, they focus on readability and maintainability, much like Google's. As part of general readability, Microsoft's guidelines suggest being attentive to whitespaces and alignment.
Based on a readability-centric approach, Microsoft's guidelines might also imply using multiple lines when declarations become complex or lengthy:
template <typename DrawFunction>
void WithColor(const Color& color, DrawFunction draw);
Modern C++ Idioms and Community Practice:
In modern C++ practices, aligning with community standards and conventions derived from high-profile open-source projects can also be valuable. Such projects often prefer readability and explicitness over compact code, which might include using multi-line template declarations to keep code clear:
template <typename DrawFunction>
void WithColor(const Color& color, DrawFunction draw);
Recommendation:
While both Google and Microsoft emphasize readability, Google provides more concrete guidelines on line length, which greatly affects how template declarations are formatted. Most organization's coding standards tend to favor what is more readable for their team. In the absence of a specific style requirement, as long as your declarations are clear and consistent across your codebase, either style should be acceptable.
Given your specific example, while both of your provided formats are fairly concise, you might find a slight preference for the multi-line declaration in line with readability best practices, especially if adopting guidelines similar to those proposed by Google or if you plan on extending your project with more complex templates in the future. This approach would leave room for consistent expansion of the template parameter list without the need to reformat existing code.