Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,31 +1,27 @@
#pragma once
template <typename T>
class Matrix
template<typename T> class Matrix
{
public:
T m_data[4][4];
Matrix()
: m_data{
{T(1.0), 0, 0, 0},
{0, T(1.0), 0, 0},
{0, 0, T(1.0), 0},
{0, 0, 0, T(1.0)}
}
{T(1.0), 0, 0, 0 },
{0, T(1.0), 0, 0 },
{0, 0, T(1.0), 0 },
{0, 0, 0, T(1.0)}
}
{
}
Matrix(T d00, T d01, T d02, T d03,
T d10, T d11, T d12, T d13,
T d20, T d21, T d22, T d23,
T d30, T d31, T d32, T d33)
Matrix(T d00, T d01, T d02, T d03, T d10, T d11, T d12, T d13, T d20, T d21, T d22, T d23, T d30, T d31, T d32, T d33)
: m_data{
{d00, d01, d02, d03},
{d10, d11, d12, d13},
{d20, d21, d22, d23},
{d30, d31, d32, d33}
}
}
{
}

View File

@ -1,10 +1,9 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "Matrix.h"
#include "Utils/ClassUtils.h"
template <typename T>
class Quaternion
template<typename T> class Quaternion
{
public:
T m_x;
@ -50,12 +49,7 @@ public:
const T m21 = 2 * yz + 2 * xw;
const T m22 = 1 - 2 * xx - 2 * yy;
return Matrix<T>(
m00, m01, m02, 0,
m10, m11, m12, 0,
m20, m21, m22, 0,
0, 0, 0, T(1.0)
);
return Matrix<T>(m00, m01, m02, 0, m10, m11, m12, 0, m20, m21, m22, 0, 0, 0, 0, T(1.0));
}
};

View File

@ -1,26 +1,25 @@
#pragma once
#include <cassert>
#include "Utils/ClassUtils.h"
template <typename T>
class Vector2
#include <cassert>
template<typename T> class Vector2
{
T m_value[2];
public:
Vector2()
: m_value{ T(0), T(0)}
: m_value{T(0), T(0)}
{
}
Vector2(T x, T y)
: m_value{ x, y }
: m_value{x, y}
{
}
explicit Vector2(const T* value)
: m_value{ value[0], value[1] }
: m_value{value[0], value[1]}
{
}
@ -36,33 +35,47 @@ public:
return m_value[index];
}
_NODISCARD T& x() { return m_value[0]; }
_NODISCARD T& y() { return m_value[1]; }
_NODISCARD const T& x() const { return m_value[0]; }
_NODISCARD const T& y() const { return m_value[1]; }
_NODISCARD T& x()
{
return m_value[0];
}
_NODISCARD T& y()
{
return m_value[1];
}
_NODISCARD const T& x() const
{
return m_value[0];
}
_NODISCARD const T& y() const
{
return m_value[1];
}
};
typedef Vector2<float> Vector2f;
typedef Vector2<double> Vector2d;
template <typename T>
class Vector3
template<typename T> class Vector3
{
T m_value[3];
public:
Vector3()
: m_value{ T(0), T(0), T(0) }
: m_value{T(0), T(0), T(0)}
{
}
Vector3(T x, T y, T z)
: m_value{ x, y, z }
: m_value{x, y, z}
{
}
explicit Vector3(const T* value)
: m_value{ value[0], value[1], value[2] }
: m_value{value[0], value[1], value[2]}
{
}
@ -78,26 +91,71 @@ public:
return m_value[index];
}
_NODISCARD T& x() { return m_value[0]; }
_NODISCARD T& y() { return m_value[1]; }
_NODISCARD T& z() { return m_value[2]; }
_NODISCARD const T& x() const { return m_value[0]; }
_NODISCARD const T& y() const { return m_value[1]; }
_NODISCARD const T& z() const { return m_value[2]; }
_NODISCARD T& x()
{
return m_value[0];
}
_NODISCARD T& r() { return m_value[0]; }
_NODISCARD T& g() { return m_value[1]; }
_NODISCARD T& b() { return m_value[2]; }
_NODISCARD const T& r() const { return m_value[0]; }
_NODISCARD const T& g() const { return m_value[1]; }
_NODISCARD const T& b() const { return m_value[2]; }
_NODISCARD T& y()
{
return m_value[1];
}
_NODISCARD T& z()
{
return m_value[2];
}
_NODISCARD const T& x() const
{
return m_value[0];
}
_NODISCARD const T& y() const
{
return m_value[1];
}
_NODISCARD const T& z() const
{
return m_value[2];
}
_NODISCARD T& r()
{
return m_value[0];
}
_NODISCARD T& g()
{
return m_value[1];
}
_NODISCARD T& b()
{
return m_value[2];
}
_NODISCARD const T& r() const
{
return m_value[0];
}
_NODISCARD const T& g() const
{
return m_value[1];
}
_NODISCARD const T& b() const
{
return m_value[2];
}
};
typedef Vector3<float> Vector3f;
typedef Vector3<double> Vector3d;
template <typename T>
class Vector4
template<typename T> class Vector4
{
T m_value[4];
@ -113,7 +171,7 @@ public:
}
explicit Vector4(const T* value)
: m_value{ value[0], value[1], value[2], value[3] }
: m_value{value[0], value[1], value[2], value[3]}
{
}
@ -129,23 +187,85 @@ public:
return m_value[index];
}
_NODISCARD T& x() { return m_value[0]; }
_NODISCARD T& y() { return m_value[1]; }
_NODISCARD T& z() { return m_value[2]; }
_NODISCARD T& w() { return m_value[3]; }
_NODISCARD const T& x() const { return m_value[0]; }
_NODISCARD const T& y() const { return m_value[1]; }
_NODISCARD const T& z() const { return m_value[2]; }
_NODISCARD const T& w() const { return m_value[3]; }
_NODISCARD T& x()
{
return m_value[0];
}
_NODISCARD T& r() { return m_value[0]; }
_NODISCARD T& g() { return m_value[1]; }
_NODISCARD T& b() { return m_value[2]; }
_NODISCARD T& a() { return m_value[3]; }
_NODISCARD const T& r() const { return m_value[0]; }
_NODISCARD const T& g() const { return m_value[1]; }
_NODISCARD const T& b() const { return m_value[2]; }
_NODISCARD const T& a() const { return m_value[3]; }
_NODISCARD T& y()
{
return m_value[1];
}
_NODISCARD T& z()
{
return m_value[2];
}
_NODISCARD T& w()
{
return m_value[3];
}
_NODISCARD const T& x() const
{
return m_value[0];
}
_NODISCARD const T& y() const
{
return m_value[1];
}
_NODISCARD const T& z() const
{
return m_value[2];
}
_NODISCARD const T& w() const
{
return m_value[3];
}
_NODISCARD T& r()
{
return m_value[0];
}
_NODISCARD T& g()
{
return m_value[1];
}
_NODISCARD T& b()
{
return m_value[2];
}
_NODISCARD T& a()
{
return m_value[3];
}
_NODISCARD const T& r() const
{
return m_value[0];
}
_NODISCARD const T& g() const
{
return m_value[1];
}
_NODISCARD const T& b() const
{
return m_value[2];
}
_NODISCARD const T& a() const
{
return m_value[3];
}
};
typedef Vector4<float> Vector4f;

View File

@ -2,19 +2,17 @@
namespace utils
{
template <typename T>
constexpr T Align(const T value, const T toNext)
template<typename T> constexpr T Align(const T value, const T toNext)
{
if (toNext > 0)
return (value + toNext - 1) / toNext * toNext;
return value;
}
template <typename T>
constexpr T AlignToPrevious(const T value, const T toPrevious)
template<typename T> constexpr T AlignToPrevious(const T value, const T toPrevious)
{
if (toPrevious > 0)
return value / toPrevious * toPrevious;
return value;
}
}
} // namespace utils

View File

@ -1,4 +1,5 @@
#include "ArgumentParser.h"
#include <sstream>
const std::string PREFIX_LONG = "--";
@ -6,7 +7,7 @@ const std::string PREFIX_SHORT = "-";
ArgumentParser::ArgumentParser(const CommandLineOption* const* options, const size_t optionCount)
{
for(unsigned optionIndex = 0; optionIndex < optionCount; optionIndex++)
for (unsigned optionIndex = 0; optionIndex < optionCount; optionIndex++)
{
m_command_line_options.push_back(options[optionIndex]);
}
@ -15,8 +16,8 @@ ArgumentParser::ArgumentParser(const CommandLineOption* const* options, const si
bool ArgumentParser::ParseArguments(const int argc, const char** argv)
{
std::vector<std::string> args(argc);
for(int arg = 0; arg < argc; arg++)
for (int arg = 0; arg < argc; arg++)
{
args[arg] = argv[arg];
}
@ -34,23 +35,23 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
{
std::string& arg = args[argIndex];
if(arg.compare(0, PREFIX_SHORT.size(), PREFIX_SHORT) == 0)
if (arg.compare(0, PREFIX_SHORT.size(), PREFIX_SHORT) == 0)
{
// Options should be case insensitive. So before comparing we make the argument lower case.
const size_t argStrLen = arg.size();
for(unsigned argStrIndex = 0; argStrIndex < argStrLen; argStrIndex++)
for (unsigned argStrIndex = 0; argStrIndex < argStrLen; argStrIndex++)
{
arg[argStrIndex] = tolower(arg[argStrIndex]);
}
const CommandLineOption* matchedOption = nullptr;
if(arg.compare(0, PREFIX_LONG.size(), PREFIX_LONG) == 0)
if (arg.compare(0, PREFIX_LONG.size(), PREFIX_LONG) == 0)
{
std::string longName = arg.substr(2);
for (auto option : m_command_line_options)
{
if(option->m_long_name == longName)
if (option->m_long_name == longName)
{
matchedOption = option;
break;
@ -63,7 +64,7 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
for (auto option : m_command_line_options)
{
if(option->m_short_name == shortName)
if (option->m_short_name == shortName)
{
matchedOption = option;
break;
@ -71,15 +72,15 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
}
}
if(matchedOption == nullptr)
if (matchedOption == nullptr)
{
printf("Unknown option '%s'.\n", arg.c_str());
return false;
}
if(m_matched_options.find(matchedOption) != m_matched_options.end())
if (m_matched_options.find(matchedOption) != m_matched_options.end())
{
if(!matchedOption->m_multi_use)
if (!matchedOption->m_multi_use)
{
printf("Option '%s' already specified.\n", arg.c_str());
return false;
@ -89,20 +90,20 @@ bool ArgumentParser::ParseArguments(std::vector<std::string>& args)
{
m_matched_options[matchedOption] = std::vector<std::string>();
}
const size_t parameterCount = matchedOption->m_parameters.size();
if(argIndex + parameterCount >= argCount)
if (argIndex + parameterCount >= argCount)
{
printf("Not enough parameters for option '%s'.\n", arg.c_str());
return false;
}
std::vector<std::string>& parameters = m_matched_options[matchedOption];
for(unsigned parameterIndex = 0; parameterIndex < parameterCount; parameterIndex++)
for (unsigned parameterIndex = 0; parameterIndex < parameterCount; parameterIndex++)
{
std::string& param = args[argIndex + parameterIndex + 1];
if(param.compare(0, PREFIX_SHORT.size(), PREFIX_SHORT) == 0)
if (param.compare(0, PREFIX_SHORT.size(), PREFIX_SHORT) == 0)
{
printf("Not enough parameters for option '%s'.\n", arg.c_str());
return false;
@ -129,14 +130,14 @@ std::vector<std::string> ArgumentParser::GetArguments() const
std::string ArgumentParser::GetValueForOption(const CommandLineOption* option)
{
if(!IsOptionSpecified(option))
if (!IsOptionSpecified(option))
return "";
std::stringstream value;
bool firstMatch = true;
for (const auto& match : m_matched_options[option])
{
if(!firstMatch)
if (!firstMatch)
{
value << " " << match;
}
@ -152,7 +153,7 @@ std::string ArgumentParser::GetValueForOption(const CommandLineOption* option)
std::vector<std::string> ArgumentParser::GetParametersForOption(const CommandLineOption* option)
{
if(!IsOptionSpecified(option))
if (!IsOptionSpecified(option))
return std::vector<std::string>();
return m_matched_options[option];
@ -161,4 +162,4 @@ std::vector<std::string> ArgumentParser::GetParametersForOption(const CommandLin
bool ArgumentParser::IsOptionSpecified(const CommandLineOption* option)
{
return m_matched_options.find(option) != m_matched_options.end();
}
}

View File

@ -1,8 +1,9 @@
#pragma once
#include "CommandLineOption.h"
#include <map>
#include <string>
#include <vector>
#include <map>
class ArgumentParser
{
@ -12,7 +13,7 @@ class ArgumentParser
public:
ArgumentParser(const CommandLineOption* const* options, size_t optionCount);
bool ParseArguments(std::vector<std::string>& args);
bool ParseArguments(int argc, const char** argv);

View File

@ -32,4 +32,4 @@ public:
Builder& WithParameter(std::string parameterName);
Builder& Reusable();
CommandLineOption* Build() const;
};
};

View File

@ -1,7 +1,8 @@
#include "UsageInformation.h"
#include <iomanip>
#include <iostream>
#include <map>
#include <iomanip>
UsageInformation::ArgumentUsage::ArgumentUsage(std::string name, const bool optional)
{
@ -88,18 +89,14 @@ void UsageInformation::Print()
for (auto option : category.second)
{
str << std::setw(static_cast<std::streamsize>(longestShortName) + 1) << (!option->m_short_name.empty()
? "-" + option->m_short_name
: "");
str << std::setw(static_cast<std::streamsize>(longestShortName) + 1) << (!option->m_short_name.empty() ? "-" + option->m_short_name : "");
if (!option->m_short_name.empty() && !option->m_long_name.empty())
str << ", ";
else
str << " ";
str << std::setw(static_cast<std::streamsize>(longestLongName) + 2) << (!option->m_long_name.empty()
? "--" + option->m_long_name
: "");
str << std::setw(static_cast<std::streamsize>(longestLongName) + 2) << (!option->m_long_name.empty() ? "--" + option->m_long_name : "");
str << " ";
str << std::setw(longestArgumentLength) << GetOptionArgument(option);
@ -160,7 +157,6 @@ size_t UsageInformation::GetOptionArgumentLength(const CommandLineOption* option
parameterCombinedStringLength += param.length();
}
return parameterCount * 2 // < and >
+ parameterCombinedStringLength
+ (parameterCount > 1 ? parameterCount - 1 : 0); // One space between each argument
return parameterCount * 2 // < and >
+ parameterCombinedStringLength + (parameterCount > 1 ? parameterCount - 1 : 0); // One space between each argument
}

View File

@ -1,8 +1,9 @@
#pragma once
#include "CommandLineOption.h"
#include <sstream>
#include <string>
#include <vector>
#include <sstream>
class UsageInformation
{
@ -21,7 +22,7 @@ class UsageInformation
bool m_var_args;
void PrintUsageOverview(std::stringstream& str);
static std::string GetOptionArgument(const CommandLineOption* option);
static size_t GetOptionArgumentLength(const CommandLineOption* option);
@ -34,4 +35,4 @@ public:
void SetVariableArguments(bool enabled);
void Print();
};
};

View File

@ -28,13 +28,12 @@
#define _NORETURN
#endif
template <class T>
struct Movable
template<class T> struct Movable
{
mutable T m_val;
// ReSharper disable once CppNonExplicitConversionOperator
operator T() const &&
operator T() const&&
{
return std::move(m_val);
}

View File

@ -6,10 +6,7 @@ namespace endianness
{
constexpr uint16_t byteswap16u(const uint16_t in)
{
return static_cast<uint16_t>(
(in >> 8) |
(in << 8)
);
return static_cast<uint16_t>((in >> 8) | (in << 8));
}
constexpr int16_t byteswap16s(const int16_t in)
@ -19,12 +16,7 @@ namespace endianness
constexpr uint32_t byteswap32u(const uint32_t in)
{
return static_cast<uint32_t>(
(in >> 24) |
((in >> 8) & 0x0000FF00ui32) |
((in << 8) & 0x00FF0000ui32) |
(in << 24)
);
return static_cast<uint32_t>((in >> 24) | ((in >> 8) & 0x0000FF00ui32) | ((in << 8) & 0x00FF0000ui32) | (in << 24));
}
constexpr int32_t byteswap32s(const int32_t in)
@ -34,23 +26,16 @@ namespace endianness
constexpr uint64_t byteswap64u(const uint64_t in)
{
return static_cast<uint32_t>(
(in >> 56) |
((in >> 40) & 0x000000000000FF00ui64) |
((in >> 24) & 0x0000000000FF0000ui64) |
((in >> 8) & 0x00000000FF000000ui64) |
((in << 8) & 0x000000FF00000000ui64) |
((in << 24) & 0x0000FF0000000000ui64) |
((in << 40) & 0x00FF000000000000ui64) |
(in << 56)
);
return static_cast<uint32_t>((in >> 56) | ((in >> 40) & 0x000000000000FF00ui64) | ((in >> 24) & 0x0000000000FF0000ui64)
| ((in >> 8) & 0x00000000FF000000ui64) | ((in << 8) & 0x000000FF00000000ui64) | ((in << 24) & 0x0000FF0000000000ui64)
| ((in << 40) & 0x00FF000000000000ui64) | (in << 56));
}
constexpr int64_t byteswap64s(const int64_t in)
{
return static_cast<int64_t>(byteswap64u(static_cast<uint64_t>(in)));
}
}
} // namespace endianness
#else
@ -85,7 +70,7 @@ namespace endianness
{
return __builtin_bswap64(in);
}
}
} // namespace endianness
#endif
@ -216,4 +201,4 @@ namespace endianness
}
#endif
}
} // namespace endianness

View File

@ -24,18 +24,65 @@
namespace endianness
{
#if HOST_ENDIANNESS == LITTLE_ENDIAN_ENDIANNESS
constexpr int16_t ToLittleEndian(const int16_t in) { return in; }
constexpr uint16_t ToLittleEndian(const uint16_t in) { return in; }
constexpr int32_t ToLittleEndian(const int32_t in) { return in; }
constexpr uint32_t ToLittleEndian(const uint32_t in) { return in; }
constexpr int64_t ToLittleEndian(const int64_t in) { return in; }
constexpr uint64_t ToLittleEndian(const uint64_t in) { return in; }
constexpr int16_t FromLittleEndian(const int16_t in) { return in; }
constexpr uint16_t FromLittleEndian(const uint16_t in) { return in; }
constexpr int32_t FromLittleEndian(const int32_t in) { return in; }
constexpr uint32_t FromLittleEndian(const uint32_t in) { return in; }
constexpr int64_t FromLittleEndian(const int64_t in) { return in; }
constexpr uint64_t FromLittleEndian(const uint64_t in) { return in; }
constexpr int16_t ToLittleEndian(const int16_t in)
{
return in;
}
constexpr uint16_t ToLittleEndian(const uint16_t in)
{
return in;
}
constexpr int32_t ToLittleEndian(const int32_t in)
{
return in;
}
constexpr uint32_t ToLittleEndian(const uint32_t in)
{
return in;
}
constexpr int64_t ToLittleEndian(const int64_t in)
{
return in;
}
constexpr uint64_t ToLittleEndian(const uint64_t in)
{
return in;
}
constexpr int16_t FromLittleEndian(const int16_t in)
{
return in;
}
constexpr uint16_t FromLittleEndian(const uint16_t in)
{
return in;
}
constexpr int32_t FromLittleEndian(const int32_t in)
{
return in;
}
constexpr uint32_t FromLittleEndian(const uint32_t in)
{
return in;
}
constexpr int64_t FromLittleEndian(const int64_t in)
{
return in;
}
constexpr uint64_t FromLittleEndian(const uint64_t in)
{
return in;
}
#else
int16_t ToLittleEndian(int16_t in);
uint16_t ToLittleEndian(uint16_t in);
@ -51,20 +98,66 @@ namespace endianness
uint64_t FromLittleEndian(uint64_t in);
#endif
#if HOST_ENDIANNESS == BIG_ENDIAN_ENDIANNESS
constexpr int16_t ToBigEndian(const int16_t in) { return in; }
constexpr uint16_t ToBigEndian(const uint16_t in) { return in; }
constexpr int32_t ToBigEndian(const int32_t in) { return in; }
constexpr uint32_t ToBigEndian(const uint32_t in) { return in; }
constexpr int64_t ToBigEndian(const int64_t in) { return in; }
constexpr uint64_t ToBigEndian(const uint64_t in) { return in; }
constexpr int16_t FromBigEndian(const int16_t in) { return in; }
constexpr uint16_t FromBigEndian(const uint16_t in) { return in; }
constexpr int32_t FromBigEndian(const int32_t in) { return in; }
constexpr uint32_t FromBigEndian(const uint32_t in) { return in; }
constexpr int64_t FromBigEndian(const int64_t in) { return in; }
constexpr uint64_t FromBigEndian(const uint64_t in) { return in; }
constexpr int16_t ToBigEndian(const int16_t in)
{
return in;
}
constexpr uint16_t ToBigEndian(const uint16_t in)
{
return in;
}
constexpr int32_t ToBigEndian(const int32_t in)
{
return in;
}
constexpr uint32_t ToBigEndian(const uint32_t in)
{
return in;
}
constexpr int64_t ToBigEndian(const int64_t in)
{
return in;
}
constexpr uint64_t ToBigEndian(const uint64_t in)
{
return in;
}
constexpr int16_t FromBigEndian(const int16_t in)
{
return in;
}
constexpr uint16_t FromBigEndian(const uint16_t in)
{
return in;
}
constexpr int32_t FromBigEndian(const int32_t in)
{
return in;
}
constexpr uint32_t FromBigEndian(const uint32_t in)
{
return in;
}
constexpr int64_t FromBigEndian(const int64_t in)
{
return in;
}
constexpr uint64_t FromBigEndian(const uint64_t in)
{
return in;
}
#else
int16_t ToBigEndian(int16_t in);
uint16_t ToBigEndian(uint16_t in);
@ -79,4 +172,4 @@ namespace endianness
int64_t FromBigEndian(int64_t in);
uint64_t FromBigEndian(uint64_t in);
#endif
}
} // namespace endianness

View File

@ -8,10 +8,7 @@ class FileUtils
public:
static constexpr uint32_t MakeMagic32(const char ch0, const char ch1, const char ch2, const char ch3)
{
return static_cast<uint32_t>(ch0)
| static_cast<uint32_t>(ch1) << 8
| static_cast<uint32_t>(ch2) << 16
| static_cast<uint32_t>(ch3) << 24;
return static_cast<uint32_t>(ch0) | static_cast<uint32_t>(ch1) << 8 | static_cast<uint32_t>(ch2) << 16 | static_cast<uint32_t>(ch3) << 24;
}
/**

View File

@ -9,8 +9,7 @@ MemoryManager::AllocationInfo::AllocationInfo(IDestructible* data, void* dataPtr
m_data_ptr = dataPtr;
}
MemoryManager::MemoryManager()
= default;
MemoryManager::MemoryManager() = default;
MemoryManager::~MemoryManager()
{

View File

@ -11,13 +11,12 @@ class MemoryManager
virtual ~IDestructible() = default;
};
template <class T>
class Allocation final : public IDestructible
template<class T> class Allocation final : public IDestructible
{
public:
T m_entry;
template <class... _Valty>
template<class... _Valty>
explicit Allocation(_Valty&&... _Val)
: m_entry(std::forward<_Valty>(_Val)...)
{
@ -50,8 +49,7 @@ public:
void* Alloc(size_t size);
char* Dup(const char* str);
template <class T, class... _Valty>
T* Create(_Valty&&... _Val)
template<class T, class... _Valty> T* Create(_Valty&&... _Val)
{
Allocation<T>* allocation = new Allocation<T>(std::forward<_Valty>(_Val)...);
m_destructible.emplace_back(allocation, &allocation->m_entry);
@ -60,4 +58,4 @@ public:
void Free(void* data);
void Delete(void* data);
};
};

View File

@ -100,4 +100,4 @@ namespace utils
for (auto& c : str)
c = static_cast<char>(toupper(c));
}
}
} // namespace utils

View File

@ -14,4 +14,4 @@ namespace utils
void MakeStringLowerCase(std::string& str);
void MakeStringUpperCase(std::string& str);
}
} // namespace utils

View File

@ -2,15 +2,15 @@
#include <functional>
template <typename BaseIteratorType, typename SourceType, typename TargetType>
class TransformIterator
template<typename BaseIteratorType, typename SourceType, typename TargetType> class TransformIterator
{
BaseIteratorType m_base;
std::function<TargetType(SourceType)> m_transform;
public:
TransformIterator(BaseIteratorType base, std::function<TargetType(SourceType)> transform)
: m_base(base), m_transform(transform)
: m_base(base),
m_transform(transform)
{
}
@ -20,7 +20,18 @@ public:
return *this;
}
bool operator==(TransformIterator other) const { return m_base == other.m_base; }
bool operator!=(TransformIterator other) const { return !(m_base == other.m_base); }
TargetType operator*() { return m_transform(*m_base); }
bool operator==(TransformIterator other) const
{
return m_base == other.m_base;
}
bool operator!=(TransformIterator other) const
{
return !(m_base == other.m_base);
}
TargetType operator*()
{
return m_transform(*m_base);
}
};