hack/sandbox/bin/concepts/main.cpp

43 lines
836 B
C++
Raw Normal View History

2023-08-14 11:02:39 +03:00
#include <set>
2023-08-20 10:07:06 +03:00
#include <unordered_set>
2023-08-14 11:02:39 +03:00
#include "hack/logger/logger.hpp"
#include "hack/concepts/concepts.hpp"
template<hack::concepts::is_map T>
void test_map(const T& m)
{
hack::log()("is map", m);
}
template<hack::concepts::is_associative_container T>
void test_associative(const T& m)
{
hack::log()("is associative", m);
}
2023-08-20 10:07:06 +03:00
template<hack::concepts::is_unordered_set T>
void test_unordered_set(const T& m)
{
hack::log()("is unordered set", m);
}
2023-08-14 11:02:39 +03:00
auto main(int argc, char *argv[]) -> int
{
std::map<std::string, int> m { { "a", 1 }, { "b", 2 } };
test_map(m);
test_associative(m);
auto t = std::make_tuple("a", 1, "b", 2);
test_associative(t);
std::vector<int> v { 1, 2, 3 };
// test_associative(v); error !!!
2023-08-20 10:07:06 +03:00
std::unordered_set<int> us { 1, 2, 3 };
test_unordered_set(us);
test_associative(us);
2023-08-14 11:02:39 +03:00
}