Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions targettests/execution/vector-1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2022 - 2025 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/

// Test for std::vector support

// RUN: nvq++ %cpp_std %s -o %t && %t | FileCheck %s

#include <cstdio>
#include <cudaq.h>

struct vector3 {
bool operator()(std::vector<double> theta) __qpu__ {
return theta.size() == 3;
}
};

struct vector5 {
bool operator()(std::vector<double> theta) __qpu__ {
return theta.size() == 5;
}
};

struct vectorPow2a {
bool operator()(std::vector<double> init) __qpu__ {
cudaq::qvector q(init);
return true;
}
};

struct vectorPow2b {
bool operator()(std::vector<double> init) __qpu__ {
cudaq::qvector q(init);
return true;
}
};

int main() {
bool b = true;
std::vector<double> v = {1.0, 2.0, 3.0};
b &= vector3{}(v);
v.push_back(4.0);
v.push_back(5.0);
b &= vector5{}(v);
v.pop_back();
b &= vectorPow2a{}(v);
std::vector<double> w{v};
v.insert(v.end(), w.begin(), w.end());
w.clear();
b &= vectorPow2b{}(v);
if (b)
printf("success\n");
return b ? 0 : ~0;
}

// CHECK: success
2 changes: 1 addition & 1 deletion test/AST-Quake/vector.cpp → test/AST-Quake/vector-0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// Test for std::vector support

// RUN: cudaq-quake %cpp_std %s | FileCheck %s
// RUN: cudaq-quake %cpp_std %s | FileCheck %s

#include <cudaq.h>
#include <cudaq/algorithm.h>
Expand Down
Loading