Variables#

#include <heyoka/variable.hpp>

The variable class#

class variable#

This class is used to represent symbolic variables in heyoka’s expression system.

Variables are uniquely identified by their name.

Note

Variable names beginning with a double underscore (__) are reserved for internal use.

variable() noexcept#

Default constructor.

The default constructor initialises a variable with an empty name.

explicit variable(std::string name)#

Constructor from name.

Parameters:

name – the name of the variable.

Exception:

any exception thrown by the copy constructor of std::string.

variable(const variable&)#
variable(variable&&) noexcept#
variable &operator=(const variable&)#
variable &operator=(variable&&) noexcept#
~variable()#

Variables are copy/move constructible, copy/move assignable and destructible.

Exception:

any exception thrown by the copy constructor/copy assignment operator of std::string.

[[nodiscard]] const std::string &name() const noexcept#

Name getter.

Returns:

a reference to the name of the variable.

Functions#

void swap(variable &a, variable &b) noexcept#

Swap primitive.

This function will efficiently swap a and b.

Parameters:
  • a – the first variable.

  • b – the second variable.

std::ostream &operator<<(std::ostream &os, const variable &v)#

Stream operator.

Parameters:
  • os – the output stream.

  • v – the input variable.

Returns:

a reference to os.

Exception:

any exception thrown by the stream operator of std::string.

Operators#

bool operator==(const variable &a, const variable &b) noexcept#
bool operator!=(const variable &a, const variable &b) noexcept#

Equality comparison operators.

Two variables are considered equal if they have the same name.

Parameters:
  • a – the first variable.

  • b – the second variable.

Returns:

the result of the comparison.

Standard library specialisations#

template<>
struct std::hash<heyoka::variable>#

Specialisation of std::hash for heyoka::variable.

std::size_t operator()(const heyoka::variable &v) const noexcept#
Parameters:

v – the input heyoka::variable.

Returns:

a hash value for v.