Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
size.hxx
Go to the documentation of this file.
1 #ifndef VCSN_CORE_RAT_SIZE_HXX
2 # define VCSN_CORE_RAT_SIZE_HXX
3 
4 namespace vcsn
5 {
6  namespace rat
7  {
8 
9 # define DEFINE \
10  template <typename RatExpSet> \
11  inline \
12  auto \
13  size<RatExpSet>
14 
15 # define VISIT(Type) \
16  DEFINE::visit(const Type ## _t& v) \
17  -> void
18 
20  {
21  (void) v;
22  ++ size_;
23  }
24 
26  {
27  (void) v;
28  ++ size_;
29  }
30 
32  {
33  (void) v;
34  // FIXME: use the label size instead of 1. Labels don't have a size yet.
35  ++ size_;
36  }
37 
39  {
40  ++ size_;
41  v.sub()->accept(*this);
42  }
43 
45  {
46  ++ size_;
47  v.sub()->accept(*this);
48  }
49 
50  template <typename RatExpSet>
51  template <type_t Type>
52  inline
53  void
55  {
56  ++ size_;
57  v.sub()->accept(*this);
58  }
59 
60  template <typename RatExpSet>
61  template <type_t Type>
62  inline
63  void
65  {
66  /* An n-ary node contributes n-1 unit (plus the sum of its
67  children sizes) to the ratexp size. */
68  -- size_;
69  for (auto child : n)
70  {
71  ++ size_;
72  child->accept(*this);
73  }
74  }
75 
76 
77 # undef VISIT
78 # undef DEFINE
79 
80  } // namespace rat
81 } // namespace vcsn
82 
83 #endif // !VCSN_CORE_RAT_SIZE_HXX
#define VISIT(Type)
Definition: size.hxx:15
typename super_t::template variadic_t< Type > variadic_t
Definition: size.hh:26
void visit_unary(const unary_t< Type > &n)
Traverse unary node.
Definition: size.hxx:54
void visit_variadic(const variadic_t< Type > &n)
Traverse variadic node.
Definition: size.hxx:64
typename super_t::template unary_t< Type > unary_t
Definition: size.hh:24
An inner node implementing a weight.
Definition: fwd.hh:145