Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix any istype #708

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

Closed
wants to merge 5 commits into from
Closed

Fix any istype #708

wants to merge 5 commits into from

Conversation

galou
Copy link
Contributor

@galou galou commented Dec 5, 2023

No description provided.

Gaël Écorchard added 2 commits December 5, 2023 14:12
Signed-off-by: Gaël Écorchard <[email protected]>
Now compares the original type, not the casted one.

Signed-off-by: Gaël Écorchard <[email protected]>
@facontidavide
Copy link
Collaborator

Motivation?

Signed-off-by: Gaël Écorchard <[email protected]>
@galou
Copy link
Contributor Author

galou commented Dec 5, 2023

I need to convert blackboard entries to my Lua environment. I cannot use tryCast because a lot of things cast to a lot of things. isType<bool>() and similar returned false because of the type casting inside Any (cf. unit-test). The second commit fixes this.

Comment on lines 279 to 281
return type() == typeid(int64_t) ||
type() == typeid(uint64_t) ||
type() == typeid(double);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this. Shouldn't you include all the possible arithmetic types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or use _any.type()?

Now the isNumber function is not called in behaviortree_cpp (isCastedAsNumber is used instead).

Comment on lines 286 to 287
return type() == typeid(int64_t) ||
type() == typeid(uint64_t);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. You should probably add all the integrals

@facontidavide
Copy link
Collaborator

this is still public API, I want to be sure that the behavior of public method is not changed

@galou
Copy link
Contributor Author

galou commented Dec 7, 2023

I did it in a generic way using EnableIntegral.

Also extend `isNumber()` to all number types.

Signed-off-by: Gaël Écorchard <[email protected]>
facontidavide added a commit that referenced this pull request Jan 10, 2024
@facontidavide
Copy link
Collaborator

I don't want to introduce the method isCastedType, therefore I cherry picked the other changes.

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants