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 {
19 namespace detail {
20 #include <hilti/autogen/__ctor.h>
21 
23 inline Node to_node(Ctor t) { return Node(std::move(t)); }
24 
26 inline std::ostream& operator<<(std::ostream& out, Ctor c) { return out << to_node(std::move(c)); }
27 
28 inline bool operator==(const Ctor& x, const Ctor& y) {
29  if ( &x == &y )
30  return true;
31 
32  assert(x.isEqual(y) == y.isEqual(x)); // Expected to be symmetric.
33  return x.isEqual(y);
34 }
35 
36 inline bool operator!=(const Ctor& c1, const Ctor& c2) { return ! (c1 == c2); }
37 
38 } // namespace detail
39 } // namespace ctor
40 
41 using Ctor = ctor::detail::Ctor;
42 using ctor::detail::to_node;
43 
45 template<typename T, typename std::enable_if_t<std::is_base_of<trait::isCtor, T>::value>* = nullptr>
46 inline Node to_node(T t) {
47  return Node(Ctor(std::move(t)));
48 }
49 
50 } // namespace hilti
Definition: node.h:113
Definition: ctor.h:15
Definition: node.h:22