Bug leads to crash program when using .set<T>() and then apply_visitor()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Compile and run the C++ reproducer from the issue, then inspect the implementations of set() and apply_visitor(). Done means the example completes without crashing and the visitor handles the stored string and float values.
Written by the indexing model from the issue text.
Description
#include
#include <mapbox/variant.hpp>
#include <unordered_map>
using namespace std;
using namespace mapbox::util;
// Forward declaration
struct HPArray;
struct HPTable;
using HPVariant = variant<string,float,recursive_wrapper>;
struct HPArray{
template <typename ...Args>
HPArray(Args ...args){
values.emplace(std::forward(args)...);
}
unordered_map<int,HPVariant> values;
};
struct Visitor{
void operator()(const string &str){
cout << str <<endl;;
}
void operator()(const float &value){
cout << value <<endl;
}
void operator()(HPArray array){
for (size_t i = 0; i < array.values.size(); i++)
{
apply_visitor(*this,array.values[i]);
}
}
};
int main()
{
HPArray ar;
ar.values[0] = HPVariant("String");
ar.values[1] = 2.0f;
HPVariant var;
var.set<HPArray>(ar);
Visitor visitor;
apply_visitor(visitor,var);
return 0;
}
- Dominant language
- C++
- Stars
- 384
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/variant
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·