Skip to content

Commit 0c7d96d

Browse files
authored
Update core header files to support C++17 as well (NVIDIA#27)
Signed-off-by: Ben Howe <[email protected]>
1 parent 6ea31be commit 0c7d96d

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

libs/core/include/cuda-qx/core/extension_point.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <functional>
1212
#include <memory>
13+
#include <stdexcept>
1314
#include <unordered_map>
1415

1516
namespace cudaqx {

libs/core/include/cuda-qx/core/heterogeneous_map.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,16 @@ class heterogeneous_map {
104104
// we have a value of type int, but request here is std::size_t.
105105
// Handle that case, by getting T's map of related types, and checking
106106
// if any of them are valid.
107-
using RelatedTypes =
108-
typename RelatedTypesMap<std::remove_cvref_t<T>>::types;
107+
using RelatedTypes = typename RelatedTypesMap<
108+
std::remove_cv_t<std::remove_reference_t<T>>>::types;
109109
std::optional<T> opt;
110110
cudaqx::tuple_for_each(RelatedTypes(), [&](auto &&el) {
111111
if (!opt.has_value() &&
112-
isCastable<std::remove_cvref_t<decltype(el)>>(iter->second))
113-
opt = std::any_cast<std::remove_cvref_t<decltype(el)>>(iter->second);
112+
isCastable<std::remove_cv_t<std::remove_reference_t<decltype(el)>>>(
113+
iter->second))
114+
opt = std::any_cast<
115+
std::remove_cv_t<std::remove_reference_t<decltype(el)>>>(
116+
iter->second);
114117
});
115118

116119
if (opt.has_value())
@@ -185,10 +188,12 @@ class heterogeneous_map {
185188
/// @brief Check if the map contains a key
186189
/// @param key The key to check
187190
/// @return true if the key exists, false otherwise
188-
bool contains(const std::string &key) const { return items.contains(key); }
191+
bool contains(const std::string &key) const {
192+
return items.find(key) != items.end();
193+
}
189194
bool contains(const std::vector<std::string> &keys) const {
190195
for (auto &key : keys)
191-
if (items.contains(key))
196+
if (items.find(key) != items.end())
192197
return true;
193198

194199
return false;

libs/core/include/cuda-qx/core/tensor.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
namespace cudaqx {
1515

16-
/// @brief A tensor class implementing the PIMPL idiom.
16+
/// @brief A tensor class implementing the PIMPL idiom. The flattened data is
17+
/// stored where the strides grow from right to left (similar to a
18+
/// multi-dimensional C array).
1719
template <typename Scalar = std::complex<double>>
1820
class tensor {
1921
private:
@@ -35,7 +37,7 @@ class tensor {
3537

3638
public:
3739
/// @brief Type alias for the scalar type used in the tensor
38-
using scalar_type = details::tensor_impl<Scalar>::scalar_type;
40+
using scalar_type = typename details::tensor_impl<Scalar>::scalar_type;
3941
static constexpr auto ScalarAsString = type_to_string<Scalar>();
4042

4143
/// @brief Construct an empty tensor
@@ -54,7 +56,7 @@ class tensor {
5456
.release())) {}
5557

5658
/// @brief Construct a tensor with the given data and shape
57-
/// @param data Pointer to the tensor data
59+
/// @param data Pointer to the tensor data. This takes ownership of the data.
5860
/// @param shape The shape of the tensor
5961
tensor(const scalar_type *data, const std::vector<std::size_t> &shape)
6062
: pimpl(std::shared_ptr<details::tensor_impl<Scalar>>(

0 commit comments

Comments
 (0)