27 template <
typename LabelSet>
31 using value_t = std::pair<typename labelset_t::value_t, bool>;
37 return value_t{labelset_t::special(),
true};
44 return value_t{labelset_t::special(),
false};
47 template <
typename Ls>
52 return std::get<1>(l) || Ls::is_one(
get_value(l));
55 template <
typename Ls>
60 return std::get<1>(l);
67 return is_one_<labelset_t>(l);
70 template <
typename Value>
80 return {ls.transpose(
get_value(l)),
false};
83 template <
typename... Args>
87 return {ls.value(std::forward<Args>(args)...),
false};
91 static typename labelset_t::value_t
94 return std::get<0>(
v);
104 template <
typename GenSet>
115 return genset_t::special();
122 return genset_t::one_letter();
132 template <
typename Value>
139 template <
typename... Args>
143 return ls.
value(std::forward<Args>(args)...);
156 template <
typename LabelSet>
168 using word_t =
typename labelset_t::word_t;
181 :
nullableset{std::make_shared<const labelset_t>(ls)}
196 eat(is,
"nullableset<");
197 auto ls = labelset_t::make(is);
207 return this->ls_->open(o);
210 static constexpr
bool
216 static constexpr
bool
222 static constexpr
bool
256 -> decltype(this->ls_->
genset())
258 return ls_->genset();
276 template <
typename LabelSet_>
278 conv(
const LabelSet_& ls,
typename LabelSet_::value_t
v)
const
280 return value(ls_->conv(ls, v));
288 template <
typename... Args>
307 -> decltype(labelset_t::letters_of(
v))
309 return labelset_t::letters_of(
v);
316 -> decltype(ls_->letters_of_padded(
v, l))
318 return ls_->letters_of_padded(
v, l);
367 raise(*
this,
": ldiv: invalid arguments: ",
400 return ls_->get_letter(i, quoted);
405 conv(std::istream& i,
bool quoted =
true)
const
408 if (i.good() && i.peek() ==
'\\')
420 return value(ls_->conv(i, quoted));
423 template <
typename Fun>
424 void convs(std::istream& i, Fun fun)
const
444 return value(ls_->zero());
460 template <
typename Value>
475 ls_->print_set(o, fmt);
481 ls_->print_set(o, fmt);
494 static typename labelset_t::value_t
495 get_value(const value_t& v)
498 return helper_t::get_value(v);
505 template <typename LabelSet>
506 struct letterized_traits<nullableset<LabelSet>>
508 using traits = letterized_traits<LabelSet>;
509 static constexpr bool is_letterized = traits::is_letterized;
511 using labelset_t = typename traits::labelset_t;
513 static labelset_t labelset(const nullableset<LabelSet>& ls)
515 return make_letterized(*ls.labelset());
520 template <typename LabelSet>
521 struct nullableset_traits<nullableset<LabelSet>>
523 using type = nullableset<LabelSet>;
524 static type value(const nullableset<LabelSet>& ls)
530 template <typename LabelSet>
531 struct proper_traits<nullableset<LabelSet>>
533 using type = LabelSet;
534 static type value(const nullableset<LabelSet>& ls)
536 return *ls.labelset();
541 template <typename LabelSet>
542 struct law_traits<nullableset<LabelSet>>
544 using type = law_t<LabelSet>;
545 static type value(const nullableset<LabelSet>& ls)
547 return make_wordset(*ls.labelset());
556 template <typename LS>
557 struct join_impl<oneset, LS,
558 enable_if_t<!LS::has_one()>>
560 using type = nullableset<LS>;
561 static type join(const oneset&, const LS& ls)
568 template <typename LS>
569 struct join_impl<oneset, LS,
570 enable_if_t<LS::has_one()>>
573 static type join(const oneset&, const LS& ls)
580 template <typename LS1, typename LS2>
581 struct join_impl<nullableset<LS1>, LS2>
583 using type = nullableset<join_t<LS1, LS2>>;
584 static type join(const nullableset<LS1>& ls1, const LS2& ls2)
586 return {::vcsn::join(*ls1.labelset(), ls2)};
594 template <typename LS1, typename LS2>
595 struct join_impl<nullableset<LS1>, nullableset<LS2>>
597 using type = nullableset<join_t<LS1, LS2>>;
598 static type join(const nullableset<LS1>& ls1,
599 const nullableset<LS2>& ls2)
601 return {::vcsn::join(*ls1.labelset(), *ls2.labelset())};
610 #define DEFINE(Lhs, Rhs, Res) \
611 template <typename GenSet> \
613 meet(const Lhs& lhs, const Rhs& rhs) \
615 return {intersection(lhs.genset(), rhs.genset())}; \
619 DEFINE(nullableset<letterset<GenSet>>,
620 nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
622 DEFINE(letterset<GenSet>,
623 nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
625 DEFINE(nullableset<letterset<GenSet>>,
626 letterset<GenSet>, nullableset<letterset<GenSet>>);
628 template <typename Lls, typename Rls>
629 nullableset<meet_t<Lls, Rls>>
630 meet(const nullableset<Lls>& lhs, const nullableset<Rls>& rhs)
632 return nullableset<meet_t<Lls, Rls>>{meet(*lhs.labelset(),
bool open(bool o) const
Whether unknown letters should be added, or rejected.
typename labelset_t::letter_t letter_t
static bool less(const value_t &l, const value_t &r)
Whether l < r.
static Value transpose(const labelset_t &ls, Value l)
static ATTRIBUTE_PURE labelset_t::value_t get_value(const value_t &v)
static ATTRIBUTE_PURE constexpr value_t special()
Implementation of labels are letters.
static ATTRIBUTE_PURE constexpr value_t one()
static value_t value(const labelset_t &ls, Args &&...args)
auto genset() const -> decltype(this->ls_->genset())
The generators. Meaningful for labelsets only.
weightset_mixin< detail::r_impl > r
static constexpr bool is_letterized()
static size_t size(const value_t &v)
value_t conv(oneset, typename oneset::value_t) const
typename helper_t::value_t value_t
nullableset(const labelset_t &ls={})
std::istringstream is
The input stream: the specification to translate.
Value transpose(const Value &l) const
Mirror label.
std::pair< typename labelset_t::value_t, bool > value_t
char eat(std::istream &is, char c)
Check lookahead character and advance.
letter_t get_letter(std::istream &i, bool quoted=true) const
std::ostream & print(const value_t &l, std::ostream &o, format fmt={}) const
Print label to stream.
typename std::enable_if< Cond, T >::type enable_if_t
static size_t hash(const value_t &v)
bool is_zero(const value_t &v) const
Add support for an empty word to a LabelSet that does not provide such special label to this end...
static value_t value(const labelset_t &ls, Args &&...args)
value_t ldiv(const value_t &l, const value_t &r) const
Compute l \ r = l^{-1}r.
static ATTRIBUTE_PURE bool is_one(value_t l)
value_t value(Args &&...args) const
static ATTRIBUTE_PURE bool is_one(const value_t &l)
static constexpr bool is_free()
std::ostream & print_set(std::ostream &o, format fmt={}) const
Print labelset description.
auto letters_of_padded(const word_t &v, letter_t l) const -> decltype(ls_->letters_of_padded(v, l))
Prepare to iterate over the letters of v.
std::shared_ptr< const labelset_t > labelset_ptr
static ATTRIBUTE_PURE bool is_one(value_t l)
bool is_letter(const value_t &v) const
word_t word(const value_t &l) const
static bool is_special(const value_t &v)
Provide a variadic mul on top of a binary mul(), and one().
static constexpr bool has_one()
Implementation of labels are ones: there is a single instance of label.
law_t< LabelSet > make_wordset(const LabelSet &ls)
The wordset of a labelset.
typename labelset_t::word_t word_t
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
static ATTRIBUTE_PURE constexpr value_t one()
static ATTRIBUTE_PURE vcsn::enable_if_t<!Ls::has_one(), bool > is_one_(const value_t &l)
const labelset_ptr labelset() const
std::string to_string(direction d)
Conversion to string.
typename labelset_t::value_t value_t
void convs(std::istream &i, Fun fun) const
static ATTRIBUTE_PURE constexpr value_t one()
static ATTRIBUTE_PURE value_t get_value(const value_t &v)
value_t conv(const LabelSet_ &ls, typename LabelSet_::value_t v) const
Conversion from another type: first by the wrapped labelset, and then by our wrappers (in case the wr...
auto letters_of_padded(value_t v, letter_t l) const -> decltype(this->letters_of_padded(this->word(v), l))
value_t conv(std::istream &i, bool quoted=true) const
Read a label from a stream.
static nullableset make(std::istream &is)
Build from the description in is.
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
static Value transpose(const labelset_t &ls, const Value &l)
vcsn::enable_if_t<!is_letterized_t< labelset_t_of< Aut > >{}, bool > is_letterized(const Aut &aut)
static auto letters_of(const word_t &v) -> decltype(labelset_t::letters_of(v))
Prepare to iterate over the letters of v.
value_t value(Args &&...args) const
Value constructor.
static constexpr bool is_expressionset()
bool is_valid(value_t v) const
ATTRIBUTE_PURE auto transpose(Args &&...args) const -> decltype(this->genset().transpose(std::forward< Args >(args)...))
value_t lgcd(const value_t &l, const value_t &r) const
The longest common prefix.
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one.
labelset_ptr ls_
The wrapped LabelSet.
static ATTRIBUTE_PURE vcsn::enable_if_t< Ls::has_one(), bool > is_one_(const value_t &l)
static ATTRIBUTE_PURE constexpr value_t special()
nullableset(const labelset_ptr &ls)
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
Implementation of labels are nullables (letter or empty).
value_t conv(self_t, value_t v) const