knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
common.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_PARSERS_COMMON_H
7 #define KNOWROB_PARSERS_COMMON_H
8 
9 #include "memory"
10 #include <boost/spirit/include/phoenix.hpp>
11 
12 namespace knowrob::parsers {
13  // code-snippet found on the web, needed to create smart pointers in parser rules.
14  // effectively here `ptr_` is defined and can be used to create std::shared_ptr's
15  // in parser rules.
16  template<typename T>
17  struct make_shared_f {
18  template<typename... A>
19  struct result {
20  typedef std::shared_ptr<T> type;
21  };
22 
23  template<typename... A>
24  typename result<A...>::type operator()(A &&... a) const {
25  return std::make_shared<T>(std::forward<A>(a)...);
26  }
27  };
28 
29  template<typename T> using ptr_ = boost::phoenix::function<make_shared_f<T> >;
30 }
31 
32 #endif //KNOWROB_PARSERS_COMMON_H
boost::phoenix::function< make_shared_f< T > > ptr_
Definition: common.h:29
const IRIAtomPtr type
Definition: rdf.h:15
result< A... >::type operator()(A &&... a) const
Definition: common.h:24