// // remap.hpp // remap // // Created by Sam Jaffe on 9/16/18. // #pragma once #include #include /* * A remap referres to a "value re-mapping object". This is used to allow us to * rename */ template class remap_base { public: using value_type = typename Impl::value_type; using key_type = typename Impl::key_type; using mapped_type = typename Impl::mapped_type; private: Impl impl_; public: remap_base(std::initializer_list mappings) : impl_(mappings) {} mapped_type const & operator[](T const & value) const { auto it = impl_.find(value); return (it != impl_.end()) ? it->second : value; } }; template , typename Alloc = std::allocator>> using remap = remap_base>; template , typename Equal = std::equal_to, typename Alloc = std::allocator>> using unordered_remap = remap_base>;