Skip to content

Make string_ref understand allocators #3

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 3 commits into from

Conversation

deanberris
Copy link
Member

No description provided.

@glynos
Copy link
Member

glynos commented Jan 22, 2013

I can't merge these commits as the first one is part of another pull request and requires changes (see #2 )

I see nothing wrong with what you've added re the allocators, but at the moment I can't build it.

@deanberris
Copy link
Member Author

Interesting. I prefer really not having these macros sprinkled in the code. I'm disappointed that Microsoft is taking its time in getting C++11 in the hands of more people. I'm already at odds with the way the URI implementation has these macros all over the place but I understand it is a necessary evil at this time.

Do you prefer a header where the NETWORK_* macros should be defined?

@glynos
Copy link
Member

glynos commented Jan 28, 2013

I much prefer not to have these macros all over the place too, and I make a point of limiting them to only those places where they're required (i.e. when I can't get the same code to compile on each platform I test on).

In order to allow the uri project to be standalone, unfortunately I see no option but to duplicate them.

So in:

uri/src/network/uri/config.hpp

and use the macro prefix: NETWORK_URI_

and in the main project, I would propose:

config/src/network/config.hpp

and use the macro prefix NETWORK_

@glynos
Copy link
Member

glynos commented Jan 29, 2013

I applied this by cherry-picking the commit with the allocator code. Verified that it compiles and unit tests run:

e3ed456

@glynos glynos closed this Jan 29, 2013
@glynos
Copy link
Member

glynos commented Jan 31, 2013

Dean,

I know I merged this a couple of days ago but on reflection, I have a question.

What are the allocators for? With string_ref there is no allocation, by definition. I double checked Jeffrey Yassin's string_ref proposal and indeed, he makes no reference to allocators in the definition of the template class string_ref.

@deanberris
Copy link
Member Author

Right, so actually I was only supposed to do the template part in the conversion operator -- it should be able to deduce the type of the allocator for the string. I'm not entirely sure whether Jeffrey's paper does the magic that way, but nonetheless the idea was:

template <class Allocator>
explicit operator basic_string<CharT, CharTraits, AllocL> () const {
  return basic_string<CharT, CharTraits, AllocL>(start, end);
}

It might still work without the allocator though, you might want to give it a shot. I forget why I had chosen to add the allocator to the type in the string_ref implementation.

@deanberris deanberris deleted the master-integration branch January 31, 2013 09:29
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