#pragma once #include #include template static auto test_z(int) -> decltype(decltype(T::z){}, std::true_type{}); template static auto test_z(...) -> std::false_type; template struct has_z : decltype(test_z(0)) {}; template ::value, bool>::type=true> T dist(const V& lhs, const V& rhs) { return std::sqrt( std::pow(lhs.x - rhs.x, 2) + std::pow(lhs.y - rhs.y, 2) + std::pow(lhs.z - rhs.z, 2)); } template ::value, bool>::type=true> T dist(const V& lhs, const V& rhs) { return std::sqrt( std::pow(lhs.x - rhs.x, 2) + std::pow(lhs.y - rhs.y, 2)); }