mCRL2
Loading...
Searching...
No Matches
workarounds.h
Go to the documentation of this file.
1// Author(s): Maurice Laveaux
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9
10#ifndef MCRL2_UTILITIES_WORKAROUNDS_H
11#define MCRL2_UTILITIES_WORKAROUNDS_H
12
13#include <algorithm>
14
15namespace mcrl2
16{
17namespace workaround
18{
19 /// \brief This is a workaround for the return by value diagnostic (clang -Wreturn-std-move).
20 /// Description: The user probably expected a move, but they're not getting a move, perhaps because
21 /// the type of "x" is different from the return type of the function.
22 /// \details This constraint might be lifted by newer C++ standards and then this workaround can easily be removed.
23 template<typename T>
25 {
26 return std::move(t);
27 }
28}
29}
30
31#endif // MCRL2_UTILITIES_WORKAROUNDS_H
An integer term stores a single std::size_t value. It carries no arguments.
Definition aterm_int.h:26
aterm_int(std::size_t value)
Constructs an integer term from a value.
Definition aterm_int.h:34
aterm_int & operator=(aterm_int &&other) noexcept=default
aterm_int(const aterm &t)
Constructs an integer term from an aterm.
Definition aterm_int.h:40
aterm_int() noexcept
Default constructor.
Definition aterm_int.h:29
aterm_int & operator=(const aterm_int &other) noexcept=default
aterm_int(const aterm_int &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
std::size_t value() const noexcept
Provide the value stored in an aterm.
Definition aterm_int.h:54
void swap(aterm_int &t) noexcept
Swaps two integer terms without changing the protection.
Definition aterm_int.h:61
aterm_int(aterm_int &&other) noexcept=default
const function_symbol & function() const
Returns the function symbol belonging to an aterm.
Definition aterm.h:144
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
The underlying integer term that actually carries the integer data.
Definition aterm_int.h:22
std::size_t value() const noexcept
Definition aterm_int.h:30
This is the class to which an aterm points.
Definition aterm_core.h:48
const function_symbol & function() const noexcept
Definition aterm_core.h:55
const function_symbol & as_empty_list() noexcept
Definition aterm_pool.h:124
const function_symbol & as_list() noexcept
Definition aterm_pool.h:121
aterm & empty_list() noexcept
Definition aterm_pool.h:115
void enable_garbage_collection(bool enable)
Enable garbage collection when passing true and disable otherwise.
Definition aterm_pool.h:130
void create_int(aterm &term, std::size_t val)
bool operator==(const function_symbol &f) const
Equality test.
Reverse iterator for term_list.
reverse_term_list_iterator & operator=(const reverse_term_list_iterator &other)=delete
Assignment is not available.
bool operator>=(const reverse_term_list_iterator &other) const
Comparison of iterators.
bool operator>(const reverse_term_list_iterator &other) const
Comparison of iterators.
reverse_term_list_iterator()
Default constructor.
bool operator==(const reverse_term_list_iterator &other) const
Equality of iterators.
reverse_term_list_iterator(detail::_aterm const *l)
Constructor from an aterm which must be a list.
bool operator<=(const reverse_term_list_iterator &other) const
Comparison of iterators.
reverse_term_list_iterator & operator++()
Prefix increment operator on iterator.
const Term & operator*() const
Dereference operator on an iterator.
bool operator<(const reverse_term_list_iterator &other) const
Comparison of iterators.
const Term * operator->() const
Arrow operator on an iterator.
reverse_term_list_iterator(const reverse_term_list_iterator &other)=delete
The copy constructor is not available.
std::unique_ptr< detail::_aterm_list< Term > const *[]> m_list_element_references
bool operator!=(const reverse_term_list_iterator &other) const
Inequality of iterators.
void operator++(int)
Postfix increment operator on iterator.
std::forward_iterator_tag iterator_category
Iterator for term_list.
const detail::_aterm_list< Term > * m_list
term_list_iterator()
Default constructor.
std::forward_iterator_tag iterator_category
bool operator<=(const term_list_iterator &other) const
Comparison of iterators.
bool operator<(const term_list_iterator &other) const
Comparison of iterators.
term_list_iterator & operator=(const term_list_iterator &other)
Assignment.
term_list_iterator operator++(int)
Postfix increment operator on iterator.
bool operator>(const term_list_iterator &other) const
Comparison of iterators.
term_list_iterator(const term_list_iterator &other)
Copy constructor.
const Term & operator*() const
Dereference operator on an iterator.
term_list_iterator(const detail::_aterm *l)
Constructor from an aterm which must be a list.
bool operator>=(const term_list_iterator &other) const
Comparison of iterators.
bool operator!=(const term_list_iterator &other) const
Inequality of iterators.
term_list_iterator & operator++()
Prefix increment operator on iterator.
bool operator==(const term_list_iterator &other) const
Equality of iterators.
const Term * operator->() const
Arrow operator on an iterator.
A list of aterm objects.
Definition aterm_list.h:24
size_type size() const
Returns the size of the term_list.
Definition aterm_list.h:256
term_list(const term_list< Term > &t) noexcept
Copy constructor.
Definition aterm_list.h:76
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:282
Term value_type
The type of object, T stored in the term_list.
Definition aterm_list.h:34
const_reverse_iterator rend() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:297
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, const ATermFilter &aterm_filter, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last, converting and filtering the list.
Definition aterm_list.h:137
std::size_t size_type
An unsigned integral type.
Definition aterm_list.h:46
term_list & operator=(const term_list &other) noexcept=default
This class has user-declared copy constructor so declare copy and move assignment.
reverse_term_list_iterator< Term > const_reverse_iterator
Const iterator used to iterate through an term_list.
Definition aterm_list.h:58
const Term & const_reference
Const reference to T.
Definition aterm_list.h:43
const term_list< Term > & tail() const
Returns the tail of the list.
Definition aterm_list.h:225
const Term & front() const
Returns the first element of the list.
Definition aterm_list.h:239
term_list(term_list< Term > &&t) noexcept
Move constructor.
Definition aterm_list.h:84
ptrdiff_t difference_type
A signed integral type.
Definition aterm_list.h:49
term_list & operator=(term_list &&other) noexcept=default
void pop_front()
Removes the first element of the list.
Definition aterm_list.h:232
term_list(const aterm &t) noexcept
Constructor from an aterm.
Definition aterm_list.h:67
term_list_iterator< Term > iterator
Iterator used to iterate through an term_list.
Definition aterm_list.h:52
Term & reference
Reference to T.
Definition aterm_list.h:40
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
size_type max_size() const
Returns the largest possible size of the term_list.
Definition aterm_list.h:304
void emplace_front(Args &&... arguments)
Construct and insert a new element at the beginning of the current list.
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last converting the elements before inserting.
Definition aterm_list.h:117
term_list_iterator< Term > const_iterator
Const iterator used to iterate through an term_list.
Definition aterm_list.h:55
Term * pointer
Pointer to T.
Definition aterm_list.h:37
term_list(detail::_aterm_appl<> *t) noexcept
Constructor for term lists from internally constructed terms delivered as reference.
Definition aterm_list.h:27
bool empty() const
Returns true if the list's size is 0.
Definition aterm_list.h:268
term_list(std::initializer_list< Term > init)
A constructor based on an initializer list.
Definition aterm_list.h:214
term_list(Iter first, Iter last, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list with the elements from first to last.
Definition aterm_list.h:99
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
const_reverse_iterator rbegin() const
Returns a const_reverse_iterator pointing to the end of the term_list.
Definition aterm_list.h:290
term_list() noexcept
Default constructor. Creates an empty list.
Definition aterm_list.h:61
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
Definition aterm_core.h:72
void swap(unprotected_aterm_core &t) noexcept
Swaps this term with its argument.
Definition aterm_core.h:152
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:83
bool defined() const
Returns true if this term is not equal to the term assigned by the default constructor of aterms,...
Definition aterm_core.h:143
friend detail::_aterm * detail::address(const unprotected_aterm_core &t)
const detail::_aterm * m_term
Definition aterm_core.h:36
bool type_is_int() const noexcept
Dynamic check whether the term is an aterm_int.
Definition aterm_core.h:63
Exception class for errors raised by the command-line parser.
Definition exception.h:39
virtual ~command_line_error()
Definition exception.h:57
static std::string format(const std::string &name, const std::string &message)
Definition exception.h:44
command_line_error(const std::string &name, const std::string &message)
Definition exception.h:53
Standard exception class for reporting runtime errors.
Definition exception.h:27
runtime_error(const std::string &message)
Constructor.
Definition exception.h:31
cached_bottom_up_replace_aterm_builder< Builder, ReplaceFunction > make_cached_bottom_up_replace_aterm_builder(ReplaceFunction f, std::unordered_map< aterm, aterm > &cache)
Definition algorithm.h:165
aterm make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. The iterators are traversed backwards and each element...
replace_aterm_builder< Builder, ReplaceFunction > make_replace_aterm_builder(ReplaceFunction f)
Definition algorithm.h:58
partial_replace_aterm_builder< Builder, ReplaceFunction > make_partial_replace_aterm_builder(ReplaceFunction f)
Definition algorithm.h:95
void make_list_forward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. Each element is converted using the TermConverter.
void make_list_forward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list traversing the iterator from first to last, putting the result in place in the vari...
aterm make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. Each element is converted using the TermConverter.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
void make_list_forward_helper(term_list< Term > &result, ForwardTraversalIterator &p, const ForwardTraversalIterator last, Transformer transformer)
aterm make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list starting from first to last. Each element is converted using the TermConverter and ...
void make_list_backward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Construct a list iterating from the last to the first element. Result is put in the variable result.
void make_list_backward(term_list< Term > &result, Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last where the result is put in result.
bottom_up_replace_aterm_builder< Builder, ReplaceFunction > make_bottom_up_replace_aterm_builder(ReplaceFunction f)
Definition algorithm.h:126
aterm make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter)
Constructs a list starting from first to last. The iterators are traversed backwards and each element...
The main namespace for the aterm++ library.
Definition algorithm.h:21
Term replace(const Term &t, ReplaceFunction r)
Replaces each subterm x of t by r(x). The ReplaceFunction r has the following signature: aterm x; ate...
Definition algorithm.h:246
term_list< Term > remove_one_element(const term_list< Term > &list, const Term &t)
Term replace(const Term &t, const aterm &old_value, const aterm &new_value)
Replaces each subterm in t that is equal to old_value with new_value. The replacements are performed ...
Definition algorithm.h:261
void make_term_list(term_list< Term > &target)
Make an empty list and put it in target;.
Definition aterm_list.h:314
term_list< aterm > aterm_list
A term_list with elements of type aterm.
Definition aterm_list.h:497
Term bottom_up_replace(Term t, ReplaceFunction r, std::unordered_map< aterm, aterm > &cache)
Replaces each subterm x of t by r(x). The ReplaceFunction r has the following signature: aterm x; ate...
Definition algorithm.h:326
void partial_find_all_if(Term t, MatchPredicate match, StopPredicate stop, OutputIterator destBegin)
Finds all subterms of t that match a given predicate, and writes the found terms to the destination r...
Definition algorithm.h:230
void make_term_list(term_list< Term > &target, Iter first, Iter last, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list with the elements from first to last.
Definition aterm_list.h:325
Term bottom_up_replace(Term t, const aterm &old_value, const aterm &new_value)
Replaces each subterm in t that is equal to old_value with new_value. The replacements are performed ...
Definition algorithm.h:291
aterm find_if(const Term &t, MatchPredicate match)
Finds a subterm of t that matches a given predicate.
Definition algorithm.h:189
std::set< T > as_set(const atermpp::term_list< T > &x)
Converts the given term list to a set.
Definition aterm_list.h:568
UnaryFunction for_each(Term t, UnaryFunction op)
Calls op(elem) for subterms of the term t.
Definition algorithm.h:179
void find_all_if(const Term &t, MatchPredicate match, OutputIterator destBegin)
Finds all subterms of t that match a given predicate, and writes the found terms to the destination r...
Definition algorithm.h:215
Term partial_replace(Term t, ReplaceFunction r)
Replaces subterms x of t by r(x). The replace function r returns an additional boolean value....
Definition algorithm.h:308
term_list< Term > sort_list(const term_list< Term > &l, const std::function< bool(const Term &, const Term &)> &ordering=[](const Term &t1, const Term &t2){ return t1< t2;})
Returns the list with the elements sorted according to given ordering which is by default the orderin...
term_list< Term > reverse(const term_list< Term > &l)
Returns the list with the elements in reversed order.
aterm partial_find_if(Term t, MatchPredicate match, StopPredicate stop)
Finds a subterm of t that matches a given predicate. The term is only partially traversed....
Definition algorithm.h:204
constexpr std::size_t LengthOfShortList
void make_term_list(term_list< Term > &target, std::initializer_list< Term > init)
A constructor based on an initializer list.
Definition aterm_list.h:446
void make_term_list(term_list< Term > &target, Iter first, Iter last, const ATermConverter &convert_to_aterm, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last converting the elements before inserting.
Definition aterm_list.h:343
std::conditional< std::is_convertible< Term2, Term1 >::value, term_list< Term1 >, term_list< Term2 > >::type operator+(const term_list< Term1 > &l, const term_list< Term2 > &m)
Returns the concatenation of two lists with convertible element types.
void make_aterm_int(aterm_int &target, std::size_t value)
Constructs an integer term from a value.
Definition aterm_int.h:69
std::vector< T > as_vector(const atermpp::term_list< T > &x)
Converts the given term list to a vector.
Definition aterm_list.h:561
void make_term_list(term_list< Term > &target, Iter first, Iter last, const ATermConverter &convert_to_aterm, const ATermFilter &aterm_filter, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last, converting and filtering the list.
Definition aterm_list.h:364
void make_reverse(term_list< Term > &result, const term_list< Term > &l)
Term bottom_up_replace(Term t, ReplaceFunction r)
Replaces each subterm x of t by r(x). The ReplaceFunction r has the following signature: aterm x; ate...
Definition algorithm.h:276
term_list< Term > merge_lists(const term_list< Term > &l1, const term_list< Term > &l2, const std::function< bool(const Term &, const Term &)> &ordering=[](const Term &t1, const Term &t2){ return t1< t2;})
Returns the merged list sorted according to the <-operator, which is by default the ordering of addre...
term_list< Term > push_back(const term_list< Term > &l, const Term &el)
Appends a new element at the end of the list. Note that the complexity of this function is O(n),...
T && return_std_move(T &t)
This is a workaround for the return by value diagnostic (clang -Wreturn-std-move)....
Definition workarounds.h:24
void swap(atermpp::term_list< T > &t1, atermpp::term_list< T > &t2) noexcept
Swaps two term_lists.
Definition aterm_list.h:585
void swap(atermpp::aterm_int &t1, atermpp::aterm_int &t2) noexcept
Swaps two aterm_ints.
Definition aterm_int.h:87
int main(int argc, char *argv[])
void leave(const T &)
Definition builder.h:35
Derived & derived()
Definition builder.h:23
void enter(const T &)
Definition builder.h:30
void apply(T &result, const aterm_int &x)
Definition builder.h:39
void apply(T &result, const aterm &x)
Definition builder.h:67
void apply(T &result, const aterm_list &x)
Definition builder.h:47
Builder< bottom_up_replace_aterm_builder< Builder, ReplaceFunction > > super
Definition algorithm.h:103
void apply(T &result, const aterm &x)
Definition algorithm.h:116
Builder< cached_bottom_up_replace_aterm_builder< Builder, ReplaceFunction > > super
Definition algorithm.h:134
std::unordered_map< aterm, aterm > & cache
Definition algorithm.h:141
cached_bottom_up_replace_aterm_builder(ReplaceFunction f_, std::unordered_map< aterm, aterm > &cache_)
Definition algorithm.h:143
void apply(T &result, const aterm &x)
Definition algorithm.h:79
Builder< partial_replace_aterm_builder< Builder, ReplaceFunction > > super
Definition algorithm.h:66
void apply(T &result, const aterm &x)
Definition algorithm.h:42
replace_aterm_builder(ReplaceFunction f_)
Definition algorithm.h:37
Builder< replace_aterm_builder< Builder, ReplaceFunction > > super
Definition algorithm.h:29
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const
std::size_t operator()(const atermpp::term_list< Term > &l) const
A specialization of the standard std::hash function.
Definition aterm_list.h:597