Skip to content

How do I represent data of undeterminate size? #299

Answered by epezent
Riser777 asked this question in Q&A
Discussion options

You must be logged in to vote

Unless I'm misunderstanding your problem, you can just pass a pointer to the underlying data of your std::vector like so:

std::vector xs = ...;
std::vector ys = ...;
...
if (ImPlot::BeginPlot("My Plot")) {
    ImPlot::PlotLine("My Line", xs.data(), ys.data(), xs.size()); // assuming xs and ys are same size!
    ImPlot::EndPlot();
}

Generally speaking, this is quite typical when a function calls for a T* and your data is contained in a std::vector<T> (or evenstd::array).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Riser777
Comment options

Answer selected by Riser777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants