mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add static_variant_visitor
This commit is contained in:
parent
f01382e3e5
commit
fce61f0def
6 changed files with 103 additions and 41 deletions
41
sprout/variant/visitor_result.hpp
Normal file
41
sprout/variant/visitor_result.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef SPROUT_VARIANT_VISITOR_RESULT_HPP
|
||||
#define SPROUT_VARIANT_VISITOR_RESULT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// has_visitor_result
|
||||
//
|
||||
SPROUT_HAS_XXX_TEMPLATE_DEF_LAZY(visitor_result);
|
||||
|
||||
namespace detail {
|
||||
template<typename Visitor, typename Visitable, typename = void>
|
||||
struct visitor_result_impl;
|
||||
template<typename Visitor, typename Visitable>
|
||||
struct visitor_result_impl<
|
||||
Visitor, Visitable,
|
||||
typename std::enable_if<sprout::has_visitor_result<Visitable>::value>::type
|
||||
>
|
||||
: public Visitable::template visitor_result<Visitor, Visitable>
|
||||
{};
|
||||
template<typename Visitor, typename Visitable>
|
||||
struct visitor_result_impl<
|
||||
Visitor, Visitable,
|
||||
typename std::enable_if<!sprout::has_visitor_result<Visitable>::value>::type
|
||||
> {
|
||||
public:
|
||||
typedef typename Visitor::result_type type;
|
||||
};
|
||||
} // namespace detail
|
||||
//
|
||||
// visitor_result
|
||||
//
|
||||
template<typename Visitor, typename Visitable>
|
||||
struct visitor_result
|
||||
: public sprout::detail::visitor_result_impl<Visitor, Visitable>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_VARIANT_VISITOR_RESULT_HPP
|
Loading…
Add table
Add a link
Reference in a new issue