#include <iostream>
#include <list> #include <vector> #include "concatenate.hpp" template <typename A, typename B> struct IsSame { static constexpr bool value = false; }; template <typename A> struct IsSame<A, A> { static constexpr bool value = true; }; template <bool cond, typename ret> struct RestrictTo { }; template <typename ret> struct RestrictTo<true,ret> { typedef ret type; }; // SFINAE template <typename A, typename B> typename RestrictTo<IsSame<A,B>::value, void>::type foo(A i, B j) { std::cout << "A and B are the same" << std::endl; } template <typename A, typename B> typename RestrictTo<! IsSame<A,B>::val(), void>::type foo(A i, B j) { std::cout << "A and B are *not* the same" << std::endl; } int main() { std::vector<int> a = {1, 2, 3}; std::list<int> b = {4, 5, 6}; // auto of type: // typename ConcatenatedContainerView<std::vector<int>, // list<int> >::iterator /* for (auto it = concatenate(a,b).begin(); it != concatenate(a,b).end(); ++it) { std::cout << *it << std::endl; } */ for (int i : concatenate(concatenate(a,a),a)) { std::cout << i << std::endl; } /* std::cout << IsSame<int,int>::value << std::endl; std::cout << IsSame<float,int>::value << std::endl; foo(1, 3); // foo(int,int) foo(1.3, 5); // foo(double,int) */ /* for (int i : a & b) { std::cout << i << std::endl; } */ } |