Add C++ support#94
Merged
Merged
Conversation
To be portable across C and C++ cvector needs only a couple of changes where C++ needs explicit casts. A macro cvector_typeof is made to cast in C++ and do nothing in C and it is applied in needed places
Owner
|
Oh geez, I was very much over thinking this! You're right that we can just use macros to do different work in C++ than C! I do think that maybe we can get away with not needing type traits though! I bet we can use C++ type of on vec[0] and cast to a pointer to that type. Might be better? |
std::remove_reference can be replaced with just taking an address of the first element
Contributor
Author
|
Yes you're right there, I was thinking of removing reference on the surface and this can indeed be done easier |
Owner
|
Nice, I'll want to double check but conceptually this looks good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've seen that #70 had some discussion recently and this is my solution. clang++ compiles
test.cas well asexample.csuccessfully.unit-tests.cfails to compile but because of itself, not the library, and since this is a C library I don't see reasons to run tests with a C++ compiler and therefore didn't touch the file.To be portable across C and C++ cvector needs only a couple of changes where C++ needs explicit casts. A macro cvector_typeof is made to cast in C++ and do nothing in C and it is applied in needed places