Skip to content

Commit d9d08e0

Browse files
authored
Merge pull request #4 from Daniel599/master
fixed range iterators constructor
2 parents dca42fb + 490dd63 commit d9d08e0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/fifo_map.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ template <
131131
/// constructor for a range of elements
132132
template<class InputIterator>
133133
fifo_map(InputIterator first, InputIterator last)
134-
: m_keys(), m_compare(m_keys), m_map(m_compare)
134+
: m_keys(), m_compare(&m_keys), m_map(m_compare)
135135
{
136136
for (auto it = first; it != last; ++it)
137137
{

test/unit.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,16 @@ TEST_CASE("regression tests")
808808
}
809809
}
810810
}
811+
812+
TEST_CASE("constructors")
813+
{
814+
SECTION("range iterators constructor")
815+
{
816+
std::map<std::string, int> inputs = {{"A", 1}, {"B", 2}};
817+
nlohmann::fifo_map<std::string, int> m(inputs.begin(), inputs.end());
818+
CHECK(m.size() == 2);
819+
CHECK(m["A"] == 1);
820+
CHECK(m["B"] == 2);
821+
822+
}
823+
}

0 commit comments

Comments
 (0)