diff options
author | 2018-11-07 11:06:42 +0900 | |
---|---|---|
committer | 2019-02-13 11:00:20 +0900 | |
commit | 0ed2885ececf079f16b42fec60a4dc86285b5101 (patch) | |
tree | b07075ffbebf9680ad4d5d2d6a4fa99a4ceee06c /include/mapbox/variant_visitor.hpp | |
parent | ae47635e56c4af4d816a76e5186e945768543679 (diff) |
add tbtnavi source
Diffstat (limited to 'include/mapbox/variant_visitor.hpp')
-rw-r--r-- | include/mapbox/variant_visitor.hpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/mapbox/variant_visitor.hpp b/include/mapbox/variant_visitor.hpp new file mode 100644 index 0000000..481eb65 --- /dev/null +++ b/include/mapbox/variant_visitor.hpp @@ -0,0 +1,38 @@ +#ifndef MAPBOX_UTIL_VARIANT_VISITOR_HPP +#define MAPBOX_UTIL_VARIANT_VISITOR_HPP + +namespace mapbox { +namespace util { + +template <typename... Fns> +struct visitor; + +template <typename Fn> +struct visitor<Fn> : Fn +{ + using type = Fn; + using Fn::operator(); + + visitor(Fn fn) : Fn(fn) {} +}; + +template <typename Fn, typename... Fns> +struct visitor<Fn, Fns...> : Fn, visitor<Fns...> +{ + using type = visitor; + using Fn::operator(); + using visitor<Fns...>::operator(); + + visitor(Fn fn, Fns... fns) : Fn(fn), visitor<Fns...>(fns...) {} +}; + +template <typename... Fns> +visitor<Fns...> make_visitor(Fns... fns) +{ + return visitor<Fns...>(fns...); +} + +} // namespace util +} // namespace mapbox + +#endif // MAPBOX_UTIL_VARIANT_VISITOR_HPP |