Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/NVIDIA/thrust.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schellenberger Costa <miscco@nvidia.com>2022-10-10 12:13:30 +0300
committerMichael Schellenberger Costa <miscco@nvidia.com>2022-10-10 12:13:30 +0300
commit227a9fb7f3899468468e763c85429730f58e651b (patch)
tree8a27c7f607c636a1e35bcb4c9bbfc714bab19023
parent8189ed487a67a7c5f7ef21727b56a04949b039da (diff)
Fix `optional::emplace`
Currently we cannot use `optional::value` on device, as that might throw if there is no value stored. However, in `emplace` we know that there must be a value stored, as we have just created it. Consequently, just return `this->_m_value`
-rw-r--r--thrust/optional.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/thrust/optional.h b/thrust/optional.h
index 52008e4f..5850b6ea 100644
--- a/thrust/optional.h
+++ b/thrust/optional.h
@@ -1580,7 +1580,7 @@ public:
*this = nullopt;
this->construct(std::forward<Args>(args)...);
- return value();
+ return this->m_value;
}
/// \group emplace
@@ -1594,7 +1594,7 @@ public:
emplace(std::initializer_list<U> il, Args &&... args) {
*this = nullopt;
this->construct(il, std::forward<Args>(args)...);
- return value();
+ return this->m_value;
}
/// Swaps this optional with the other.