Spicy
ctor.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 
7 #include <hilti/ast/node.h>
8 #include <hilti/ast/type.h>
9 #include <hilti/base/type_erase.h>
10 
11 namespace hilti {
12 
13 namespace trait {
15 class isCtor : public isNode {};
16 } // namespace trait
17 
18 namespace ctor::detail {
19 #include <hilti/autogen/__ctor.h>
20 
22 inline Node to_node(Ctor t) { return Node(std::move(t)); }
23 
25 inline std::ostream& operator<<(std::ostream& out, Ctor c) { return out << to_node(std::move(c)); }
26 
27 inline bool operator==(const Ctor& x, const Ctor& y) {
28  if ( &x == &y )
29  return true;
30 
31  assert(x.isEqual(y) == y.isEqual(x)); // Expected to be symmetric.
32  return x.isEqual(y);
33 }
34 
35 inline bool operator!=(const Ctor& c1, const Ctor& c2) { return ! (c1 == c2); }
36 
37 } // namespace ctor::detail
38 
39 using Ctor = ctor::detail::Ctor;
40 using ctor::detail::to_node; // NOLINT(misc-unused-using-decls)
41 
43 template<typename T, typename std::enable_if_t<std::is_base_of<trait::isCtor, T>::value>* = nullptr>
44 inline Node to_node(T t) {
45  return Node(Ctor(std::move(t)));
46 }
47 
48 } // namespace hilti
Definition: node.h:111
Definition: ctor.h:15
Definition: node.h:21