More code cleanup

This commit is contained in:
2020-10-18 21:56:30 +02:00
parent d50a14f9c9
commit 0790e40294
9 changed files with 328 additions and 241 deletions

View File

@@ -17,7 +17,7 @@ namespace openVulkanoCpp
class Utils
{
public:
static std::vector<const char*> toCString(const std::vector<std::string>& values)
static inline std::vector<const char*> toCString(const std::vector<std::string>& values)
{
std::vector<const char*> result;
result.reserve(values.size());
@@ -27,7 +27,7 @@ namespace openVulkanoCpp
return result;
}
static std::vector<const char*> toCString(const std::set<std::string>& values)
static inline std::vector<const char*> toCString(const std::set<std::string>& values)
{
std::vector<const char*> result;
result.reserve(values.size());
@@ -38,27 +38,32 @@ namespace openVulkanoCpp
}
template <typename T>
static bool Contains(std::vector<T>& vec, const T& element)
static inline bool Contains(std::vector<T>& vec, const T& element)
{
return (std::find(vec.begin(), vec.end(), element) != vec.end());
}
template <typename T>
static void Remove(std::vector<T>& vec, const T& element)
static inline void Remove(std::vector<T>& vec, const T& element)
{
vec.erase(std::remove(vec.begin(), vec.end(), element), vec.end());
}
template <typename Enumeration>
static auto EnumAsInt(Enumeration const value)
static inline auto EnumAsInt(Enumeration const value)
-> typename std::underlying_type<Enumeration>::type
{
return static_cast<typename std::underlying_type<Enumeration>::type>(value);
}
static bool MatchesAnyElementWise(const glm::vec3& a, const glm::vec3& b)
static inline bool MatchesAnyElementWise(const glm::vec3& a, const glm::vec3& b)
{
return a.x == b.x || a.y == b.y || a.z == b.z;
}
static inline size_t Align(size_t size, size_t alignment)
{
return (size + alignment - 1) & ~(alignment - 1);
}
};
}