12 #include <type_traits>
52 return os <<
"Uninterpreted";
54 return os <<
"Bitvector";
56 assert(
false &&
"Invalid enum value for VariableType");
108 assert(0 <
id &&
id < (1UL <<
AVAILABLE));
123 constexpr std::size_t
id() const noexcept {
139 std::string
name()
const;
153 constexpr std::size_t
rank() const noexcept {
171 return lhs.mContent == rhs.mContent;
174 return lhs.mContent != rhs.mContent;
177 return lhs.mContent < rhs.mContent;
180 return lhs.mContent <= rhs.mContent;
183 return lhs.mContent > rhs.mContent;
186 return lhs.mContent >= rhs.mContent;
191 static constexpr std::size_t
BITSIZE = CHAR_BIT *
sizeof(std::size_t);
198 static_assert(
RESERVED <
BITSIZE,
"Too many bits reserved for special use.");
205 static_assert(std::is_trivially_copyable<Variable>::value,
"Variable should be trivially copyable.");
214 return os << rhs.
name();
231 return variable.id();
A small wrapper that configures logging for carl.
carl is the main namespace for the library.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
VariableType
Several types of variables are supported.
constexpr auto underlying_enum_value(Enum e)
Casts an enum value to a value of the underlying number type.
A Variable represents an algebraic variable that can be used throughout carl.
std::string safe_name() const
Retrieves a unique name of the variable of the form <type><id>.
friend bool operator>=(Variable lhs, Variable rhs) noexcept
Compares two variables.
friend bool operator<=(Variable lhs, Variable rhs) noexcept
Compares two variables.
constexpr std::size_t rank() const noexcept
Retrieves the rank of the variable.
friend bool operator<(Variable lhs, Variable rhs) noexcept
Compares two variables.
static constexpr std::size_t RESERVED_FOR_RANK
Number of bits reserved for the rank.
Variable(std::size_t id, VariableType type=VariableType::VT_REAL, std::size_t rank=0) noexcept
Private constructor to be used by the VariablePool.
friend bool operator!=(Variable lhs, Variable rhs) noexcept
Compares two variables.
friend bool operator==(Variable lhs, Variable rhs) noexcept
Compares two variables.
static constexpr std::size_t BITSIZE
Number of bits available for the content.
static constexpr std::size_t RESERVED_FOR_TYPE
Number of bits reserved for the type.
friend bool operator>(Variable lhs, Variable rhs) noexcept
Compares two variables.
std::string name() const
Retrieves the name of the variable.
constexpr Variable()=default
Default constructor, constructing a variable, which is considered as not an actual variable.
static const Variable NO_VARIABLE
Instance of an invalid variable.
constexpr std::size_t id() const noexcept
Retrieves the id of the variable.
static constexpr std::size_t RESERVED
Overall number of bits reserved.
std::size_t mContent
The content of the variable.
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
static constexpr std::size_t AVAILABLE
Number of bits available for the id.
std::size_t operator()(const carl::Variable variable) const noexcept
Calculates the hash of a Variable.