Skip to content

Commit

Permalink
Refactored naming convention and reversed templ8 args
Browse files Browse the repository at this point in the history
This is to make sure that the signature is as similar as possible to std::map<>
  • Loading branch information
FireFlyForLife committed Oct 2, 2019
1 parent 26caa03 commit 70ed03e
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 288 deletions.
2 changes: 2 additions & 0 deletions SparseToDenseVector.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)external\catch2\include;$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -128,6 +129,7 @@
<ClInclude Include="include\flat_value_map.h" />
<ClInclude Include="include\utils\container_utils.h" />
<ClInclude Include="include\utils\defines.h" />
<ClInclude Include="include\utils\tmp_compatibility.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="tests\different_allocator_test.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions SparseToDenseVector.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<ClInclude Include="include\flat_value_map_handle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\utils\tmp_compatibility.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="tests\tests.cpp">
Expand Down
251 changes: 126 additions & 125 deletions include/flat_value_map.h

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions include/flat_value_map_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,41 @@

namespace cof
{
/// Handle for a `cof::flat_value_map<T>`
/// Handle for a `cof::FlatValueMap<T>`
/// A utility class for creating a typesafe handle.
template<typename T>
struct fvm_handle {
struct FvmHandle {
uint32_t id;

friend bool operator==(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id == rhs.id; }
friend bool operator!=(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id != rhs.id; }
friend bool operator<(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id < rhs.id; }
friend bool operator<=(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id <= rhs.id; }
friend bool operator>(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id > rhs.id; }
friend bool operator>=(const fvm_handle& lhs, const fvm_handle& rhs) { return lhs.id >= rhs.id; }
friend bool operator==(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id == rhs.id; }
friend bool operator!=(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id != rhs.id; }
friend bool operator<(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id < rhs.id; }
friend bool operator<=(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id <= rhs.id; }
friend bool operator>(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id > rhs.id; }
friend bool operator>=(const FvmHandle& lhs, const FvmHandle& rhs) { return lhs.id >= rhs.id; }
};

/// Handle for a `cof::light_flat_value_map<T>`
/// Handle for a `cof::LightFlatValueMap<T>`
/// A utility class for creating a typesafe handle.
template<typename T>
struct lfvm_handle {
struct LfvmHandle {
uint32_t id;

friend bool operator==(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id == rhs.id; }
friend bool operator!=(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id != rhs.id; }
friend bool operator<(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id < rhs.id; }
friend bool operator<=(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id <= rhs.id; }
friend bool operator>(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id > rhs.id; }
friend bool operator>=(const lfvm_handle& lhs, const lfvm_handle& rhs) { return lhs.id >= rhs.id; }
friend bool operator==(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id == rhs.id; }
friend bool operator!=(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id != rhs.id; }
friend bool operator<(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id < rhs.id; }
friend bool operator<=(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id <= rhs.id; }
friend bool operator>(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id > rhs.id; }
friend bool operator>=(const LfvmHandle& lhs, const LfvmHandle& rhs) { return lhs.id >= rhs.id; }
};
}

namespace std
{
template<typename T>
struct hash<cof::fvm_handle<T>>
struct hash<cof::FvmHandle<T>>
{
std::size_t operator()(const cof::fvm_handle<T>& handle) const
std::size_t operator()(const cof::FvmHandle<T>& handle) const
{
using internal_id_t = decltype(handle.id);

Expand All @@ -44,9 +46,9 @@ namespace std
};

template<typename T>
struct hash<cof::lfvm_handle<T>>
struct hash<cof::LfvmHandle<T>>
{
std::size_t operator()(const cof::lfvm_handle<T>& handle) const
std::size_t operator()(const cof::LfvmHandle<T>& handle) const
{
using internal_id_t = decltype(handle.id);

Expand Down
Loading

0 comments on commit 70ed03e

Please sign in to comment.