« first day (325 days earlier)      last day (4609 days later) » 

12:00 AM
I define that as equivalent to 'a pair of iterators', with each being as powerful as each other.
 
yeah
except then I came to write a function that required a pair of iterators plus a std::set to represent it's range correctly
 
Mapping some kinds of non-container related range to container ranges can be unfun to code yeah.
 
that's not necessarily what I meant
imagine that you are writing a function that will return a pair of iterators to only the distinct elements of a container
 
kay
 
how are you going to implement the iterators? they need to share a set defining what's already been found
the two iterators can't exist independently, because it's in the contract of the return value that you can never reach any two equal values
 
12:04 AM
The real unfortunate thing is that it's only hard to write such iterators because they're required to have copy semantics.
 
so, e.g., if you incremented the begin iterator, you could then go and decrement the end iterator
 
@DeadMG That's if you want the distinct elements and bidirectionality.
 
so in this case, the "distinct" range really needs to be a begin iterator, an end iterator, and a set defining the values you already found
 
@DeadMG Half the time my iterators are the result of find or insert, or arguments of erase, so I'm not sure that iterators "always occur in pairs"...
 
sure, why shouldn't you have bidirectionality?
 
12:06 AM
How useful is it?
 
honestly, I don't really know, I don't usually deal in such areas
 
lol
 
but at a fundamental level, you're telling me that I can't implement something because the abstraction won't support it
that's bad.
 
I don't think your conclusion is correct.
Why is 'the two iterators can't exist independently' a problem anyway?
 
because you could, for example, copy the begin iterator but not the end iterator, and legally increment from the copy to get to the end
 
12:09 AM
Yeah.
 
more importantly, each begin iterator needs to know it's end iterator, so it can maintain the state of what's been incremented
but the current iterator model is that any iterator is as good as any other iterator
 
That's sufficient but not necessary.
It's also sufficient for each iterator to share a state.
 
Can anyone here vote to re-open a question?
-1
Q: Are unused classes compiled by Xcode when building an app?

Ani J WillisIf something is not used in C++, it's not compiled at all. Is the same true for iPhone? If I compile a program and there are unused classes or other stuff, will it be compiled or ignored?

 
sure
and where are you going to put that state? on the heap?
now you're draining my cache, wasting my resources, because the abstraction is leaky
 
There's more than one way to do it.
Last time I did it the container had that state.
Got away with it because the iterators are InputIterators.
 
12:11 AM
intrusive? that's not really acceptable
apart from anything else
 
Looks like an intense conversation here, way above my head.
 
how am I going to maintain more than one pair of iterators at once with one state in the container?
 
I'm not much of a C++ dev yet.
 
and how am I going to implement the iterators for pre-existing containers that I don't control?
 
@DeadMG InputIterators
 
12:12 AM
but a distinct range is not input at all
it's bi-directional, if not random access
 
I gave you an example.
Aw fuck.
You have the elements, piece them together.
 
drawing a blank here
 
9 mins ago, by Luc Danton
The real unfortunate thing is that it's only hard to write such iterators because they're required to have copy semantics.
3 mins ago, by Luc Danton
There's more than one way to do it.
 
so you're suggesting that I forbid copying my iterators?
 
And those ways depend on what requirements you put on the kind of iterators.
 
12:15 AM
that's insane
 
@DeadMG I don't see how you can reach that (flippant) conclusion.
 
well I don't see what other conclusion you're expecting me to draw
 
How a lot of the hardships in writing iterators are inherent to the problem of iterating, and how what iterators do under the covers are intimately tied to the underlying container or sequence or kind of iteration; and how that conflicts with the usual view that C++ iterators should be lightweight.
Iterators are designed to be simple to use in generic situations, not simple to write.
 
the implementation of iterators is an implementation detail, and their coupling to a given implementation doesn't bother me
nor does the idea that some iterators might not be lightweight- iterators do a job, and if their job is heavy, then they're heavy
 
@DeadMG But you're complaining about just that, particularly regarding your example.
 
12:19 AM
no
I'm not complaining at all that what I want is coupled
 
i.e. when you need a range + something else, that's because you're writing an iterator.
 
it's coupled up the arse and that's fine by me
I'm complaining that what I want is impossible.
 
It's not.
 
it is
 
It's not as easy as you want to be but it's not. Poorly worded
 
12:21 AM
Hi all!
 
The end result might not look as easy or convenient to use as you'd like.
 
no, that's not the same thing
the end result must be as easy or convenient as the underlying concepts dictate
 
I'm almost finished drafting my super-compliant C++11 preprocessor.
 
Yes; one can't write a range_type make_distinct_view(Range); and not use heap allocation.
 
it's unacceptable for an iterating abstraction to enforce run-time overhead
 
12:22 AM
But I don't see how to format local time in a thread-safe, standard way.
 
@DeadMG What abstraction would that be?
 
above what the underlying implementation requires, anyway
 
Is this just missing from the C++ standard?
 
the one that says "A range is a pair of iterators"
 
You can implement a make_distinct_view that doesn't use heap allocation.
 
12:24 AM
@DeadMG: Do you intend for your "range" to be able to express arbitrary subcollections of a container?
 
apart from the inherent heap allocation required in maintaining some form of maintaining known values
 
It won't look like range_type make_distinct_view(Range); but that's not related to what iterators are required to do.
 
which is a fundamental requirement of the concept and I don't mind it at all
 
Mmh, I'm not sure what we're saying.
 
ok
 
12:25 AM
When you say heap allocation, do you mean the shared state or the distinct elements to keep track of?
 
the shared state between the iterators
if I had
 
Well
range make_distinct_view(Range, Set&);
 
struct range { iterator begin, end; set values; };
I'd still need heap allocation for the set
 
Client-code does some_set_type set; auto range = make_distinct_view(my_range, set);
Perhaps more generic looking
 
no
because I want my function to be compatible with functions that take a pair of iterators as a "range"
 
12:27 AM
distinct_range make_distinct_view(input_range, output_range_to_store_elements);
Won't really work because you can't read back the output iterator to find what's been iterator over already but yeah.
 
and more generally, conform with the usual requirements of iterator
 
@DeadMG In what way do my proposed versions not satisfy that?
 
how are you going to pass an object of distinct_range as a pair of iterators?
distinct_range is one object. a pair of iterators is two objects.
 
lol
auto range = make_distinct_view(...); std::transform(range.first, range.second, ...);
 
right
 
12:29 AM
or use those Boost.Range algorithms that work on ranges or whatnot
 
so if I put range.first and range.second into some vectors, and mishmash them around with a bunch of other iterators basically randomly, that'll work fine, too?
because any first iterator can work with any second iterator
 
Not true. Only true if they're associated with the same view.
 
that's completely true
it's in the requirements
 
Can't compare two std::vector<int>::iterator of two different vectors.
 
no, but you can create the begin iterator n-times
and the end iterator n-times
 
12:31 AM
Interesting.
 
and then randomly permute them repeatedly
and then iterate from any one of the original begin to any one of the original end
 
auto range1 = make_distinct_view(...); auto range2 = make_distinct_view(...); would create two different views.
 
or partially iterate some of them, and then go back and iterate some more on a different arbitrary pairing, and then go back to the first one
 
However, auto copy = range; is a simple way to obtain two ranges to the same view.
 
yeah
 
12:33 AM
So I'm not sure which is relevant here?
 
except I don't have the luxury of having that allowed by the normal iterator requirements
 
All iterators kinds are required to be CopyConstructible anyway?
 
because I could, say, do something like
 
What's the problem again?
 
insert the iterators from the same range into a vector
repeatedly
and then iterate them independently
 
12:35 AM
You do realize that all of the iterator kinds require that to work by definition?
 
yeah
that's my point
 
Except output, but doesn't apply here.
But
 
but your code won't, because they all share a view behind the scenes
 
I already told you can implement you range without needing heap allocation.
@DeadMG Share as in level of indirection, not as in own though.
 
how? you can only guarantee to have one view object for any number of independent iterations
in fact, I believe that legally, they could even be concurrent iterations
 
12:37 AM
@DeadMG Lolno.
 
they're independent iterators and can be iterated independently
 
None of the iterator concepts say anything on thread safety.
 
the Standard bans sharing state except where explicitly allowed
it's part of the CoW-banning stuff
 
@DeadMG range_type make_distinct_view(input_range, magic_set_to_put_elements_in&);
 
except I can't make people call that function
 
12:38 AM
Utter nonsense, all of it.
There's no such requirement on user-code.
@DeadMG Why?
 
because all the functions which take (iterator, iterator) that were already written don't do so
 
err
std::for_each take two iterators and a functor
std::transform can take three iterators and a functor
std::accumulate can take three iterators, one value and one functor
 
yeah, I'm really not fussed about the other arguments
 
@LucDanton iterators are all required to be CopyConstructible, and the standard library almost always passes them by value. However, you can also define a reference-to-noncopyable-iterator class, which is an iterator. This works well.
0
Q: C++11 alternative to localtime_r

PotatoswatterC++ defines time formatting functions in terms of strftime, which requires a struct tm "broken-down time" record. However, the C and C++03 languages define no thread-safe way to obtain such a record; there is just one master struct tm for the whole program. In C++03 this was more or less OK beca...

 
What's stupid about taking other things beside the range to operate on?
 
12:40 AM
nothing, I just have nothing to guarantee it
 
@Potatoswatter Why quote me and that message?
 
what about std::sort without a custom predicate?
I admit that sorting distinct values might be of dubious value, but it's just an example
 
I just came back and scanned the history, felt like replying. Maybe it's relevant.
If you want noncopyable iterators, reference wrappers are a solution.
 
@DeadMG What about it?
 
@LucDanton Well, it doesn't take anything else that I might hide the state in, and it will most assuredly not call any state-duplicating function
 
12:43 AM
As opposed to what?
 
what?
 
I still don't see a problem, I really don't get it.
 
well, how the hell am I going to conform to the iterator requirements when I need extra state that can't go in the iterators?
 
make_distinct_view without heap allocation is trivial to write and the resulting iterators are cheap to copy, simple to use. Perhaps that's not the best example.
 
it is
but I can't make people call it
 
12:46 AM
That's like complaining you can't write an iterator for a random-access sequence without writing std::vector.
 
because their code isn't written to deal with it
 
@DeadMG What people?
What code?
 
anyone who ever wrote a generic algorithm that took a pair of iterators as a range
 
Yeah, you don't pass make_distinct_view; the client code call it and pass the iterators.
How is that related to iterator concepts?
 
if the client code is aware of make_distinct_view
what if I have client code that makes an undefined number of copies of my iterators and iterates through them concurrently?
an excellent example is the parallel sort algorithm in the PPL, and I believe that TBB offers one too
 
12:48 AM
Better make a thread-safe version of it?
 
how? I can't make them even call it
I can't make a function thread safe when it's never called
 
Call what?
 
make_distinct_view
 
Can you please read what you say?
You bring up one issue.
 
no, it's always the same issue
 
12:49 AM
Then you say 'plus it's unusable anyway so we can't get to that'.
Only one issue at a time?
 
it's always the same issue
the issue is that I cannot depend on client code that is capable of calling my custom function to deal with extra state for ranges
 
Then stick to it.
 
and therefore have nowhere to put that extra state
 
Don't bring concurrency on the table.
 
that's unacceptable
 
12:50 AM
Righto.
 
if "pairs of iterators" as ranges didn't leak, I would have a perfectly good concurrent system
hence, you're telling me that I'm limiting what my code can do because "pairs of iterators" as ranges leaks
which reinforces my original point- that "pairs of iterators" as ranges suck
 
30 mins ago, by Luc Danton
The end result might not look as easy or convenient to use as you'd like.
 
inconvenient != limiting functionality
 
It's not a problem IMO for make_distinct_view but that may be due to the nature of that example: this particular functionality will not ever be called by client code that didn't explicitly needed it (and thus will be written to accomodate that interface).
@DeadMG Ranges don't leak -- ranges are not the concept to use for what you're attempting.
 
they're generic algorithms, it's their job to accept whatever I give them
 
12:54 AM
Not true.
 
it is completely true
 
Algorithms put requirements on what you can use with them.
 
the purpose of a range is to say "I'm gonna go from A to B."
anything else is my problem
and the purpose of an algorithm is to do something with A, all the values in the middle, and B.
my distinct range fits that necessity perfectly well
 
Look
ret whatever_silly_algorithm_takes_a_range_transformation_as_input(transform);
magic_set set; whatever_silly_algorithm_takes_a_range_transformation_as_input([&set](input_rang‌​e i) { return make_distinct_view(i, set); });
How is that for genericity?
 
still not seeing how I'm going to convince parallel_sort to work with that
 
12:59 AM
parallel_sort takes a range, not a range transform.
So pass the result of calling make_distinct_view.
 
except it needs N distinct views
where N is non-determinstic
 
Don't you mean its implementation?
 
what do you mean?
 
Can't find a reference for parallel_sort
 
it's basically quicksort, except the two recursions happen concurrently
afaik, it's in one of the sample packs and the MSDN documentation for them basically doesn't exist
which is less helpful than it could be
 
1:03 AM
template<typename RandomAccessIterator>
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end);

template<typename RandomAccessIterator, typename Compare>
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end,
const Compare& comp );
For TBB
Only one range there. It's a sort.
 
you only pass in one range
they make multiple copies of the subranges to iterate over concurrently
 
i'm new to iterators, and have one question...
deque<int> d(5);
for(int i=0; i<5; i++) cin >> d[i];

for(int *p=&d[0]; p<&d[5]; p++) cout << *p; // This is incorrect ?
for(deque<int>::iterator it=d.begin(); it<d.end(); it++) cout << *it; // This is correct?

Because, never use pointers arithmetic on container which elements are not in order one-by-one in memory? iterator don't have problems with that ?
 
iterators have a pointer interface, but they're not pointers, they can have any implementation
so indeed, the second is correct and the first is most definitely not
 
deque doesn't make the contiguous guarantee that you need to use pointers like that.
@DeadMG It may be silly to have a concurrecnt::make_distinct_view but if you so desire you can and it may work with parallel_sort (although I am not familiar with the exact requirements it puts on ranges)
 
sure, but I still can't make parallel_sort call it
it's just going to copy the iterators and not tell me about it
 
1:07 AM
so with any container which elements are not in order one-by-one, always to use iterators in situation like this ?
 
Yeah.
Not a problem.
Well, not a semantical problem.
 
@Srle Any container that is not explicitly defined to store contiguous elements. That is, for Standard containers, any container that is not vector
 
@Srle Why not always use iterators for containers?
 
well if i can use pointer i will
if i can't i will user iterators
 
why? it's a horrendous mess
iterators are much better
 
1:10 AM
than i will use always iterators
:D
 
Can you do &*container.end() anyway? How do you get the final pointer?
Use indices or use iterators for random-access but pointers seems they're more roundabout.
 
well
I am in desperate need of sleep
good night
 
@DeadMG I'm trying hard to tie the situation with just iterators but arguably it's hard than that; how about a generic make_subsequence<Range>()(range)
 
same problem: if I could make parallel_sort do anything other than call the iterator operator=, I wouldn't have the problem in the first place
 
1:14 AM
Still, it feels more like missing functionality rather than an underlying problem with the concepts behind iterators.
 
if the range was a single object, then the view could just go in the object and the problem would be instantaneously solved
 
Well, not exactly: you still need functionality to create a subrange from a range, don't you?
 
true
 
Given range r;, how do I make a partition?
 
but the important point is that anything I need to be done can be done
 
1:17 AM
But yeah, I tend to agree that ranges feel nicer than iterators in general.
I really hope that QoI for variadic templates, SFINAE and the like rises enough that we advance further with generic code.
 
if you ask me, a significant fault lies with the language
 
The difference between old-timey std::bind1st and modern Boost.Phoenix is staggering.
@DeadMG Tons of faults lie with the language :)
 
mainly, how incredibly goddamn bitchy it is whenever you do anything except explain to the compiler incredibly slowly and in very strange orders what you want
 
it's the greatest esoteric language ever :)
 
I'd rather have good implementations than a new language (else I wouldn't be using C++ right now).
 
1:20 AM
true
until I finish DeadMG++, there's nothing better to be using, really
right
remember that "sleep" thing I mentioned?
 
 
1 hour later…
2:36 AM
bah, I have to pretty much redo the recursion prevention in this preprocessor macro engine…
 
 
3 hours later…
5:33 AM
lol… I guess now we know what C++ celebrities do on Labor Day
The last 2 C++11 questions were answered by Howard Hinnant and Chris Lattner
 
 
3 hours later…
8:21 AM
1
Q: Variant implementation like boost::any with auto-conversion support

cytrinoxI want to implement a variant class that can store any datatype (like boost::any) but with the support of datatype conversion. For example, Variant v1(int(23)); can be converted to bool via v1.get<bool>() using Converter<int, bool>, Variant v2(CustomT1()); to CustomT2 via Converter&...

 
9:10 AM
Hello.
 
I think I'm going to need a std::map with nodes from an intrusive list as values. Does this sound insane? I'm pretty sure I'm micro-optimizing, but I can't seem to stop it now.
 
Why would it be insane?
 
I keep thinking there's got to be an existing solution.
 
Ah -- well I'm not sure what is the problem to be solved so hard to tell.
FWIW I tend to use containers with e.g. iterators from another container as 'shallow views' of data.
Seems what you're doing is in the same spirit.
 
9:17 AM
It's an MRU cache. I need quick access by key, and when accessed, an element pops to the front. When a new element is added, the element in the back is dropped.
 
Ah, so the list maintains the order of use?
 
@RMartinhoFernandes it's not micro-optimizing until you've reduced every one of your data structures to an array or vector. ;)
 
Can't tell without knowing the interface of the intrusive list but perhaps you can use a map of pointers to the object, if that makes you feel better.
 
The intrusive list is pretty much like a std::list, but the next/prev pointers are stored in the elements themselves.
 
9:41 AM
Has anyone ever used the Boost Concept Check Library to verify template argument constraints on template parameters, and create more readable error messages when they occur?
 
Yes. I'd use it more if I it had up-to-date C++11 concepts :(
Granted, I could easily write them myself, but... lazy.
 
cool! an c++ chat!
 
@TonyTheTiger I played around with it a little bit once, but didn't really seem to be worth the trouble
 
boost friends here?
 
9:48 AM
I don't think you will boost your social skills by hanging around in a C++ chat room.
 
@kbok Maybe you're overestimating someone's social skills.
:P
 
your right, ill go
 
oh ok
 
You don't mean "go away", do you? No one told you to go away!
 
@PeterRader Just kidding, it was a bad pun with "boost". And to answer your question, I think nearly everyone here uses it.
@RMartinhoFernandes What ?
 
9:50 AM
@kbok If you have very very low social skills, you might boost them here ;)
> Sounds like quite a heavy class. I prefer the single-cwt class personally - it's a bit lighter. – Chris J 8 mins ago
 
@RMartinhoFernandes Ah, right. Although I think the Video Games room would be a better bet.
 
Well, he really is gone.
WTF.
 
Some people.
Hey, this is my last week of doing Java. Celebrate !
 
What is next after that?
 
COBOL.
 
9:56 AM
XSLT!
 
Visual Basic.
 
>_<
Seriously?
 
No, really, after that I'll have my first job (I'm currently doing an internship.) This is a C++ position in the finance industry.
 
@TonyTheTiger Yes.
 
To me, XSLT is really what I have to do next :(
 

« first day (325 days earlier)      last day (4609 days later) »