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

Fix mismatching allocator types #140

Closed
wants to merge 1 commit into from

Conversation

xezon
Copy link
Contributor

@xezon xezon commented Dec 23, 2017

New master branch does not compile on MSVC c++17

The allocator types are mismatching. I fixed all errors I could find, but there might be more, as I might not have all templates in my compile unit. I suggest to pass allocators as templated templates. Then it is easier to use them for various types.

@danielaparker
Copy link
Owner

danielaparker commented Dec 24, 2017

Thanks for raising this issue.

Following boost and other examples, however, the template parameter should be just class Allocator = std::allocator<ValueType> rather than template<class U> class Allocator = std::allocator. When we use the allocator with multiple value types, we are supposed to rebind the allocator as needed for every allocation, so the initial ValueType of the allocator isn't important. We generally use CharT, could even use void, except not all compilers support std::allocator<void>.

I've changed the code to rebind the Allocator template parameter to the value_type for the standard library containers wherever they appear in the code.

Having an allocator template parameter for each value type would, I think, be impractical. There are too many - we have char_allocator_type, string_allocator_type, csv_mode_allocator_type, csv_type_info_allocator_type, and string_vector_allocator_type in basic_csv_parameters alone. Besides, using a vector of csv_type_info, say, is an internal detail that could change, so we don't want to expose that to the user.

@xezon
Copy link
Contributor Author

xezon commented Dec 24, 2017 via email

@danielaparker
Copy link
Owner

I'll be grateful for feedback, as the compilers I'm using don't give me any diagnostics for the mismatch, so I could easily have missed one or two.

Thanks,
Daniel

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