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>
49 static std::enable_if_t<Ls::has_one(), bool>
52 return std::get<1>(l) || Ls::is_one(
get_value(l));
55 template <
typename Ls>
57 static std::enable_if_t<!Ls::has_one(), bool>
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;
185 :
nullableset{std::make_shared<const labelset_t>(ls)}
200 eat(is,
"nullableset<");
201 auto ls = labelset_t::make(is);
211 return this->ls_->open(o);
214 static constexpr
bool
220 static constexpr
bool
226 static constexpr
bool
260 return ls_->genset();
267 return ls_->generators();
285 template <
typename LabelSet_>
287 conv(
const LabelSet_& ls,
typename LabelSet_::value_t
v)
const
289 return value(ls_->conv(ls, v));
297 template <
typename... Args>
316 -> decltype(labelset_t::letters_of(
v))
318 return labelset_t::letters_of(
v);
325 -> decltype(ls_->letters_of_padded(
v, l))
327 return ls_->letters_of_padded(
v, l);
365 raise(*
this,
": mul: invalid arguments: ",
388 raise(*
this,
": ldivide: invalid arguments: ",
421 return ls_->get_letter(i, quoted);
426 conv(std::istream& i,
bool quoted =
true)
const
429 if (i.good() && i.peek() ==
'\\')
441 return value(ls_->conv(i, quoted));
453 template <
typename Fun>
454 void convs(std::istream& i, Fun&& fun)
const
457 [
this,fun](
const typename labelset_t::value_t& l)
471 ": conjunction: invalid operation (lhs and rhs are not equal): ",
492 return value(ls_->zero());
508 template <
typename Value>
523 ls_->print_set(o, fmt);
529 ls_->print_set(o, fmt);
535 ls_->print_set(o, fmt);
548 static typename labelset_t::value_t
549 get_value(const value_t& v)
552 return helper_t::get_value(v);
559 template <typename LabelSet>
560 struct letterized_traits<nullableset<LabelSet>>
562 using traits = letterized_traits<LabelSet>;
563 static constexpr bool is_letterized = traits::is_letterized;
565 using labelset_t = typename traits::labelset_t;
567 static labelset_t labelset(const nullableset<LabelSet>& ls)
569 return make_letterized(*ls.labelset());
574 template <typename LabelSet>
575 struct nullableset_traits<nullableset<LabelSet>>
577 using type = nullableset<LabelSet>;
578 static type value(const nullableset<LabelSet>& ls)
584 template <typename LabelSet>
585 struct proper_traits<nullableset<LabelSet>>
587 using type = LabelSet;
588 static type value(const nullableset<LabelSet>& ls)
590 return *ls.labelset();
595 template <typename LabelSet>
596 struct law_traits<nullableset<LabelSet>>
598 using type = law_t<LabelSet>;
599 static type value(const nullableset<LabelSet>& ls)
601 return make_wordset(*ls.labelset());
610 template <typename LS>
611 struct join_impl<oneset, LS,
612 std::enable_if_t<!LS::has_one()>>
614 using type = nullableset<LS>;
615 static type join(const oneset&, const LS& ls)
622 template <typename LS>
623 struct join_impl<oneset, LS,
624 std::enable_if_t<LS::has_one()>>
627 static type join(const oneset&, const LS& ls)
634 template <typename LS1, typename LS2>
635 struct join_impl<nullableset<LS1>, LS2>
637 using type = nullableset<join_t<LS1, LS2>>;
638 static type join(const nullableset<LS1>& ls1, const LS2& ls2)
640 return {::vcsn::join(*ls1.labelset(), ls2)};
648 template <typename LS1, typename LS2>
649 struct join_impl<nullableset<LS1>, nullableset<LS2>>
651 using type = nullableset<join_t<LS1, LS2>>;
652 static type join(const nullableset<LS1>& ls1,
653 const nullableset<LS2>& ls2)
655 return {::vcsn::join(*ls1.labelset(), *ls2.labelset())};
664 #define DEFINE(Lhs, Rhs, Res) \
665 template <typename GenSet> \
667 meet(const Lhs& lhs, const Rhs& rhs) \
669 return {set_intersection(*lhs.genset(), *rhs.genset())}; \
673 DEFINE(nullableset<letterset<GenSet>>,
674 nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
676 DEFINE(letterset<GenSet>,
677 nullableset<letterset<GenSet>>, nullableset<letterset<GenSet>>);
679 DEFINE(nullableset<letterset<GenSet>>,
680 letterset<GenSet>, nullableset<letterset<GenSet>>);
682 template <typename Lls, typename Rls>
683 nullableset<meet_t<Lls, Rls>>
684 meet(const nullableset<Lls>& lhs, const nullableset<Rls>& rhs)
686 return nullableset<meet_t<Lls, Rls>>{meet(*lhs.labelset(),
static ATTRIBUTE_PURE bool is_one(value_t l)
static size_t size(const value_t &v)
value_t ldivide(const value_t &l, const value_t &r) const
Compute l \ r = l^{-1}r.
static size_t hash(const value_t &v)
static bool is_special(const value_t &v)
std::ostream & print_set(std::ostream &o, format fmt={}) const
Print labelset description.
static ATTRIBUTE_PURE constexpr value_t one()
typename labelset_t::letter_t letter_t
static Value transpose(const labelset_t &ls, const Value &l)
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
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...
law_t< LabelSet > make_wordset(const LabelSet &ls)
The wordset of a labelset.
value_t value(Args &&...args) const
bool is_letter(const value_t &v) const
static labelset_t::value_t get_value(const value_t &v)
The (inner) value when it (the outer value) is not one.
decltype(ls_->genset()) genset_ptr
static value_t value(const labelset_t &ls, Args &&...args)
typename labelset_t::value_t value_t
Implementation of labels are letters.
std::enable_if_t<!is_letterized_t< labelset_t_of< Aut > >{}, bool > is_letterized(const Aut &aut)
word_t word(const value_t &l) const
value_t conv(std::istream &i, bool quoted=true) const
Read a label from a stream.
static constexpr bool has_one()
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
value_t conv(self_t, value_t v) const
bool open(bool o) const
Whether unknown letters should be added, or rejected.
Add support for an empty word to a LabelSet that does not provide such special label to this end...
typename helper_t::value_t value_t
static bool equal(const value_t &l, const value_t &r)
Whether l == r.
Print as a parsable type string.
static auto letters_of(const word_t &v) -> decltype(labelset_t::letters_of(v))
Prepare to iterate over the letters of v.
Implementation of labels are nullables (letter or empty).
static ATTRIBUTE_PURE bool is_one(value_t l)
nullableset(const labelset_ptr &ls)
std::ostream & print(const value_t &l, std::ostream &o=std::cout, format fmt={}) const
Print label to stream.
genset_ptr genset() const
static ATTRIBUTE_PURE labelset_t::value_t get_value(const value_t &v)
value_t mul(const value_t &l, const value_t &r) const
The concatenation.
value_t conv(oneset, typename oneset::value_t) const
value_t lgcd(const value_t &l, const value_t &r) const
The longest common prefix.
bool is_zero(const value_t &v) const
Implementation of labels are ones: there is a single instance of label.
labelset_ptr ls_
The wrapped LabelSet.
void convs(std::istream &i, Fun &&fun) const
Process a label class.
static ATTRIBUTE_PURE value_t get_value(const value_t &v)
static ATTRIBUTE_PURE constexpr value_t one()
static constexpr bool is_free()
static ATTRIBUTE_PURE std::enable_if_t<!Ls::has_one(), bool > is_one_(const value_t &l)
Value transpose(const Value &l) const
Mirror label.
value_t conjunction(const value_t &l, const value_t &r) const
static bool less(const value_t &l, const value_t &r)
Whether l < r.
static constexpr bool is_letterized()
bool is_special(const Aut &aut, transition_t_of< Aut > t)
Whether this transition is from pre or to post.
An input/output format for valuesets.
static ATTRIBUTE_PURE constexpr value_t special()
auto letters_of_padded(value_t v, letter_t l) const -> decltype(this->letters_of_padded(this->word(v), l))
static ATTRIBUTE_PURE constexpr value_t one()
std::string to_string(direction d)
Conversion to string.
value_t value(Args &&...args) const
Value constructor.
Print as rich UTF-8 text, escaped.
std::shared_ptr< const labelset_t > labelset_ptr
nullableset(const labelset_t &ls={})
static nullableset make(std::istream &is)
Build from the description in is.
static ATTRIBUTE_PURE bool is_one(const value_t &l)
bool is_valid(value_t v) const
std::pair< typename labelset_t::value_t, bool > value_t
static ATTRIBUTE_PURE std::enable_if_t< Ls::has_one(), bool > is_one_(const value_t &l)
static Value transpose(const labelset_t &ls, Value l)
ATTRIBUTE_PURE auto transpose(Args &&...args) const -> decltype(this->genset() -> transpose(std::forward< Args >(args)...))
decltype(ls_->generators()) genset_t
genset_t generators() const
The generators. Meaningful for labelsets only.
const labelset_ptr labelset() const
Provide a variadic mul on top of a binary mul(), and one().
typename labelset_t::word_t word_t
static value_t value(const labelset_t &ls, Args &&...args)
static constexpr bool is_expressionset()
letter_t get_letter(std::istream &i, bool quoted=true) const
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.
char eat(std::istream &is, char c)
Check lookahead character and advance.
static ATTRIBUTE_PURE constexpr value_t special()
weightset_mixin< detail::r_impl > r