diff --git a/README.md b/README.md index 6dadbb4..eb93e35 100644 --- a/README.md +++ b/README.md @@ -128,20 +128,22 @@ Utily::StaticVector s_vector{1, 2, 3, 4}; A vector with no compile time enfored type. Access is checked in debug mode at runtime using Reflection. Useful for on the fly composing of types. ```c++ - auto vector = Utily::TypeErasedVector {}; - vector.set_underlying_type(); +// cannot resize or push back if the underlying_type is not set. +auto vector = Utily::TypeErasedVector {}; +vector.set_underlying_type(); - // these operations will throw in debug mode. - vector.emplace_back(1); - vector.emplace_back(1); +// these operations will assert false in debug mode. +vector.emplace_back(1); +vector.emplace_back(1); - vector.push_back(0.0f); - vector.emplace_back(1.0f); +// these will be valid. +vector.push_back(0.0f); +vector.emplace_back(1.0f); - // as_span can throw if T != Underlying - for (float& v : vector.as_span()) { - std::cout << v << ' '; - } +// as_span will assert if T != Underlying. +for (float& v : vector.as_span()) { + std::cout << v << ' '; +} ``` --- @@ -204,30 +206,19 @@ Simd optimised operations for supported algorithms. Mostly char searching at the const auto DELIMS = std::string_view { "azxy" }; const auto STRING = std::string { "hello world! This is a sentenze" }; -auto iter1 = Utily::Simd::find(STRING.begin(), STRING.end(), DELIMS.front()); - -auto iter2 = Utily::Simd::find_first_of( +``` +```C++ +auto iter = Utily::Simd::find(STRING.begin(), STRING.end(), DELIMS.front()); +``` +```C++ +auto iter = Utily::Simd::find_first_of( STRING.begin(), STRING.end(), DELIMS.begin(), DELIMS.end() ); - ``` --- - - - - -
Utily::Concepts - -Just a collection of [concepts](https://en.cppreference.com/w/cpp/concepts) to restrict/narrow types for templated functions ontop of the STL. - ---- - -
- -
Utily::Split Subdividing ranges ('splitting') is so common and there's many slightly different ways we need to do it. Below are the iterator classes for each type of split. diff --git a/include/Utily/TypeErasedVector.hpp b/include/Utily/TypeErasedVector.hpp index 1ae1aaa..231a6ec 100644 --- a/include/Utily/TypeErasedVector.hpp +++ b/include/Utily/TypeErasedVector.hpp @@ -115,7 +115,7 @@ namespace Utily { #ifdef _MSC_VER _aligned_free(_data); #else - free(data); + free(_data); #endif _data = nullptr; } diff --git a/test/UnitTypeErasedVector.cpp b/test/UnitTypeErasedVector.cpp index 1030e46..d42b171 100644 --- a/test/UnitTypeErasedVector.cpp +++ b/test/UnitTypeErasedVector.cpp @@ -7,8 +7,9 @@ TEST(TypeErasedVector, Constructor) { { auto vector = Utily::TypeErasedVector {}; +#ifndef NDEBUG EXPECT_DEBUG_DEATH(vector.emplace_back(1), ""); - +#endif vector.set_underlying_type(); EXPECT_EQ(vector.size(), 0); EXPECT_EQ(vector.size_bytes(), 0); @@ -38,8 +39,10 @@ TEST(TypeErasedVector, push_back) { EXPECT_EQ(vector.size_bytes(), 0); EXPECT_EQ(vector.capacity(), 0); +#ifndef NDEBUG EXPECT_DEBUG_DEATH(vector.emplace_back(1), ""); EXPECT_DEBUG_DEATH(vector.emplace_back(1), ""); +#endif vector.push_back(0.0f); vector.push_back(1.0f);