Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use reference or pointer binding values? #1482

Closed
3038922 opened this issue Feb 14, 2019 · 0 comments
Closed

How do I use reference or pointer binding values? #1482

3038922 opened this issue Feb 14, 2019 · 0 comments

Comments

@3038922
Copy link

3038922 commented Feb 14, 2019

json data{
    "chassis": {
        "motor": {
            "left": {
                "prot": 1,
                "isRevase": false,
                "gear": 1
            },
            "right": {
                "prot": 2,
                "isRevase": true,
                "gear": 1
            },
        },
}
static void action(void * ptr)
{
  // if jsonType is bool flaot? How to Realize Automatic Judgment?
   long *p=static_cast<long*>(ptr);
   *p=100;
   std::cout<< json data["chassis"]["motor"]["left"]["prot"]<<std::endl; //output 100

 //I want to be able to pass the value pointer directly, without restricting the type.
  json::autoType p=static_cast<json::autoType *>(ptr);
 *p=100;
   std::cout<< json data["chassis"]["motor"]["left"]["prot"]<<std::endl; //output 100
}
void test
{

  long*a =data["chassis"]["motor"]["left"]["prot"].get_ptr<long *>();
  action((void*)a);
 //I want to be able to pass the value pointer directly, without restricting the type.
  auto *a=&data["chassis"]["motor"]["left"]["prot"];  
  action((void*)a);
 // //I want to change JSON by a reference
}
@3038922 3038922 closed this as completed Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant