« first day (97 days earlier)      last day (4852 days later) » 

sbi
12:24 AM
@JohannesSchaublitb They have a pretty good conference each year in April. Their publications would very likely bore you. (They are good for Joe C++ Programmer, though.) Their website's book review section used to be superb. (I haven't checked in years.)
@FredOverflow This should be an FAQ. With rvalue references coming over us, such questions are going to flood us.
@JohannesSchaublitb It was founded in the UK, but it's open internationally. I once was a member. There used to be some German around whom you could pay your member fee by Überweisung, which was much easier than paying to some UK bank account.
@JohannesSchaublitb What for?
@JohannesSchaublitb Ah, I see.
@peoro The chat is serious, actually. It's us who are silly.
@FredOverflow Nobody forced you.
 
 
1 hour later…
1:34 AM
@DeadMG one whose users ask for optimization and who knows how to pipeline
@JohannesSchaublitb doesn't work in all cases, 'typename' may or may not be required
and if it's not required, it's not allowed in c++03
@DeadMG if only you'd been using vim, you'd have a swapfile with checkpoints of unsaved work :)
 
2:17 AM
@FredNurk it will work in c++0x and most sane c++03 compilers
ah you already mentioned
BTW I find it funny how so many people seem to use T() as an example for "default initialization". Those are currently half-lucky with c++03 because it's somewhat similar to what it actually is. But they will be all-unlucky with c++0x, because default initialization basically means "no initialization" for non-class types in c++0x xD
 
@JohannesSchaublitb it was more idle curiosity anyway: we can't abandon current syntax (especially for those new to the language) and introducing an alternative syntax, even if we could acknowledge it as universally more easily understood, is likely to be overall worse
 
in c++0x i will definitely abandon c++ syntax and write alias<int*> a, b;
 
 
2 hours later…
4:44 AM
1
Q: With the x86 chips, are there any INT instructions other than with 0x80?

jasonbogdI know Linux provide int 0x80 for trapping into a system call but are there any others and what are their uses?

should that be closed?
 
5:07 AM
@JohannesSchaublitb I can never tell if you are being serious anymore, Mr. Standard Thread Library.
Also, in case anyone still wonders why the standard library algorithms often suck: stackoverflow.com/questions/4755288/…
 
5:21 AM
@James: I know, wasn't saying you were doing anything wrong, but tried to give context to the rest of my comment :)
 
I know.
 
though I suppose I see the same situation in other languages
 
It doesn't look much worse than a Lisp function ;-)
 
it is a Lisp function, c++ fulfills greenspun's tenth with templates alone
 
Heh
It's interesting that Visual C++ does not require disambiguation of &std::vector<int>::begin. I'm not quite sure what criteria it uses to select an overload.
Well, it does require disambiguation in some cases, e.g. auto fp = &std::vector<int>::begin.
 
5:37 AM
yeah, there's awkward situations (which I don't fully understand) where the standard doesn't require disambiguation
 
 
2 hours later…
 
2 hours later…
9:20 AM
@JohannesSchaublitb Wouldn't that be alias<int*>::type, assuming alias is a template? Or is alias a new language mechanism I'm not aware of yet?
@JohannesSchaublitb So does int() not mean 0 anymore? :(
@JamesMcNellis It is illegal to take the address of a member function of a standard container :) Let me back that up...
> Please note that it is technically forbidden to take the address of a Standard Library member function. (They can be overloaded, making &foo::bar ambiguous, and they can have additional default arguments, defeating attempts to disambiguate via static_cast.)
(Written by Mr. Lavavej here.)
 
9:53 AM
@FredOverflow alias will be template<typename T> using alias = T;
 
@sbi yeah, didn't doubt about it ;-)
 
10:16 AM
Why this question got downvoted so much?
-23
Q: Invert a stack, without using extra data structures?

vksHow would you invert a stack, without using extra data structures, like a second, or temporary, stack. Thus no stack1-stack2 or stack-queue-stack implementation in the answer. You just have access to push/pop feature of a standard stack. I think there is way to do it by keeping a global counter...

 
Anyone has some insights?
0
Q: Why doesn't my template doesn't accept an initializer list.

Johannes Schaub - litbI have created a template as follows template<typename T> void f(T const& t) { } I wanted for this to be callable by containers but also by initializer lists. I thought it would be initializer_list<int>, when called as follows. f({1, 2, 3}); But GCC behaves as if it's not St...

 
10:41 AM
0
Q: Unfortunate auto-detection of "synonyms" for "initializer{_,-}list".

Johannes Schaub - litbThere is some unfortunate mechanism that merges tags initializer-list and initializer_list. In the new upcoming C++ Standard, these have quite different meanings and usage patterns, and are about different problem domains class IntList { public: // This is a constructor that accepts an // in...

 
 
1 hour later…
12:07 PM
@JohannesSchaublitb does it matter?
(I realize that the tag meaning is overloaded but …)
 
@peoro wow that question was downvoted heavily!
so have to get back to work
cu
 
I know this isn't the room to post and sorry to post it here. Why c exceptions are always unsigned int ?
Is it just because they have to be that way or any valid reason?
 
12:27 PM
@JohannesSchaublitb Well, Wordpress (blog) changes tag C++ to C# very consistently (actually it "generalizes" to pure C, and then renders that as the more specific C#), and IANA I think it was once had the SuperGreat idea of defining ISO-8859-1 as a superset of ISO 8859-1 (note: only difference is a hyphen). Such silliness makes life ... interesting.
Hm, I think I'm going to suggest new standard for traffic lights, only shades of green. Also, all text on the Internet should be red on blue and max 8 point. Plus, a few more gotchas in C++, of course. :-)
 
sbi
@Mahesh C doesn't have exceptions.
 
@sbi Possibly @Mahesh is talking about Structured Exception Handling, SEH, in Windows.
@Mahesh If you're talking about SEH, that mechanism transfers a 32-bit word of no particular type. Microsoft made that almost like HRESULT values in COM, and almost like code in the event log. Differences just to make life interesting (in apropos of @Johannes comment above).
 
sbi
@AlfPSteinbach Possibly. But this wouldn't render my statement invalid.
 
@sbi Course not, you're talking about standard C. Right? ;-)
Listening to good old Satch :-) (Surfing with the Alien, and I'm Alf)
 
12:48 PM
@KonradRudolph imo it does matter as much as the difference of arrays matters to initializer lists
but I think i found a suitable solution for myself
 
@JohannesSchaublitb ?
 
2 hours ago, by Johannes Schaub - litb
0
Q: Unfortunate auto-detection of "synonyms" for "initializer{_,-}list".

Johannes Schaub - litbThere is some unfortunate mechanism that merges tags initializer-list and initializer_list. In the new upcoming C++ Standard, these have quite different meanings and usage patterns, and are about different problem domains class IntList { public: // This is a constructor that accepts an // in...

 
1:22 PM
0
Q: Is the aliasing rule symmetric?

Johannes Schaub - litbHello all. I had a discussion with someone on IRC and this question turned up. We are allowed by the Standard to change an object of type int by a char lvalue. int a; char &b = a; b = 0; Would be be allowed to do this in the opposite direction, if we know that the alignment is fine? The ...

this time i'm really clueless
 
@JohannesSchaublitb Uh char &b = a; is defined behavior with a of type int? That's weird!
 
@peoro Does that mean I can pass an int variable to a function that takes a char by reference? Weird indeed :)
 
GCC doesn't let me: error: invalid initialization of reference of type ‘char&’ from expression of type ‘int’
@FredOverflow I think so... It looks like an error prone syntax for quick unions
 
folks, i fixed
 
1:39 PM
@peoro Wouldn't that also break strict aliasing?
 
sbi
2:03 PM
I've given several answers today with only one or no up-vote at all, and then this idiot comes by and down-votes without leaving a comment why. I'm quite pissed about that.
 
I upvoted you
 
@sbi @AlfPSteinbach So, standard C doesn't have exceptions. It is the windows guys implementing on their own. I was going through msdn on exception handling. So, thought C too has exceptions
 
there's no reason to even bother with C if you can use C++
 
@Mahesh yes. it's complicated by fact that others have also done that, adding exceptions to C as language extension
 
@DeadMG : That is true. But to point out the differences.
 
2:06 PM
well
 
@DeadMG AOL
 
I could also spend my days listing how much better C++ is than FORTRAN or ALGOL or COBOL or BASIC
but I'd rather spend it actually programming in C++ :P
 
GWBasic was cool
even if Bill had a hand in it
 
2:28 PM
@DeadMG Whenever I come to chat, you are here. Are you stocking me??
 
uh
stocking you?
yes, I stock you regularly, you sell well
 
@DeadMG I knew it. lol I was just checking the nominations,
you seem to be quite popular
 
lol#
 
huh, that's the Microsoft .NET lol?
3
 
2:47 PM
I find impressive how sometimes a really, really good answer doesn't get the upvotes/attention it deserves
but I guess that's the reason for which I got the Unsung Hero badge.
For instance, I almost voted to close this question because it was too specific: stackoverflow.com/questions/4751709/…
 
sbi
@AlfPSteinbach It's called Microsoft .NET lol# ("lol-sharp"), actually.
 
3:21 PM
somehow I must be losing my mind
the following code obviously fails:
vector<foo> foos;
foos.push_back(foo(…));
foo& x = foos.back();
foos.pop_back();
use(x); // Boom, `x` no longer valid
 
yes
 
what is the smartest way to make this work in C++03, short of wrapping the third line in an explicit copycon call?
(ah yes, and the reference cannot be removed … that’s actually an argument)
I’m guessing the best way is really to write foo& x = foo(foos.back()), right?
 
uh
what is the smart way to do it, short of the smart way to do it?
you've just created a non-const reference to a temporary, which is undefined
I mean
illegal
you will need to allocate some named holding object
or fix your algorithm so that you're not popping off? This just seems like "How do I pretend that my code isn't bugged".
 
sbi
@KonradRudolph No, you can't bind an rvalue to non-const ref. What's wrong with foo x = foos.back()?
 
@sbi hmm, foobar. My brain is completely wrecked apparently
 
sbi
3:26 PM
It's either value semantics, ref-counting smart pointers, or garbage collection.
 
the reference is a parameter
 
@FredOverflow I didn't believe you (or him). Then I looked it up. Wow. ("Hence, taking the address of a [standard library class] member function has an unspecified type.")
 
@sbi The code looks like this:
(it’s part of a locking queue implementation)
template <typename T>
inline bool
tryPopFront(
    BlockingQueue<T>& me,
    T& value
) {
    SEQAN_CHECKPOINT;
    ScopedGuard _(me._lock);
    if (empty(me._elements))
        return false;
    value = T(front(me._elements));
    popFront(me._elements);
    return true;
}
(and yes, the interface looks totally f*cked up but it makes sense in the context of the library)
 
sbi
@KonradRudolph I used to work in a company where you'd go playing table tennis at this point. Later, they had a pool table instead. Both worked great.
 
damn, do I really need to copy-construct it into the target via placement-new? looks weird :(
 
sbi
3:30 PM
@KonradRudolph I can't see the foo& x = line in that.
 
@sbi fourth to last line, value = T(front(me._elements));
 
sbi
@KonradRudolph You mustn't. That target doesn't need to be a T, obviously.
 
and the T(…) is wrong, too. Temporary and somesuch
@sbi I don’t understand that … the target is very definitely a T (we don’t do subtype polymorphism if you were referring to that)
 
sbi
@KonradRudolph That's different.
 
you might want to look into my RAII abuse
 
3:32 PM
@sbi: yes, it’s different because I just changed it, in premature haste. And yes, it’s wrong because it binds a temp to a non-const ref
 
@Konrad: That's a common queue interface for concurrent queues
 
15
A: C/C++ macro/template blackmagic to generate unique name.

Johannes Schaub - litbI would not do this personally but just come up with unique names. But if you want to do it, one way is to use a combination of if and for: #define FOR_BLOCK(DECL) if(bool _c_ = false) ; else for(DECL;!_c_;_c_=true) You can use it like FOR_BLOCK(GlTranslate t(1.0, 0.0, 0.0)) { FOR_BLOCK(GlT...

 
sbi
foo& x = .. initializes a reference to refer to a specific object. x = ..., however, assigns to that object (without changing the reference).
 
why not just copy?
value = front(me._elements);
 
@DeadMG I want to … the question is, how
 
3:33 PM
the reference must already be bound to an object when it's passed in
 
@DeadMG That won’t copy, that’s the whole problem
 
so you are calling T::operator=(front(me._elements));
 
sbi
@KonradRudolph But it does.
 
hrrrm, I am obviously tired
of course it does
duh
 
lol
 
sbi
3:34 PM
(I'm a bit hindered by a test, supposedly running in the background, taking up 98% CPU time here.)
 
ok, so the segfault is coming from somewhere else … curiouser and curiouser
 
sbi
@KonradRudolph If you're close enough to the ICC, we can meet and have a coffee together. A break always helps. :)
 
@sbi not really close … Prenzlauer Berg … and I’m in the last throes of my master thesis so each break is THE ENEMY ;)
 
sbi
@KonradRudolph Can't you just look at the stack when the app segfaults?
 
@sbi No … multithreading. The stack trace turns up zilch
wait, I take that back
 
sbi
3:37 PM
@KonradRudolph Oh, too bad. (I'll be passing through there tonight.) But it does look like not taking a break now will actually waste your time.
 
So, now that they've removed the ugly, obnoxious "come see the elections" banner, I can't seem to find the elections page :'(
 
sbi
@KonradRudolph What debugger do you have that won't show you the stack of each thread? Or do you have so many threads to make paging through them to painful?
 
is it a bad thing, in general, having two classes referring to each other? class A{ B *b; }; class B{ A *a; };
 
sbi
Also linked from the blog, no doubt.
 
@sbi I’m using gdb and the heavy use of templates coupled with multiple threads is apparently too much
it does show a stack trace but that is definitely wrong
in particular, it’s showing the wrong source locations
 
sbi
3:39 PM
@peoro Actually, that is instances of two classes referring to each other. Of course, that requires the classes to refer to each other, too.
@KonradRudolph Ah yeah. I've had my share of gdb debugging and I prefer VS.
 
@sbi yes, of course, wrote it quickly... Anyway, is it a bad thing, in general?
 
@sbi Actually, gdb rocks. You can define your own macros and all that … you just need to know how to use it (and I don’t). And of course it handles templates extremely poorly
 
sbi
Well, there's always "cout-debugging". Just keep adding messages while doing a binary approximation to the line where it faults.
@KonradRudolph This is 2011. How can a C++ debugger "rock", when it fails at templates??
 
@sbi Ohh. Thanks.
 
@sbi Come on, it’s not as if VS really supports templates well. Auto completion completely fails, for one thing
 
sbi
3:44 PM
@peoro No, it's not bad, in general, although I'd have to be hard-pressed to remember a case where I actually needed that. It means you tightly couple two classes to each other, and tight coupling is always an inferior design to lose coupling.
 
@peoro: It depends on the instances at hand. If A* always points to the same A that points back at the same B, then it's a terrible design
Of course, some "classes" have to be actually split up into more than one class purely for things like lifetime management
 
sbi
@KonradRudolph Yes, VS has its quirks (VAX to the rescue!), but the debugger really rocks. I've done x-platform development for years, and the Mac guys would often ask if the Win guys could reproduce a problem, because debugging in VS was so much more better than XCode (which, AFAIK, uses gdb underneath). The same goes for the Unix guys.
 
Hmmm, I don't know, will need to think about it
 
> but the debugger really rocks
amen to that
Oh, and VS is the best IDE in my opinion … I never used Xcode because I find it horrible …
Ok, I’m going for a walk … @sbi I’ll come back to the offer of a joint coffee break, but after I have handed in this sumbitch of a thesis.
 
sbi
> Wow, I didn't know you could quote here!
 
3:51 PM
(just kidding of course :-P)
 
sbi
@KonradRudolph Yeah, sounds like a good idea. (I rarely ever actually drink coffee, though.)
 
@peoro Yea, I never knew whether that thread was spot-on or just wonky. I rarely use the debugger but when I do I wouldn’t want to miss it. Unit testing is fine but when the test crashes you still need to debug it (which is what I’m doing right now).
@sbi Beer, then ;) Even better
 
 
1 hour later…
5:01 PM
I hate UI code :(
 
5:32 PM
@DeadMG designers exist for this!
 
what, to write the backing classes?
 
sbi
5:46 PM
@DeadMG Yeah. They're called class designer.
 
 
2 hours later…
7:59 PM
0
Q: Why am I getting a Linker error with template function pointer ?

brainydexterI have a class EventMgr which has a template function to register a listener. But, when I register a listener, linker gives me a "error LNK2019: unresolved external symbol". Appetizer code: class EventMgr { template< class T, class EvenT> void RegisterListener(T* listener, int EventType,...

Hi, I am trying to figure out why this is not working, I'd appreciate if anyone can give me any hints on what the problem is here
 
@brainydexter You don't need to post a link to your question in the chat to get it answered.
 
I'm sorry, I've been thinking/refining this idea for a few days now, and I finally got to implement it..so I just grew a bit impatient
 
niiice, clang has full variadic templates support now, according to dgregor!
 
and rvalue refs should be ready in a few days, if it continues at that pace
 
8:14 PM
Hmm, I really should change my default compiler to clang
 
8:30 PM
what's the big deal about clang?
 
9:02 PM
@John Unlike GCC, it’s architecture isn’t fucked up on purpose
 
sbi
In an attempt to improve on my answer to stackoverflow.com/questions/4749325/…, I came up with ideone.com/RWfja, which VC10 compiles fine. Ideone's GCC gcc-4.3.4, however, barks at me, all in <tuple> .
 
and it’s programmed in very clean C++
 
sbi
This is my first attempt at ideone.com, and I'm not sure how to proceed. Is there a way to set it to a newer GCC version?
 
@Konrad: is it especially conformant to C++03? Or no more/less so than other modern compilers?
 
@John: I suspect (but I don’t know) that its conformance is probably a little less than GCC’s
however, if that’s the case it should soon catch up. Conformance was a design goal from the start
and since the compiler itself is written in C++ they have a much bigger incentive than GCC to get it right
 
sbi
9:05 PM
Um, hullo?
 
@sbi I think Ideone should also support GCC 4.5
 
@JohnDibling i have the feeling that GCC is more conformant in some cases and clang is more conformant in other cases
but overall I have the feeling that clang beats GCC
 
sbi
@peoro It "should". Mhmm. But does it? And if so, how to make it do so?
 
@Konrad, @litb: ok, thx
 
@John I have to add that as an “end user” I don’t think I’d benefit very much from switching to clang. But its code base is much more comprehensible and its design philosophy is very, very much superior to GCC’s
 
9:12 PM
@Konrad: yeah, that's what I gather. and I was curious from and end-user's point of view
 
@sbi Hum, I was just checking... Maybe using C++0x instead of C++ as language?
 
GCC is designed specifically so that no plugins can be programmed for it. Instead, additions have to be patched into its actual code base.
 
sbi
@peoro <slaps_forehead/>
@peoro Thanks, it now compiles: ideone.com/u6OHj
 
The rationale is that this forces other people to open-source their code, e.g. Stallman has stated that this is the only reason why GCC has Objective-C support: Apple was forced to release their code under GPL since it modified the actual GCC, rather than be an external plug-in that could be released under a closed-source license
this kind of reasoning really grates on me
as design principles go, I’ve yet to see worse
 
@Konrad: I suppose the "free software" hippie zealots (I'm not one) would claim this to be a good thing?
 
9:18 PM
Stallman claims its a good thing
that’s why I think that clang is fundamentally superior
 
You can actually use it to write software you can get paid for not in beads & chickens? Yeah, I think that's better too. :)
But, I may be biased. I don't know if you could tell by my tone. :)
 
sbi
@JohnDibling We, who have to code for a living, are certainly biased on this.
 
sbi
9:32 PM
Well, I'm actually quite fond of my solution:
1
A: Parsing binary message stream in C/C++

sbiOk, the following compiles for me with VC10 and with GCC 4.5.1 (on ideone.com). I think all this needs of C++1x is <tuple>, which should be available (as std::tr1::tuple) in older compilers as well. #include <iostream> #include <tuple> typedef unsigned char uint8_t; typedef ...

It requires only two trivial member functions per struct plus that buffer size constant.
What say you?
 
@sbi: I'm checking it out. This is pretty much what I do for a living
 
sbi
@JohnDibling Checking things out? Serialization?
 
your post
 
sbi
@JohnDibling What, you make a living of my posts?? <confused/>
 
Yeah. I thought you knew. Thanks for making me rich!
 
sbi
9:36 PM
LOL!
 
@sbi looks nice, but for the usage of a C-style array :-P
 
@sbi: Am I misunderstanding the problem? Op seems to be trying to find a way to solve the problem that pragma pack(1) solves?
 
sbi
@peoro Well, since it isn't allocated dynamically, and it isn't used as an STL container, I didn't want to drag in std::array.
@JohnDibling Which he claims is not available on all of his compilers.
 
what do compilers do with static const variables? Are they actually storing the value in memory, and access the variable when the value is needed?
 
@sbi: I wonder which compilers?
 
sbi
9:40 PM
@peoro This one must be an integral compile-time constant, otherwise I couldn't use it for defining the array's size.
@JohnDibling He says in a comment somewhere...
 
@peoro: I think that if you dont take the address of the static const, its up to the compiler can interpret it as an ICE
@sbi: ah, yes, he's writing to QNX.
 
sbi
In a comment to the question: "...unfortunaltey (sic!) I'm writing fo QNX and other exotic platforms..."
 
I've actually just started looking in to QNX
 
sbi
@JohnDibling Whatever that is...
 
@JohnDibling ICE?
 
9:41 PM
QNX is an embedded real-time operating system
@peoro: Integral Constant Expression
 
oh, ok
 
sbi
@JohnDibling Ah, yes, that's the correct term. I messed this up. Sorry, @peoro.
@JohnDibling Too much to digest at a glance. I wonder whether such a compiler would support TR1, though.
 
@sbi: Unlikely.
These things are often slow to adopt new tech
 
sbi
@JohnDibling Ah, so it was for nothing.
Too bad.
 
9:44 PM
Certianly not for nothing.
Even if he can't use TR1, he can still use your solution as a guide
 
sbi
@JohnDibling But it would need some mildly advanced template support.
 
true dat
 
sbi
@JohnDibling Indeed, I ran into std::tie() and I like this a lot.
 
woah, it crashes if I assign a static const int to an int & via const_cast, and access the reference
 
sbi
Anyway, I do like the result, even if it might never be needed.
 
9:47 PM
I do too
If I were tackling this problem, I would start on the (assumed) presumption that since we're bringing the message in from a socket, we're getting effectively an array of char.
I'd write an STL-ish iterator for that raw array. Templatized on the type of field you'd like to extract. Say string or double.
copy from the raw array in to members of a struct
 
@JohnDibling > The other way is to write specific parse function for each message type, but as I've mentioned, protocol includes hundreds of messages.
 
I did this recently for a FIX/FAST decoder. The code is grungy and pretty heavy-duty, but it works beautifully and is super fast.
@peoro: Yes, that's a valid alternative. I think it would be much easier to write parsers for fields rather than mesasges though, since there will be only a handful of fields.
 
@JohnDibling I was quoting the answer... I think he doesn't want to manually specify the order of fields to be read
 
@peoro: ah, he wants to have his cake and eat it too. a super-magical system that does everything. thats going to be hard to build, and will be very prone to defects
 
(and I think that "specific parse function for each message type" was just a function like stream >> field1 >> field2 >> field3;)
@JohnDibling agree with you
I'd write a code generator for those functions... It shouldn't be tough at all to parse POD structs like those ones
hum, not sure anyway... Also @sbi (and others)'s answer needs to define a tuple for any message -- probably I didn't get the question
 
sbi
10:12 PM
@JohnDibling What would that bring? You don't have many objects of the same type in that array, but many of different objects types. You can't iterate over a heterogeneous container. What am I missing?
@peoro The tuple is so that you can let the compiler generate the boiler-plate parsing code. All you need to do manually is add those two similar member functions per message type and overloads for any data types you want to treat specially.
 
@sbi: You can, if you write your own iterator class
 
@sbi then wouldn't be enough to write something like stream >> msg.field1 >> msg.field2 /*etc etc*/ and specialize stream::operator>> for any native type he can find in any message (as I think @JohnDibling was proposing)?
 
sbi
@JohnDibling And what would be its value_type??
@peoro For one, he needs it binary. But also, you cannot always simply stream all types. For example, for std::string you might need a reader that reads more than one word.
 
@sbi can't you both read binary data and read more than a word with an overloaded operator[] ?
 
@sbi: I declare my iterator like this:
class const_iterator : public std::iterator<std::forward_iterator_tag, FIXFast::FieldId >
 
sbi
10:21 PM
@peoro What? <confused/>
 
Where `FieldId` is delcared as:
struct FieldId
{
uint32_t type : 5;
uint32_t length : 11;
uint32_t id : 16;
template<class Type, class Return> inline Return GetAs() const;
template<class Type> inline Type Get() const;
};
 
sbi
@JohnDibling Ah, I see.
 
after the FieldId follows a variable-length binary data blob
 
uhm, something like this:
`operator>>( S &stream, int &x ) { stream.read(4, &x); }`
`operator>>( S &stream, string &x ) { int len; stream.read(4, &len); stream.read(len, &x ); }`
wouldn't this work?
how can I insert code?
 
@peoro: I can't get it to work either
 
sbi
10:23 PM
@peoro Indent. Multi-line messages don't feature markdown, though. (You might want to rea dthe newbie hints on the right.)
 
you have to use four-line indentation in chat
 
sbi
@JohnDibling Yours is a multi-line message, too, that's why.
@peoro What is S?
 
@sbi already read it, but didn't know of this limitation on multi line messages...
 
sbi
@peoro It says: "Markdown sort of works here, like in comments, but it fails for multi-line messages."
 
@sbi the typo of the stream... I wrote it quickly: that operator will also have to return a reference of the stream (ie: stream)
 
10:25 PM
un oph, beer o clock comes early on fridays!
 
sbi
@peoro But there already is an operator>>(std::ostream&, std::string&).
 
@sbi it's not an std::ostream, I guess, is it?
and even if it's, it'd be easy to build a wrapper around it using inheritance or composition
 
sbi
@peoro Then why would you come up with your own streams, with similar, but for some types slightly different semantics for reading from them, instead of just using a set of write() and read() functions?
 
@sbi you could do also with a write and a read function... I think overloading operator>> is cleaner, since here I was trying to define the semantics of a binary stream (thus overloading stream operators )
 
sbi
gaga already has a binary buffer, all that's needed is to read from it. Why would you want to wrap some stream-like thingy around it?
@peoro No, it's not cleaner. Please read the three basic rules of operator overloading. Your idea violates at least #2, if not #1 as well.
 
10:30 PM
ok, ok, no reason to do that, it's what I'd do, anyway it'd be OK also if you do network.read( msg.field1 ); network.read( msg.field2 ); etc etc
 
sbi
Anyway, I should go home now. It'*ll already take until Sat for me to do so...
see you
 
@sbi I think << and >> are a well known semantics for stream operators, since STL and boost (and Qt and many others) are using shifting operators like that
ouch, I think I was annoying him :-/
I'm leaving too, anyway...
 
11:10 PM
though << and >> are well known as stream operators, they are often considered by some to be an abuse of operator overloading, and I count myself among that group
 
sbi
11:55 PM
@peoro Yes, they are very well known, but with a slightly different semantics than you want to overload them with. And that is a real problem.
@peoro No, as I said, I needed to go home. It was approaching midnight already.
 

« first day (97 days earlier)      last day (4852 days later) »