![]() |
FIMS
v0.8.1
|
A class that provides shared ownership of an integer value. More...
#include <rcpp_shared_primitive.hpp>
Public Member Functions | |
| SharedReal () | |
Constructs a new SharedReal object with a default value. | |
| SharedReal (int val) | |
Constructs a new SharedReal object from an integer value. | |
| SharedReal (const SharedReal &other) | |
Copy constructs a new SharedReal object. | |
| SharedReal & | operator= (const SharedReal &other) |
| Overloaded copy assignment operator. | |
| SharedReal & | operator= (const int &other) |
| Overloaded assignment operator for an integer value. | |
| SharedReal (SharedReal &&other) noexcept | |
Constructs a new SharedReal object by moving resources. | |
| SharedReal & | operator= (SharedReal &&other) noexcept |
| Overloaded move assignment operator. | |
| int | get () const |
| Retrieves the integer value managed by the object. | |
| void | set (int val) |
| Sets the integer value of the object. | |
| 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. | |
| SharedReal & | operator++ () |
Overloads the prefix increment operator (++). | |
| SharedReal | operator++ (int) |
| Overloads the postfix increment operator. | |
| SharedReal & | operator-- () |
Overloads the prefix decrement operator (--). | |
| SharedReal | operator-- (int) |
| Overloads the postfix decrement operator. | |
| SharedReal | operator+ (const SharedReal &other) const |
Overloads the binary addition operator (+). | |
| SharedReal | operator- (const SharedReal &other) const |
Overloads the binary subtraction operator (-). | |
| SharedReal | operator* (const SharedReal &other) const |
Overloads the binary multiplication operator (*). | |
| SharedReal | operator/ (const SharedReal &other) const |
Overloads the binary division operator (/). | |
| SharedReal | operator+ (const int &other) const |
Overloads the binary addition operator (+) for an integer. | |
| SharedReal | operator- (const int &other) const |
Overloads the binary subtraction operator (-) for an integer. | |
| SharedReal | operator* (const int &other) const |
Overloads the binary multiplication operator (*) for an integer. | |
| SharedReal | operator/ (const int &other) const |
Overloads the binary division operator (/) for an integer. | |
| SharedReal & | operator+= (const SharedReal &other) |
Overloads the compound assignment operator (+=). | |
| SharedReal & | operator-= (const SharedReal &other) |
Overloads the compound assignment operator (-=). | |
| SharedReal & | operator*= (const SharedReal &other) |
Overloads the compound assignment operator (*=). | |
| SharedReal & | operator/= (const SharedReal &other) |
Overloads the compound assignment operator (/=). | |
| SharedReal & | operator+= (const int &other) |
Overloads the compound assignment operator (+=) for an integer. | |
| SharedReal & | operator-= (const int &other) |
Overloads the compound assignment operator (-=) for an integer. | |
| SharedReal & | operator*= (const int &other) |
Overloads the compound assignment operator (*=) for an integer. | |
| SharedReal & | operator/= (const int &other) |
Overloads the compound assignment operator (/=) for an integer. | |
| bool | operator== (const SharedReal &other) const |
Overloads the equality operator (==). | |
| bool | operator!= (const SharedReal &other) const |
Overloads the inequality operator (!=). | |
| bool | operator< (const SharedReal &other) const |
Overloads the less-than operator (<). | |
| bool | operator<= (const SharedReal &other) const |
Overloads the less-than-or-equal-to operator (<=). | |
| bool | operator> (const SharedReal &other) const |
Overloads the greater-than operator (>). | |
| bool | operator>= (const SharedReal &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. | |
| bool | operator< (const int &other) const |
Overloads the less-than operator (<) for an integer. | |
| bool | operator<= (const int &other) const |
Overloads the less-than-or-equal-to operator (<=) for an integer. | |
| bool | operator> (const int &other) const |
Overloads the greater-than operator (>) for an integer. | |
| bool | operator>= (const int &other) const |
Overloads the greater-than-or-equal-to operator (>=) for an integer. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const SharedReal &sp) |
Overloads the stream insertion operator (<<) for SharedReal. | |
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 SharedReal object is copied, it shares the same underlying integer with the original object. The integer's memory is automatically deallocated when the last SharedReal object pointing to it is destroyed.
|
inline |
Constructs a new SharedReal object with a default value.
Initializes the object's internal shared pointer to manage a new integer with a value of zero.
|
inline |
Constructs a new SharedReal object from an integer value.
Initializes the object's internal shared pointer to manage a new integer with the value provided by the val parameter.
| val | The integer value to be stored in the shared pointer. |
|
inline |
Copy constructs a new SharedReal object.
Initializes the object by creating a new shared pointer that shares ownership of the integer managed by another SharedReal object.
| other | The existing SharedReal object to copy from. |
|
inlinenoexcept |
Constructs a new SharedReal 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 and is also known as a move constructor.
| other | The temporary SharedReal object to move from. After this call, other will no longer own the resource. |
|
inline |
Retrieves the integer value managed by the object.
This is a getter function that returns a copy of the integer value. Since the function is const, it can be safely called on a constant instance of the class without modifying its state.
|
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.
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.
|
inline |
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 SharedReal object to compare against. |
true if the values are not equal, false otherwise.
|
inline |
Overloads the dereference operator (*).
Provides direct access to the integer value managed by the internal shared pointer. This function is const and provides a read-only view of the data.
|
inline |
Overloads the binary multiplication operator (*) for an integer.
Multiplies the current object's value by an integer. This operation does not modify the current object; it returns a new SharedReal object containing the product.
| other | The integer value to multiply the current object by. |
SharedReal object containing the product.
|
inline |
Overloads the binary multiplication operator (*).
Multiplies the integer value of the current object by the integer value of other. This operation does not modify either object; it returns a new SharedReal object containing the product.
| other | The SharedReal object to multiply by. |
SharedReal object containing the product of the two values.
|
inline |
Overloads the compound assignment operator (*=) for an integer.
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.
|
inline |
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 SharedReal object to multiply by. |
*this) after the multiplication.
|
inline |
Overloads the binary addition operator (+) for an integer.
Adds an integer value to the current object's value. This operation does not modify the current object; it returns a new SharedReal object containing the sum.
| other | The integer value to add to the current object. |
SharedReal object containing the sum.
|
inline |
Overloads the binary addition operator (+).
Adds the integer value of the current object to the integer value of other. This operation does not modify either object; it returns a new SharedReal object containing the sum.
| other | The SharedReal object to add to the current object. |
SharedReal 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.
|
inline |
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.
|
inline |
Overloads the compound assignment operator (+=) for an integer.
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.
|
inline |
Overloads the compound assignment operator (+=).
Adds the integer value of other to the current object's value, modifying the object in place.
| other | The SharedReal object to add. |
*this) after the addition.
|
inline |
Overloads the binary subtraction operator (-) for an integer.
Subtracts an integer value from the current object's value. This operation does not modify the current object; it returns a new SharedReal object containing the result.
| other | The integer value to subtract from the current object. |
SharedReal object containing the result.
|
inline |
Overloads the binary subtraction operator (-).
Subtracts the integer value of other from the current object's value. This operation does not modify either object; it returns a new SharedReal object containing the result.
| other | The SharedReal object to subtract from the current object. |
SharedReal object containing the result of the subtraction.
|
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.
|
inline |
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.
|
inline |
Overloads the compound assignment operator (-=) for an integer.
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.
|
inline |
Overloads the compound assignment operator (-=).
Subtracts the integer value of other from the current object's value, modifying the object in place.
| other | The SharedReal object to subtract. |
*this) after the subtraction.
|
inline |
Overloads the member access operator (->).
This function provides a way to access the underlying integer value by returning a raw pointer to it. It returns the result of the std::shared_ptr::get() method.
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.
|
inline |
Overloads the binary division operator (/) for an integer.
Divides the current object's value by an integer. This operation does not modify the current object; it returns a new SharedReal object containing the quotient.
| other | The integer value to divide the current object by. |
SharedReal object containing the quotient.
|
inline |
Overloads the binary division operator (/).
Divides the integer value of the current object by the integer value of other. This operation does not modify either object; it returns a new SharedReal object containing the quotient.
| other | The SharedReal object to divide by. |
SharedReal object containing the quotient of the two values.
|
inline |
Overloads the compound assignment operator (/=) for an integer.
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.
|
inline |
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 SharedReal object to divide by. |
*this) after the division. Overloads the less-than operator (<) for an integer.
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.
|
inline |
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 SharedReal 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.
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.
|
inline |
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 SharedReal object to compare against. |
true if the current object's value is less than or equal to other's value, false otherwise.
|
inline |
Overloaded assignment operator for an integer value.
Assigns a new integer value to the underlying shared integer, modifying the object in place.
| other | The integer value to assign. |
*this) to allow for chained assignments.
|
inline |
Overloaded copy assignment operator.
Assigns the shared state of other to the current object. If the objects are not the same, the current object will release its old resource and share ownership of the integer value managed by other.
| other | The SharedReal object to assign from. |
*this) to allow for chained assignments.
|
inlinenoexcept |
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 a non-throwing and more efficient operation than a copy assignment and is also known as a move assignment operator.
| other | The temporary SharedReal 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.
|
inline |
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 SharedReal object to compare against. |
true if the values are equal, false otherwise. Overloads the greater-than operator (>) for an integer.
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.
|
inline |
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 SharedReal 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.
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.
|
inline |
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 SharedReal object to compare against. |
true if the current object's value is greater than or equal to other's value, false otherwise. Sets the integer value of the object.
Assigns a new integer value to the underlying shared integer.
| val | The integer value to set. |
|
friend |
Overloads the stream insertion operator (<<) for SharedReal.
Provides a way to print the integer value of a SharedReal object to an output stream.
| os | The output stream to write to. |
| sp | The SharedReal object to print. |