SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
VariantCast.h
Go to the documentation of this file.
1
17
18#ifndef _SEUTILS_VARIANTCAST_H_
19#define _SEUTILS_VARIANTCAST_H_
20
21#include <boost/lexical_cast.hpp>
22#include <boost/variant/static_visitor.hpp>
23#include <boost/variant/apply_visitor.hpp>
24
25namespace SourceXtractor {
26
27template<typename To>
28class VariantCastVisitor : public boost::static_visitor<To> {
29public:
30 template<typename From>
31 To operator()(const From& from) const {
32 return boost::lexical_cast<To>(from);
33 }
34};
35
36template<typename To, typename From>
37To VariantCast(const From& from) {
38 return boost::apply_visitor(VariantCastVisitor<To>(), from);
39}
40
41} // end of namespace SourceXtractor
42
43#endif /* _SEUTILS_VARIANTCAST_H_ */
To operator()(const From &from) const
Definition VariantCast.h:31
To VariantCast(const From &from)
Definition VariantCast.h:37