File: VisitorWrapper.hpp

package info (click to toggle)
reflect-cpp 0.21.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,128 kB
  • sloc: cpp: 50,336; python: 139; makefile: 30; sh: 3
file content (27 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef RFL_INTERNAL_VISITORWRAPPER_HPP_
#define RFL_INTERNAL_VISITORWRAPPER_HPP_

#include "../Literal.hpp"
#include "../TaggedUnion.hpp"
#include "StringLiteral.hpp"

namespace rfl {
namespace internal {

/// Necessary for the VisitTree structure.
template <class Visitor, internal::StringLiteral... _fields>
struct VisitorWrapper {
    /// Calls the underlying visitor when required to do so.
    template <int _i, class... Args>
    inline auto visit(const Args&... _args) const {
        return (*visitor_)(name_of<Literal<_fields...>, _i>(), _args...);
    }

    /// The underlying visitor.
    const Visitor* visitor_;
};

}  // namespace internal
}  // namespace rfl

#endif  // RFL_VISIT_HPP_