![]() |
FIMS
v0.8.1
|
A class that provides shared ownership of an integer value. More...
#include <rcpp_shared_primitive.hpp>
Public Member Functions | |
| SharedInt () | |
Construct a new SharedInt object. | |
| SharedInt (int val) | |
Constructs a new SharedInt object. | |
| SharedInt (const SharedInt &other) | |
Copy constructs a new SharedInt object. | |
| SharedInt & | operator= (const SharedInt &other) |
Overloaded assignment operator for copying a SharedInt object. | |
| SharedInt & | operator= (const int &other) |
| Overloaded assignment operator for an integer value. | |
| SharedInt (SharedInt &&other) noexcept | |
Constructs a new SharedInt object by moving resources. | |
| SharedInt & | operator= (SharedInt &&other) noexcept |
| Overloaded move assignment operator. | |
| int | get () const |
| Retrieve the value of the integer. | |
| void | set (int val) |
| Change the value of the integer. | |
| operator int () | |
User-defined conversion to int. | |
| int | operator* () const |
| Overloads the dereference operator. | |
| int * | operator-> () |
Overloads the member access operator (->). | |
| const int * | operator-> () const |
Overloads the member access operator (->) for const objects. | |
| SharedInt & | operator++ () |
Overloads the prefix increment operator (++). | |
| SharedInt | operator++ (int) |
Overloads the postfix increment operator (++). | |
| SharedInt & | operator-- () |
Overloads the prefix decrement operator (--). | |
| SharedInt | operator-- (int) |
| Overloads the postfix decrement operator. | |
| SharedInt | operator+ (const SharedInt &other) const |
Overloads the binary addition operator (+). | |
| SharedInt | operator- (const SharedInt &other) const |
Overloads the binary subtraction operator (-). | |
| SharedInt | operator* (const SharedInt &other) const |
Overloads the binary multiplication operator (*). | |
| SharedInt | operator/ (const SharedInt &other) const |
Overloads the binary division operator (/). | |
| SharedInt | operator+ (const int &other) const |
| Overloads the binary addition operator for an integer value. | |
| SharedInt | operator- (const int &other) const |
| Overloads the binary subtraction operator for an integer value. | |
| SharedInt | operator* (const int &other) const |
| Overloads the binary multiplication operator for an integer value. | |
| SharedInt | operator/ (const int &other) const |
| Overloads the binary division operator for an integer value. | |
| SharedInt & | operator+= (const SharedInt &other) |
Overloads the compound assignment operator (+=). | |
| SharedInt & | operator-= (const SharedInt &other) |
Overloads the compound assignment operator (-=). | |
| SharedInt & | operator*= (const SharedInt &other) |
Overloads the compound assignment operator (*=). | |
| SharedInt & | operator/= (const SharedInt &other) |
Overloads the compound assignment operator (/=). | |
| SharedInt & | operator+= (const int &other) |
Overloads the compound assignment operator (+=) for a shared integer value. | |
| SharedInt & | operator-= (const int &other) |
Overloads the compound assignment operator (-=) for a shared integer value. | |
| SharedInt & | operator*= (const int &other) |
Overloads the compound assignment operator (*=) for a shared integer value. | |
| SharedInt & | operator/= (const int &other) |
Overloads the compound assignment operator (/=) for a shared integer value. | |
| bool | operator== (const SharedInt &other) const |
Overloads the equality operator (==). | |
| bool | operator!= (const SharedInt &other) const |
Overloads the inequality operator (!=). | |
| bool | operator< (const SharedInt &other) const |
Overloads the less-than operator (<). | |
| bool | operator<= (const SharedInt &other) const |
Overloads the less-than-or-equal-to operator (<=). | |
| bool | operator> (const SharedInt &other) const |
Overloads the greater-than operator (>). | |
| bool | operator>= (const SharedInt &other) const |
Overloads the greater-than-or-equal-to operator (>=). | |
| bool | operator== (const int &other) const |
Overloads the equality operator (==) for an integer value. | |
| bool | operator!= (const int &other) const |
Overloads the inequality operator (!=) for an integer value. | |
| bool | operator< (const int &other) const |
Overloads the less-than operator (<) for an integer value. | |
| bool | operator<= (const int &other) const |
Overloads the less-than-or-equal-to operator (<=) for an integer value. | |
| bool | operator> (const int &other) const |
Overloads the greater-than operator (>) for an integer value. | |
| bool | operator>= (const int &other) const |
Overloads the greater-than-or-equal-to operator (>=) for an integer value. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const SharedInt &sp) |
Overloads the stream insertion operator (<<) for SharedInt. | |
A class that provides shared ownership of an integer value.
This class wraps a std::shared_ptr to provide a reference-counted integer value. When a SharedInt object is copied, it shares the same underlying integer with the original object. The integer's memory is automatically deallocated when the last SharedInt object pointing to it is destroyed.
|
inline |
Constructs a new SharedInt object.
Initializes the object by creating a std::shared_ptr to an integer with the provided value.
| val | The integer value to be stored in the shared pointer. |
|
inlinenoexcept |
Constructs a new SharedInt object by moving resources.
Transfers ownership of the shared integer from other to the new object. This is a non-throwing operation that is more efficient than a copy.
| other | The temporary SharedInt object to move from. After this call, other will no longer own the resource. |
|
inline |
Retrieve the value of the integer.
|
inline |
User-defined conversion to int.
This conversion operator allows the object to be implicitly converted to an int. The returned value is the integer managed by the object's internal shared pointer, which is retrieved by calling get().
Overloads the inequality operator (!=) for an integer value.
Compares the integer value of the current object with an int for inequality. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the values are not equal, false otherwise. Overloads the inequality operator (!=).
Compares the integer value of the current object with the integer value of other for inequality. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the values are not equal, false otherwise.
|
inline |
Overloads the dereference operator.
Provides a convenient way to access the integer value held by the shared pointer. This function is const, meaning it provides read-only access and does not modify the object's state.
Overloads the binary multiplication operator for an integer value.
Multiplies the integer value of the current object by the integer value of other. This operation does not modify the current object; it returns a new SharedInt object containing the product.
| other | The integer value to multiply the current object by. |
SharedInt object containing the product of the two values. Overloads the binary multiplication operator (*).
Multiplies the integer value of the current object by the integer value of the other object. This operation does not modify either object; it returns a new SharedInt object containing the product.
| other | The SharedInt object to multiply the current object by. |
SharedInt object containing the product of the two values. Overloads the compound assignment operator (*=) for a shared integer value.
Multiplies the integer value of the current object by the integer value of other, modifying the object in place.
| other | The integer value to multiply the current object by. |
*this) after the multiplication. Overloads the compound assignment operator (*=).
Multiplies the integer value of the current object by the value of other, modifying the object in place.
| other | The SharedInt object to multiply by. |
*this) after the multiplication. Overloads the binary addition operator for an integer value.
Adds an integer value to the integer value of the current object. This operation does not modify the current object; it returns a new SharedInt object containing the sum.
| other | The integer value to add to the current object. |
SharedInt object containing the sum of the two values. Overloads the binary addition operator (+).
Adds the integer value of the current object to the integer value of the other object. This operation does not modify either object; it returns a new SharedInt object containing the sum.
| other | The SharedInt object to add to the current object. |
SharedInt object containing the sum of the two values.
|
inline |
Overloads the prefix increment operator (++).
Increments the integer value managed by the shared pointer. As a prefix operator, it increments the value before returning the result.
*this) after the increment has occurred. Overloads the postfix increment operator (++).
This is a postfix operation. It first creates a copy of the object's current state, then increments the underlying integer value, and finally returns the temporary copy, which holds the original value. A dummy parameter used by the compiler to distinguish this operator from the prefix version.
Overloads the compound assignment operator (+=) for a shared integer value.
Adds an integer value to the current object's value, modifying the object in place.
| other | The integer value to add to the current object. |
*this) after the addition. Overloads the compound assignment operator (+=).
Adds the integer value of other to the current object's value, modifying the object in place.
| other | The SharedInt object to add. |
*this) after the addition. Overloads the binary subtraction operator for an integer value.
Subtracts an integer value from the integer value of the current object. This operation does not modify the current object; it returns a new SharedInt object containing the result.
| other | The integer value to subtract from the current object. |
SharedInt object containing the result of the subtraction. Overloads the binary subtraction operator (-).
Subtracts the integer value of the current object to the integer value of the other object. This operation does not modify either object; it returns a new SharedInt object containing the difference.
| other | The SharedInt object to subtract from the current object. |
SharedInt object containing the difference of the two values.
|
inline |
Overloads the prefix decrement operator (--).
Decrements the integer value managed by the shared pointer. As a prefix operator, it decrements the value before returning the result.
*this) after the decrement has occurred. Overloads the postfix decrement operator.
This is a postfix operation. It first creates a copy of the object's current state, then decrements the underlying integer value, and finally returns the temporary copy, which holds the original value. A dummy parameter used by the compiler to distinguish this operator from the prefix version.
Overloads the compound assignment operator (-=) for a shared integer value.
Subtracts an integer value from the current object's value, modifying the object in place.
| other | The integer value to subtract from the current object. |
*this) after the subtraction. Overloads the compound assignment operator (-=).
Subtracts the integer value of other from the current object's value, modifying the object in place.
| other | The SharedInt object to subtract. |
*this) after the subtraction.
|
inline |
Overloads the member access operator (->).
Provides a way to access the integer value by returning a raw pointer to it. This function returns the result of std::shared_ptr::get().
int*) to the integer managed by the shared pointer. Overloads the member access operator (->) for const objects.
This function provides a way to get a read-only raw pointer to the underlying integer. The const return type prevents modification of the integer value through this pointer. The function itself is also const, ensuring it can be called on const instances of the class.
const raw pointer to the integer managed by the shared pointer. Overloads the binary division operator for an integer value.
Divides the integer value of the current object by the integer value of other. This operation does not modify the current object; it returns a new SharedInt object containing the quotient.
| other | The integer value to divide the current object by. |
SharedInt object containing the quotient of the two values. Overloads the binary division operator (/).
Divides the integer value of the current object by the integer value of the other object. This operation does not modify either object; it returns a new SharedInt object containing the result of the division.
| other | The SharedInt object to divide the current object by. |
SharedInt object containing the quotient of the two values. Overloads the compound assignment operator (/=) for a shared integer value.
Divides the integer value of the current object by the integer value of other, modifying the object in place.
| other | The integer value to divide the current object by. |
*this) after the division. Overloads the compound assignment operator (/=).
Divides the integer value of the current object by the value of other, modifying the object in place.
| other | The SharedInt object to divide by. |
*this) after the division. Overloads the less-than operator (<) for an integer value.
Compares the integer value of the current object with an int. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the current object's value is less than other, false otherwise. Overloads the less-than operator (<).
Compares the integer value of the current object with the integer value of other. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the current object's value is less than other's value, false otherwise. Overloads the less-than-or-equal-to operator (<=) for an integer value.
Compares the integer value of the current object with an int. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the current object's value is less than or equal to other, false otherwise. Overloads the less-than-or-equal-to operator (<=).
Compares the integer value of the current object with the integer value of other. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the current object's value is less than or equal to other's value, false otherwise. Overloaded assignment operator for an integer value.
Assigns a new integer value to the underlying shared integer. This operation modifies the shared state of the object.
| other | The integer value to assign. |
*this). Overloaded assignment operator for copying a SharedInt object.
Assigns the shared state of other to the current object. If the object is not self-assigned, it will share ownership of the same integer value.
| other | The SharedInt object to assign from. |
*this) to allow for chaining assignments. Overloaded move assignment operator.
Moves the shared state from other to the current object, releasing any resources the current object might have held. This is more efficient than a copy operation.
| other | The temporary SharedInt object to move from. |
*this). Overloads the equality operator (==) for an integer value.
Compares the integer value of the current object with an int for equality. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the values are equal, false otherwise. Overloads the equality operator (==).
Compares the integer value of the current object with the integer value of other for equality. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the values are equal, false otherwise. Overloads the greater-than operator (>) for an integer value.
Compares the integer value of the current object with an int. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the current object's value is greater than other, false otherwise. Overloads the greater-than operator (>).
Compares the integer value of the current object with the integer value of other. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the current object's value is greater than other's value, false otherwise. Overloads the greater-than-or-equal-to operator (>=) for an integer value.
Compares the integer value of the current object with an int. This is a non-mutating operation.
| other | The integer value to compare against. |
true if the current object's value is greater than or equal to other, false otherwise. Overloads the greater-than-or-equal-to operator (>=).
Compares the integer value of the current object with the integer value of other. This is a non-mutating operation.
| other | The SharedInt object to compare against. |
true if the current object's value is greater than or equal to other's value, false otherwise. Change the value of the integer.
| val | An integer value to set. |