clang-format: Always break template declarations

I find this format easier to read, because the definitions are at the
expected indentation, making it easier to find what I'm looking for.
This commit is contained in:
Riku Isokoski 2023-01-25 11:24:38 +02:00
parent 512ebf0704
commit 6dc49e5bdb
5 changed files with 17 additions and 9 deletions

View file

@ -20,7 +20,7 @@ AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false BinPackArguments: false
BinPackParameters: false BinPackParameters: false
BraceWrapping: BraceWrapping:

View file

@ -1,7 +1,8 @@
#include <array> #include <array>
#include <cstddef> #include <cstddef>
template <typename T, size_t N> class StaticStack { template <typename T, size_t N>
class StaticStack {
public: public:
T Pop(); T Pop();
void Push(T element); void Push(T element);
@ -15,24 +16,28 @@ private:
}; };
// Returns random data when popping from empty array. // Returns random data when popping from empty array.
template <typename T, size_t N> T StaticStack<T, N>::Pop() { template <typename T, size_t N>
T StaticStack<T, N>::Pop() {
if (stackPointer > 0) { if (stackPointer > 0) {
stackPointer--; stackPointer--;
} }
return elementArray[stackPointer]; return elementArray[stackPointer];
} }
template <typename T, size_t N> void StaticStack<T, N>::Push(T element) { template <typename T, size_t N>
void StaticStack<T, N>::Push(T element) {
if (stackPointer < elementArray.size()) { if (stackPointer < elementArray.size()) {
elementArray[stackPointer] = element; elementArray[stackPointer] = element;
stackPointer++; stackPointer++;
} }
} }
template <typename T, size_t N> void StaticStack<T, N>::Reset() { template <typename T, size_t N>
void StaticStack<T, N>::Reset() {
stackPointer = 0; stackPointer = 0;
} }
template <typename T, size_t N> T StaticStack<T, N>::Top() { template <typename T, size_t N>
T StaticStack<T, N>::Top() {
return elementArray[stackPointer - 1]; return elementArray[stackPointer - 1];
} }

View file

@ -7,7 +7,8 @@ namespace Pinetime {
namespace Utility { namespace Utility {
// based on: https://github.com/SHristov92/LinearApproximation/blob/main/Linear.h // based on: https://github.com/SHristov92/LinearApproximation/blob/main/Linear.h
template <typename Key, typename Value, std::size_t Size> class LinearApproximation { template <typename Key, typename Value, std::size_t Size>
class LinearApproximation {
using Point = struct { using Point = struct {
Key key; Key key;
Value value; Value value;

View file

@ -10,7 +10,8 @@ namespace Pinetime {
namespace Screens { namespace Screens {
template <class T> class DirtyValue { template <class T>
class DirtyValue {
public: public:
DirtyValue() = default; // Use NSDMI DirtyValue() = default; // Use NSDMI

View file

@ -12,7 +12,8 @@ namespace Pinetime {
enum class ScreenListModes { UpDown, RightLeft, LongPress }; enum class ScreenListModes { UpDown, RightLeft, LongPress };
template <size_t N> class ScreenList : public Screen { template <size_t N>
class ScreenList : public Screen {
public: public:
ScreenList(DisplayApp* app, ScreenList(DisplayApp* app,
uint8_t initScreen, uint8_t initScreen,