17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_MONOID_PAIR_STR_WORDS_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_MONOID_PAIR_STR_WORDS_HXX
20 # include <vaucanson/algebra/implementation/monoid/pair_str_words.hh>
26 template <
class Self,
typename T>
29 op_first(
const algebra::FreeMonoidProductBase<Self>& s, T& v)
31 return Element<typename virtual_types<Self>::first_monoid_t,
32 typename T::first_type> (s.first_monoid(), v.first);
35 template <
class Self,
typename T>
38 op_second(
const algebra::FreeMonoidProductBase<Self>& s, T& v)
40 return Element<typename virtual_types<Self>::second_monoid_t,
41 typename T::second_type> (s.second_monoid(), v.second);
44 template <
class F,
class S>
46 op_in_mul(
const algebra::FreeMonoidProduct<F, S>& s,
47 std::pair<std::basic_string<typename F::letter_t>,
48 std::basic_string<typename S::letter_t> >& dst,
49 const std::pair<std::basic_string<typename F::letter_t>,
50 std::basic_string<typename S::letter_t> >& src)
52 dst.first += src.first;
53 dst.second += src.second;
56 template<
class F,
class S>
57 std::pair<std::basic_string<typename F::letter_t>,
58 std::basic_string<typename S::letter_t> >
59 op_mul(
const algebra::FreeMonoidProduct<F, S>&,
60 const std::pair<std::basic_string<typename F::letter_t>,
61 std::basic_string<typename S::letter_t> >& a,
62 const std::pair<std::basic_string<typename F::letter_t>,
63 std::basic_string<typename S::letter_t> >& b)
65 return std::pair< std::basic_string<typename F::letter_t>,
66 std::basic_string<typename S::letter_t> >
67 (a.first + b.first, a.second + b.second);
70 template<
class F,
class S>
71 const std::pair<std::basic_string<typename F::letter_t>,
72 std::basic_string<typename S::letter_t> >
73 identity_value(
SELECTOR2(algebra::FreeMonoidProduct<F, S>),
74 SELECTOR2(std::pair<std::basic_string<typename F::letter_t>,
75 std::basic_string<typename S::letter_t> >))
77 static const std::pair<std::basic_string<typename F::letter_t>,
78 std::basic_string<typename S::letter_t> >
83 template <
class F,
class S>
84 Element<algebra::FreeMonoidProduct<F, S>,
85 std::pair<std::basic_string<typename F::letter_t>,
86 std::basic_string<typename S::letter_t> > >
87 op_choose(
const algebra::FreeMonoidProduct<F, S>& s,
88 SELECTOR2(std::pair<std::basic_string<typename F::letter_t>,
89 std::basic_string<typename S::letter_t> >))
91 typedef std::basic_string<typename F::letter_t> T1;
92 typedef std::basic_string<typename S::letter_t> T2;
94 std::pair< T1, T2 > res(s.first_monoid().choose(
SELECT(T1)).value(),
95 s.second_monoid().choose(
SELECT(T2)).value());
97 return Element<algebra::FreeMonoidProduct<F, S>,
98 std::pair< T1, T2 > > (s, res);
101 template<
typename Self,
typename T>
103 op_in_mirror(
const algebra::FreeMonoidProductBase<Self>& s, T& v)
105 op_in_mirror(s.first_monoid(), v.first);
106 op_in_mirror(s.second_monoid(), v.second);
109 template<
typename Self,
typename T,
typename Ftor>
110 typename Ftor::result_type
111 op_length(
const algebra::FreeMonoidProductBase<Self>&,
const T& v, Ftor f)
113 return f(v.first.length(), v.second.length());
116 template<
typename F,
typename S,
117 typename A1,
typename A2,
typename A3,
typename A4>
119 op_is_atom(
const algebra::FreeMonoidProduct<F, S>&,
120 const std::pair<std::basic_string<typename F::letter_t, A1, A2>,
121 std::basic_string<typename S::letter_t, A3, A4>
124 return (v.first.length() <= 1) && (v.second.length() <= 1);
127 template <
typename F,
typename S,
typename St>
129 op_rout(
const FreeMonoidProduct<F, S>& s,
131 const std::pair<std::basic_string<typename F::letter_t>,
132 std::basic_string<typename S::letter_t> >& v)
134 if (v.first.empty() && v.second.empty())
135 st << s.representation()->empty;
138 st << s.representation()->open_par;
139 op_rout(s.first_monoid(), st, v.first);
140 st << s.representation()->sep;
141 op_rout(s.second_monoid(), st, v.second);
142 st << s.representation()->close_par;
152 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_MONOID_PAIR_STR_WORDS_HXX