12#ifndef MCRL2_ATERMPP_ATERM_APPL_H
13#define MCRL2_ATERMPP_ATERM_APPL_H
31 :
aterm_core(reinterpret_cast<detail::_aterm*>(t))
71 template <
class ForwardIterator,
72 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value>::type* =
nullptr,
73 typename std::enable_if<!std::is_same<typename ForwardIterator::iterator_category, std::input_iterator_tag>::value>::type* =
nullptr,
74 typename std::enable_if<!std::is_same<typename ForwardIterator::iterator_category, std::output_iterator_tag>::value>::type* =
nullptr>
76 ForwardIterator
begin,
80 static_assert(!std::is_same<typename ForwardIterator::iterator_category, std::input_iterator_tag>::value,
81 "A forward iterator has more requirements than an input iterator.");
82 static_assert(!std::is_same<typename ForwardIterator::iterator_category, std::output_iterator_tag>::value,
83 "A forward iterator has more requirements than an output iterator.");
93 template <
class InputIterator,
94 typename std::enable_if<mcrl2::utilities::is_iterator<InputIterator>::value>::type* =
nullptr,
95 typename std::enable_if<std::is_same<typename InputIterator::iterator_category, std::input_iterator_tag>::value>::type* =
nullptr>
101 static_assert(std::is_same<typename InputIterator::iterator_category, std::input_iterator_tag>::value,
102 "The InputIterator is missing the input iterator tag.");
113 template <
class InputIterator,
115 typename std::enable_if<mcrl2::utilities::is_iterator<InputIterator>::value>::type* =
nullptr>
119 TermConverter converter)
122 static_assert(!std::is_same<typename InputIterator::iterator_category, std::output_iterator_tag>::value,
123 "The InputIterator has the output iterator tag.");
136 template<
typename ...Terms>
181 return std::numeric_limits<size_type>::max();
209 class ForwardIterator,
210 typename std::enable_if<mcrl2::utilities::is_iterator<ForwardIterator>::value>::type* =
nullptr,
211 typename std::enable_if<!std::is_same<typename ForwardIterator::iterator_category, std::input_iterator_tag>::value>::type* =
nullptr,
212 typename std::enable_if<!std::is_same<typename ForwardIterator::iterator_category, std::output_iterator_tag>::value>::type* =
nullptr>
215 ForwardIterator begin,
220 static_assert((std::is_base_of<aterm, Term>::value),
"Term must be derived from an aterm");
221 static_assert(
sizeof(Term)==
sizeof(std::size_t),
"Term derived from an aterm must not have extra fields");
222 static_assert(!std::is_same<typename ForwardIterator::iterator_category, std::input_iterator_tag>::value,
223 "A forward iterator has more requirements than an input iterator.");
224 static_assert(!std::is_same<typename ForwardIterator::iterator_category, std::output_iterator_tag>::value,
225 "A forward iterator has more requirements than an output iterator.");
239 typename std::enable_if<mcrl2::utilities::is_iterator<InputIterator>::value>::type* =
nullptr,
240 typename std::enable_if<std::is_same<typename InputIterator::iterator_category, std::input_iterator_tag>::value>::type* =
nullptr>
246 make_term_appl(target, sym, begin, end, [](
const Term& term) ->
const Term& {
return term; } );
248 static_assert((std::is_base_of<aterm, Term>::value),
"Term must be derived from an aterm");
249 static_assert(
sizeof(Term)==
sizeof(std::size_t),
"Term derived from an aterm must not have extra fields");
250 static_assert(std::is_same<typename InputIterator::iterator_category, std::input_iterator_tag>::value,
251 "The InputIterator is missing the input iterator tag.");
267 typename std::enable_if<mcrl2::utilities::is_iterator<InputIterator>::value>::type* =
nullptr>
272 TermConverter converter)
276 static_assert(std::is_base_of<aterm, Term>::value,
"Term must be derived from an aterm");
277 static_assert(
sizeof(Term)==
sizeof(std::size_t),
"Term derived from an aterm must not have extra fields");
278 static_assert(!std::is_same<typename InputIterator::iterator_category, std::output_iterator_tag>::value,
279 "The InputIterator has the output iterator tag.");
291 static_assert(std::is_base_of<aterm, Term>::value,
"Term must be derived from an aterm");
292 static_assert(
sizeof(Term)==
sizeof(std::size_t),
"Term derived from an aterm must not have extra fields");
318template <
class Term1,
class Term2>
320 std::conditional<std::is_base_of<aterm, Term1>::value &&
321 std::is_base_of<aterm, Term2>::value && (
322 std::is_convertible<Term1, Term2>::value ||
323 std::is_convertible<Term2, Term1>::value),
324 std::true_type, std::false_type>::type
336template <
class Derived,
class Base>
339 !std::is_base_of<Derived, Base>::value>::type* =
nullptr)
341 static_assert(
sizeof(Derived) ==
sizeof(
aterm),
342 "aterm cast can only be applied ot types derived from aterms where no extra fields are added");
343 assert(Derived(
static_cast<const aterm&
>(t)) !=
aterm());
344 return reinterpret_cast<const Derived&
>(t);
351template <
class Derived,
class Base>
354 !std::is_base_of<Derived, Base>::value >::type* =
nullptr)
356 static_assert(
sizeof(Base) ==
sizeof(
aterm),
357 "aterm cast can only be applied to terms directly derived from aterms");
358 static_assert(
sizeof(Derived) ==
sizeof(
aterm),
359 "aterm cast can only be applied to types derived from aterms where no extra fields are added");
361 return reinterpret_cast<Derived&
>(t);
369template <
class Derived>
372 static_assert(
sizeof(Derived) ==
sizeof(
aterm),
373 "aterm cast can only be applied to terms directly derived from aterms");
378template <
typename DerivedCont,
typename Base,
template <
typename Elem>
class Cont >
380 typename std::enable_if_t<
382 std::is_same_v<Cont<typename DerivedCont::value_type>, DerivedCont> &&
383 !std::is_base_of_v<DerivedCont, Cont<Base> > &&
387 static_assert(
sizeof(
typename DerivedCont::value_type) ==
sizeof(
aterm),
388 "aterm cast cannot be applied types derived from aterms where extra fields are added");
389 assert(std::all_of(t.begin(),t.end(),[](
const Base& u){ return typename DerivedCont::value_type(static_cast<const aterm&>(u)) != aterm();} ));
390 return reinterpret_cast<const DerivedCont&
>(t);
398template <
class Derived,
class Base>
402 static_assert(
sizeof(Derived) ==
sizeof(
aterm),
403 "aterm cast cannot be applied types derived from aterms where extra fields are added");
404 assert(Derived(
static_cast<const aterm&
>(t)) !=
aterm());
405 return reinterpret_cast<const Derived&
>(t);
408template <
typename DerivedCont,
typename Base,
template <
typename Elem>
class Cont >
410 typename std::enable_if_t<
412 std::is_same_v<Cont<typename DerivedCont::value_type>, DerivedCont> &&
416 static_assert(
sizeof(
typename DerivedCont::value_type) ==
sizeof(
aterm),
417 "aterm cast cannot be applied types derived from aterms where extra fields are added");
418 assert(std::all_of(t.begin(),t.end(),[](
const Base& u){ return typename DerivedCont::value_type(static_cast<const aterm&>(u)) != aterm();} ));
419 return reinterpret_cast<const DerivedCont&
>(t);
442 std::ostringstream oss;
485 return std::hash<atermpp::aterm_core>()(t);
The aterm_core base class that provides protection of the underlying shared terms.
aterm(aterm &&other) noexcept=default
aterm(const function_symbol &sym, InputIterator begin, InputIterator end, TermConverter converter)
const_iterator end() const
Returns a const_iterator pointing past the last argument.
aterm(const function_symbol &symbol, const Terms &...arguments)
Constructor for n-arity function application.
const aterm & operator[](const size_type i) const
Returns the i-th argument.
aterm()
Default constructor.
const_iterator begin() const
Returns an iterator pointing to the first argument.
aterm(const function_symbol &sym, InputIterator begin, InputIterator end)
Constructor that provides an aterm based on a function symbol and an input iterator providing the arg...
aterm(const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Constructor that provides an aterm based on a function symbol and forward iterator providing the argu...
aterm & operator=(const aterm &other) noexcept=default
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
std::size_t size_type
An unsigned integral type.
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
aterm(detail::_term_appl *t)
Constructor.
ptrdiff_t difference_type
A signed integral type.
bool empty() const
Returns true if the term has no arguments.
aterm & operator=(aterm &&other) noexcept=default
aterm(const function_symbol &sym)
Constructor.
term_appl_iterator< aterm > iterator
Iterator used to iterate through an term_appl.
size_type size() const
Returns the number of arguments of this term.
term_appl_iterator< aterm > const_iterator
Const iterator used to iterate through an term_appl.
constexpr size_type max_size() const
Returns the largest possible number of arguments.
This class stores a term followed by N arguments. Where N should be equal to the arity of the functio...
const function_symbol & function() const noexcept
void create_appl(aterm &term, const function_symbol &sym, const Terms &... arguments)
void create_term(aterm &term, const function_symbol &sym)
void create_appl_dynamic(aterm &term, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
void create_appl_index(aterm &term, const function_symbol &sym, const Terms &... arguments)
std::size_t arity() const
Return the arity (number of arguments) of the function symbol (function_symbol).
An unprotected term does not change the reference count of the shared term when it is copied or moved...
const detail::_aterm * m_term
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
The main namespace for the aterm++ library.
void(* term_callback)(const aterm &)
std::string pp(const atermpp::aterm &t)
Transform an aterm to an ascii string.
std::ostream & operator<<(std::ostream &out, const atermpp::aterm &t)
Send the term in textual form to the ostream.
void make_term_appl(Term &target, const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
Constructor an aterm in a variable based on a function symbol and an forward iterator providing the a...
void add_deletion_hook(const function_symbol &, term_callback)
Check for reasonably sized aterm (32 bits, 4 bytes) This check might break on perfectly valid archite...
const DerivedCont & container_cast(const Cont< Base > &t, typename std::enable_if_t< is_container< DerivedCont, aterm >::value &&std::is_same_v< Cont< typename DerivedCont::value_type >, DerivedCont > &&!std::is_base_of_v< DerivedCont, Cont< Base > > &&is_convertible< Base, typename DerivedCont::value_type >::value > *=nullptr)
void make_term_appl_with_index(aterm &target, const function_symbol &symbol, const Terms &...arguments)
Constructor for n-arity function application with an index.
const Derived & vertical_cast(const Base &t, typename std::enable_if< is_convertible< Base, Derived >::value >::type *=nullptr)
A cast form an aterm derived class to a class that inherits in possibly multiple steps from this clas...
const Derived & down_cast(const Base &t, typename std::enable_if< is_convertible< Base, Derived >::value &&!std::is_base_of< Derived, Base >::value >::type *=nullptr)
A cheap cast from one aterm based type to another When casting one aterm based type into another,...
Derived & reference_cast(Base &t, typename std::enable_if< is_convertible< Base, Derived >::value &&!std::is_base_of< Derived, Base >::value >::type *=nullptr)
A cast from one aterm based type to another, as a reference, allowing to assign to it.
void swap(atermpp::unprotected_aterm_core &t1, atermpp::unprotected_aterm_core &t2) noexcept
Swaps two aterms.
std::size_t operator()(const atermpp::aterm &t) const