A class that provides shared ownership of a boolean value.
More...
#include <rcpp_shared_primitive.hpp>
A class that provides shared ownership of a boolean value.
This class wraps a std::shared_ptr to provide a reference-counted boolean value. When a SharedBoolean object is copied, it shares the same underlying boolean with the original object. The boolean's memory is automatically deallocated when the last SharedBoolean object pointing to it is destroyed.
◆ SharedBoolean() [1/4]
| SharedBoolean::SharedBoolean |
( |
| ) |
|
|
inline |
Constructs a new SharedBoolean object with a default value.
Initializes the object's internal shared pointer to manage a new boolean with a default value of false.
◆ SharedBoolean() [2/4]
| SharedBoolean::SharedBoolean |
( |
bool |
val | ) |
|
|
inline |
Constructs a new SharedBoolean object from a boolean value.
Initializes the object's internal shared pointer to manage a new boolean with the value provided by the val parameter.
- Parameters
-
| val | The boolean value to be stored in the shared pointer. |
◆ SharedBoolean() [3/4]
Copy constructs a new SharedBoolean object.
Initializes the object by creating a new shared pointer that shares ownership of the boolean managed by another SharedBoolean object.
- Parameters
-
◆ SharedBoolean() [4/4]
Constructs a new SharedBoolean object by moving resources.
Transfers ownership of the shared boolean from other to the new object. This is a non-throwing operation that is more efficient than a copy.
- Parameters
-
| other | The temporary SharedBoolean object to move from. After this call, other will no longer own the resource. |
◆ get()
| bool SharedBoolean::get |
( |
| ) |
const |
|
inline |
Retrieves the boolean value managed by the object.
This is a getter function that returns a copy of the boolean value. Since the function is const, it can be safely called on a constant instance of the class without modifying its state.
- Returns
- The boolean value managed by the shared pointer.
◆ operator bool()
| SharedBoolean::operator bool |
( |
| ) |
|
|
inline |
User-defined conversion to bool.
This conversion operator allows the object to be implicitly converted to a bool. The returned value is the boolean managed by the object's internal shared pointer.
- Returns
- The boolean value held by the object.
◆ operator!=() [1/2]
Overloads the inequality operator (!=) for a boolean value.
Compares the boolean value of the current object with a bool for inequality. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the values are not equal, false otherwise.
◆ operator!=() [2/2]
Overloads the inequality operator (!=).
Compares the boolean value of the current object with the boolean value of other for inequality. This is a non-mutating operation.
- Parameters
-
- Returns
true if the values are not equal, false otherwise.
◆ operator*()
| bool SharedBoolean::operator* |
( |
| ) |
const |
|
inline |
Overloads the dereference operator (*).
Provides direct access to the boolean value managed by the internal shared pointer. This function is const and provides a read-only view of the data.
- Returns
- The boolean value held by the object.
◆ operator->() [1/2]
| bool * SharedBoolean::operator-> |
( |
| ) |
|
|
inline |
Overloads the member access operator (->).
This function provides a way to access the underlying boolean value by returning a raw pointer to it. It returns the result of the std::shared_ptr::get() method.
- Returns
- A raw pointer (
bool*) to the boolean managed by the shared pointer.
◆ operator->() [2/2]
| const bool * SharedBoolean::operator-> |
( |
| ) |
const |
|
inline |
Overloads the member access operator (->) for const objects.
This function provides a way to get a read-only raw pointer to the underlying boolean. The const return type prevents modification of the boolean value through this pointer. The function itself is also const, ensuring it can be called on const instances of the class.
- Returns
- A
const raw pointer to the boolean managed by the shared pointer.
◆ operator<() [1/2]
Overloads the less-than operator (<) for a boolean value.
Compares the boolean value of the current object with a bool. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the current object's value is less than other, false otherwise.
◆ operator<() [2/2]
Overloads the less-than operator (<).
Compares the boolean value of the current object with the boolean value of other. This is a non-mutating operation.
- Parameters
-
- Returns
true if the current object's value is less than other's value, false otherwise.
◆ operator<=() [1/2]
Overloads the less-than-or-equal-to operator (<=) for a boolean.
Compares the boolean value of the current object with a bool. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the current object's value is less than or equal to other, false otherwise.
◆ operator<=() [2/2]
Overloads the less-than-or-equal-to operator (<=).
Compares the boolean value of the current object with the boolean value of other. This is a non-mutating operation.
- Parameters
-
- Returns
true if the current object's value is less than or equal to other's value, false otherwise.
◆ operator=() [1/3]
Overloaded assignment operator for a boolean value.
Assigns a new boolean value to the underlying shared boolean, modifying the object in place.
- Parameters
-
| other | The boolean value to assign. |
- Returns
- A reference to the current object (
*this) to allow for chained assignments.
◆ operator=() [2/3]
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 boolean value managed by other.
- Parameters
-
- Returns
- A reference to the current object (
*this) to allow for chained assignments.
◆ operator=() [3/3]
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.
- Parameters
-
- Returns
- A reference to the current object (
*this).
◆ operator==() [1/2]
Overloads the equality operator (==) for a boolean value.
Compares the boolean value of the current object with a bool for equality. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the values are equal, false otherwise.
◆ operator==() [2/2]
Overloads the equality operator (==).
Compares the boolean value of the current object with the boolean value of other for equality. This is a non-mutating operation.
- Parameters
-
- Returns
true if the values are equal, false otherwise.
◆ operator>() [1/2]
Overloads the greater-than operator (>) for a boolean value.
Compares the boolean value of the current object with a bool. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the current object's value is greater than other, false otherwise.
◆ operator>() [2/2]
Overloads the greater-than operator (>).
Compares the boolean value of the current object with the boolean value of other. This is a non-mutating operation.
- Parameters
-
- Returns
true if the current object's value is greater than other's value, false otherwise.
◆ operator>=() [1/2]
Overloads the greater-than-or-equal-to operator (>=) for a boolean.
Compares the boolean value of the current object with a bool. This is a non-mutating operation.
- Parameters
-
| other | The boolean value to compare against. |
- Returns
true if the current object's value is greater than or equal to other, false otherwise.
◆ operator>=() [2/2]
Overloads the greater-than-or-equal-to operator (>=).
Compares the boolean value of the current object with the boolean value of other. This is a non-mutating operation.
- Parameters
-
- Returns
true if the current object's value is greater than or equal to other's value, false otherwise.
◆ set()
Sets the boolean value of the object.
Assigns a new boolean value to the underlying shared boolean.
- Parameters
-
| val | The boolean value to set. |
◆ operator<<
Overloads the stream insertion operator (<<) for SharedBoolean.
Provides a way to print the boolean value of a SharedBoolean object to an output stream.
- Parameters
-
| os | The output stream to write to. |
| sp | The SharedBoolean object to print. |
- Returns
- A reference to the output stream, allowing for chained insertions.
The documentation for this class was generated from the following file: