// eventpp library // Copyright (C) 2018 Wang Qi (wqking) // Github: https://github.com/wqking/eventpp // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef ANYID_H_320827729782 #define ANYID_H_320827729782 #include namespace eventpp { namespace anyid_internal_ { template struct MakeHash; template struct MakeHash ::value>::type> { std::size_t operator() (T value) const { return static_cast(value); } }; template struct MakeHash ::value>::type> { std::size_t operator() (const T & value) const { return std::hash()(value); } }; template class HasLess { template static std::true_type test(decltype(std::declval() < std::declval()) *); template static std::false_type test(...); public: enum { value = !! decltype(test(0))() }; }; template auto compareLessThan(const T & a, const T & b) -> typename std::enable_if::value, bool>::type { return a < b; } template auto compareLessThan(const T &, const T &) -> typename std::enable_if::value, bool>::type { return false; } template class HasEqual { template static std::true_type test(decltype(std::declval() == std::declval()) *); template static std::false_type test(...); public: enum { value = !! decltype(test(0))() }; }; template auto compareEqual(const T & a, const T & b) -> typename std::enable_if::value, bool>::type { return a == b; } template auto compareEqual(const T &, const T &) -> typename std::enable_if::value, bool>::type { return true; } } //namespace anyid_internal_ struct EmptyAnyStorage { EmptyAnyStorage() {} template EmptyAnyStorage(const T &) {} }; template