« first day (611 days earlier)      last day (4346 days later) » 

3:00 PM
@Potatoswatter good point
A boiled potato
 
@sehe Parenting level: Sehe :P
 
@Ell boost iostreams has container_sink which does that: boost.org/doc/libs/1_49_0/libs/iostreams/doc/tutorial/…
(string is a container)
 
Ell
well I want it to operate on a vector<char> (buffer, not string)
 
yeah you can use a vector<char> instead of string in those examples
 
18 mins ago, by sehe
@Ell std::vector<char>(std::istreambuf_iterator<char>(std::cin.rdbuf()), (std::istreambuf_iterator<char>())); -- roughly Edit Oops, the other way around :)
 
3:02 PM
I think they all deduce the types so you literally only need to change that part
 
^ to append use std::back_inserter(v);
 
Ell
right kk
 
that's not a stream though (if that matters)
 
That's a fucktor.
2
 
Ell
basically I need an std::ostream interface to a vector<char> so boost can serialize an object into it
 
3:03 PM
@awoodland True enough. The guy apparently is doing serialization, so I suppose he could do without semi-streaming containers
@Ell Why. Serialize into a std::stringstream ss(std::ios::binary) instead?
 
std::string > std::vector<char>.
 
Ell
good point actually, that was me being stupid. although at the moment, my network thing accepts a vector<char> to send
 
bob
If I have a pointer p of uint8_t and I want the 16 bit int value between the bits 32 and 48, do I have to do this: ((uint16_t) p + 4) ?
 
@Ell What, it takes an std::vector<char>??! Make it take an std::vector<char> const& at least.
 
@sehe that would be a partial specialisation though
 
3:05 PM
@Ell That's unhealthy. It would be better to make it accept streaming input (e.g. using input iterators)
 
template<typename T> void std::swap<Container<T>>(Container<T> &, Container<T> &) { } <-- not allowed
 
Use std::bitset if you want to manipulate individual bits.
 
@sehe sry, I meant that one
 
Hey what the fuck happened?
Is this room moved to meta or something?
Oh it's normal again.
 
Ell
ugh I might have to start this whole networking part again!
boost::asio needs a buffer - not sure what exactly is allowed in that
 
bob
3:08 PM
If I have a pointer p of uint8_t and I want the 16 bit int value between the bits 32 and 48, do I have to do this: * ((uint16_t *) p + 4) ?
 
@bob you probably want at least a * in that
 
It still looks fugly.
 
bob
I know it was understood as an italic sign
 
@ecatmur Please respond to individual messages. This is confusing the hell out of me.
 
They didn't even get the margins in the grey box at the bottom right.
 
3:08 PM
@ecatmur Also, only since c++11. And, does it matter? Specialization is specialization, IMO
 
@RadekSlupik it went odd for me
it's got the meta chat theme and wrong width
 
Ell
@awoodland me too. it just fixed though
 
@RadekSlupik They pushed new stylesheets...
 
Ell
right, boost::asio accepts a std::streambuf& when sending stuff. not sure if that covers iterator pairs or what?
 
No, equal on all sides.
 
3:09 PM
@sehe but you can't partially specialise std::swap because it's a function
 
@bob that looks sensible (assuming CHAR_BITS == 8 and the buffer is big enough)
 
bob
"sensible" meaning "right" ?
 
@Ell Nope it doesn't. However, it wouldn't be too hard to implement streambuf on an interator range. I'm also pretty sure boost asio supports more than just std::streambuf&
 
@bob yeah, I don't like C style casts much though - for all I know you lost constness there too
 
Isn't that perfectly fine in c++11? Hmmm.
Breakdown. Need food
 
bob
3:11 PM
What would be the c++ equivalent ?
 
Ell
@sehe oops I was reading the wrong thing, serialization only accepts streambuf & ostream
 
@bob static_cast<T>(), dynamic_cast<T>(), reinterpret_cast<T>() (DANGER), const_cast<T>() (DANGER)
 
bob
What's the difference between all of these ? :)
 
#include <cstdint>

int main() {
  uint8_t bytes[10];
  uint16_t val = *(reinterpret_cast<uint16_t*>(bytes+4));
}
 
bob
thanks awood
I don't see much difference though :)
 
Ell
3:14 PM
@bob static_cast is just an explicit type conversion, dynamic_cast tries to convert Base class to Derived class and throws exception if its not right (rtti sorta), reinterpret_cast is c-style cast, const_cast casts from const to non-const
 
@sehe it wasn't changed in C++11 apparently: stackoverflow.com/questions/5101516/…
 
@bob The documented behaviour :)
 
@bob the difference is const uint8_t bytes[10]; uint16_t *val = (reinterpret_cast<uint16_t*>(bytes+4)); gives you an error, but just doing (uint16_t*) happily ignores the loss of const
 
@bob That's because reinterpret_cast is crazy. It just basically tells the compiler "Shut up. I know stuff!"
 
@sehe reinterpret_cast warns about const still and reinterpret is exactly what's happening there
 
3:16 PM
@ecatmur Thanks for the hin
@awoodland Good point. Also, sry for misdirected reply/plink
 
Ell
my gosh this is going to be incredibly innefficient probably
 
Wow, Alf is very critical of other's answers :/ I've never had him come after mine before.
 
Ell
I might just rewrite the whole networking part :s
 
@MooingDuck I seem to recall @alf making a strong argument for using namespace in more contexts than most agreed with
 
@MooingDuck I think, when you have removed the directly incorrect stuff, then if I travel by the question again I just remove the downvote. Even if there's enough other bad things to justify a downvote, it is slightly subjective. So I apply the same rules for myself as for others: downvote should only be used for directly incorrect or meaningless stuff, and it should always be explained. ;-)
 
3:21 PM
@Ell Use binary serialization already. If you don't like Boost Serialization, at least look at Boost Spirit (e.g. vector<int32_t> v; qi::parse(it1, it2, *qi::big_dword, v); see also boost.org/doc/libs/1_49_0/libs/spirit/doc/html/spirit/qi/…)
 
Ell
@sehe I'm using binary serialization - I've just mucked everything up with a load of vector<char>'s for no reason, I'm just going to redo the whole Asio part of it. I hadn't done much so wont take too long
 
@Ell you can probably get asio to work on the vectors and avoid copying (by using lvalue references in the right places, iff c++11). I might be wrong, but Boost libs are usually crazy flexible so, I think it's a fair bet
 
@CheersandhthAlf fwi: I just addressed your newest comment, turns out I was misinformed on the subject and you were right.
@CheersandhthAlf I don't mind the downvote (well, much), and I do appreciate the comments and corrections, but your wording always seems like you're calling other people stupid and I frequently find it offensive :(
 
Ell
@sehe I was trying to make the interface independant of how messages are delivered, e.g., if the server is running on the local machine you don't need to use sockets so my interface is like SendMessage(std::vector<char> buffer). Then I have TCPServerConnection which just implements this with boost::asio. It just looks like I'm copying a lot
 
@MooingDuck linky?
 
3:25 PM
@MooingDuck You're not alone. Also, there is not much you can do about that. This is the internet, more specifically, SO users, and you have to deal with it :)
 
Welcome to the internetz, you shall be offended :)
 
@Ell Do you think that will be a problem? If so, fix it. If not, keep it in mind for next time
 
Ell
@sehe I think it could be a problem, but I don't know yet. I will leave it for now and check out after
 
@Ell Good idea.
 
@sehe but usually when people are offensive, it's just offsensive and I can flag it. Alf's comments are (usually) helpful (but worded aggressively), which makes me not want to flag.
 
3:28 PM
you just need to adopt a technical mindset where corrections engender Positive Feelings(TM) of learning something new. as opposed to a social interaction mindset where criticism is negative unless framed in compensating meaningless feel-good phrasing. technical stuff is not social itself -- and i think the few girls/women who succeed in this field are mostly the very few who have managed to break out of the common social box and realized that.
 
What's the problem? That sounds reasonable :)
My usual response is. "Right! Fixed"
Frequently, mutual comment deletion ensues
 
@CheersandhthAlf but comments on SO are social. "In short, this is a Very Bad(TM) answer, with both bad advice, incorrect code and an incorrect claim" is not technical. Though as I reread your comments, the rest would neutral in a technical context, I see where you are coming from. I still disagree, but I see it now.
 
did i mention here that the university of Minnesota did a study of that on Wikipedia?
 
@sehe Thats what my comments were, I was just letting off steam here.
 
@CheersandhthAlf lol
 
3:32 PM
it was about Wikipedia editors. females generally don't choose to contribute by editing, and when they do, they generally can't take the feedback, and opt out again. they prefer to only reap the harvest of others' editing efforts. and I think, it was not said in the study, that that's because technical feedback hurts them. because (I think) it's interpreted as social signals.
 
@CheersandhthAlf I knew of the study, and it was criticized, namely for working with the assumption that a technical mindset should be preferred without justification. Why not prefer the social feel-good phrasing? (I believe it was a feminist website, I'm not sure which side I agree with)
@CheersandhthAlf in the case of wikipedia itself, I agree with the technical side, because communication channels are too limited for social. Unsure about SO though.
 
@CheersandhthAlf Pfff.. women and their "emotions"
 
@Neil wikipedia is known to be harsh on new material. R.Martinho got upset when he corrected some malicious edits, and it instantly got rolled back for being a malicious edit, by some bot.
 
@CheersandhthAlf I learned this a few years back when I learned a lot as an 'apprentice' to a programmer who had been writing his own software product for 10 years and wanted to 'transfer' the project. His style was somewhat hard to accomodate, this was in person 8 hours per day. But it worked out.
I just had to unlink my self esteem from the proceedings. Also, about in the second week I felt the need to assert my own expertise. I did, and it got accepted. I worked there for 8 months, and had a good time. (A few others came in and either crumbled or got shown the door in a few weeks. Or both)
@MooingDuck IMO the communication channels on SO are even more limited. But the quality/objectivity requirements are ostensibly lower too
 
Hello.
 
3:38 PM
 
@TonyTheLion The beer is really out-of-character there
 
@sehe But it's so interesting!
 
@sehe You mean you don't edit the wiki while drunk?
I thought everyone was doing it
 
The alpha male with his cool, assertive pose doesn't go well with the weak-hearted, feebly-kneed, overly long excuse text of a meme. So: no it doesn't work.
/last thecoshman
What do you guys reckon?

(a) the pirate is doing actual work today -- ???
(b) the pirate is chatting on IRC fulltime now
(c) the pirate is somehow incapacitated and needs medical attenion
(d) other: ....
 
(d) the pirate is buying ketchup-flavored crisps
 
3:54 PM
@RadekSlupik ... overseas
 
Damn. I still haven't created any wireframes of Hexapoda.
 
Ell
@RadekSlupik what is it a clone of again?
 
@Ell clone?
 
Not a clone. More a crossbreed from hell
 
Ell
@RadekSlupik sorry I thought it was a clone? nevermind. What kind of game is it?
 
3:59 PM
lola :p
@Ell It's a game where you file bug reports and assign them to other people or to yourself, or comment on them.
 
Ell
ahh must have the wrong person, sorry :P
how is it going anyhow?
the bug tracker?
 
I started over for about the tenth time.
Now in Python.
 
Ell
I always start stuff over and over :l
 
I found out that on every HTTP request it makes a new connection to the database.
xD
 
@sehe did you insult my ability to create a meme?
lol
 
Ell
4:05 PM
argh unregistered class exception S:
 
@TonyTheLion I don't know. Did I?
@Ell Boost serialization!
 
Ell
@sehe I know :s I've read the docs and am doing what it is saying but I get boost::archive.......some exception
I need to use the macro BOOST_CLASS_EXPORT_GUID
but it isn't working :(
 
@Ell any container with polymorphic items?
 
Ell
@sehe at the moment it doesn't contain anything, just a Base and a Derived with a virtual function string GetDescription()
 
@Ell did you register Derived properly too and tell boost about both in the serialise function?
 
Ell
4:10 PM
oops may not have overriden the serialize method
I only registered derived - do I need to register Base too?
 
I think you need to register both and you'll need something like &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base) in the derrived type
 
@Ell if it can be instantiated
 
Ell
if this was wide, it could discover the class hierarchy at compile time
@sehe it can't - its abstract
 
you could use gcc-xml or something like that
 
Ell
I'll keep trying
 
4:15 PM
@sehe not really
 
@TonyTheLion Oh good. Ah lion with thick skin
 
Oracle is so much fun:
> 1. Download the ODAC zip file into a temporary directory. Note: Do not download this file into the "Tmp" directory.
 
Ell
lol
 
Does JavaScript have a stack data structure?
 
4:20 PM
@PaulManta Not that I can see, but you can Array and create one
@sehe urgh Oracle, I had nightmares about that product before
 
Lounge<C++>: dishing out javascript advice. And memes Jelly
 
> 69 error(s), 0 warning(s)
I like that number :P
lol
 
:D
@TonyTheLion If there wasn't your nickname in front of the message, I would have known who had typed it anyway :P
 
Checkin time, then
Only one thing left: think of the appropriate checking comment
 
bob
4:24 PM
If I create a tabular inside a function using 'int v[5]', will I be able to use 'return v' and use v in another function ?
 
@bob You mean array
 
A tabular ?
 
@bob Nope. It's a stacklocal variable, it doesn't exist when you exit the function
 
bob
yeah array
 
@bob not unless it's static but you most likely don't want to make it static
 
bob
4:25 PM
so I need to use 'new' ?
 
no you don't
 
@ScarletAmaranth kek
 
@bob use std::vector or std::array
 
@TonyTheLion :P
 
@bob No, use std::vector<int> v(5); or std::array<int,5> v; and return it by value
 
bob
4:26 PM
what if that's not an option ?
 
Then you can return by strong reference.
But usually, value's fine :)
 
@bob upgrade system/compiler or kill the person who forbids it
 
@bob why would that not be an option? That's always an option.
@bob oh, are you doing homework and the professor isn't letting you use the standard library?
 
bob
because I'm using a C code that uses char* and I don't want to modify everything
 
4:27 PM
I suggest hitting professor with heavy force.
 
@bob two mandatory readings: First the standard workings of C++ (or C) since ever:
2237
A: Can a local variable's memory be accessed outside its scope?

Eric Lippert How can it be? Isn't the memory of a local variable inaccessible outside its function? You rent a hotel room. You put a book in the top drawer of the bedside table and go to sleep. You check out the next morning, but "forget" to give back your key. You steal the key! A week later, you retu...

 
@bob minimal change: use new. Correct change: change everything
 
Second: modern C++ style Want Speed?: Pass By Value
 
@bob you can make a std::vector<char> into a char * quite sanely
just do it in the right place and manage the memory the nice C++ way still
 
@awoodland std::string comes to mind... /cc @bob
 
4:29 PM
@sehe I wonder how long it will be before someone tops that with a non-wiki answer. (Jon Skeet's top answer doesn't count since he gets too many people visiting his profile.)
 
bob
and the syntax for new would be int v[5] = new int[5] ?
 
@Mysticial Rep fetish
 
@bob no, int* v = new int[5];
 
no, syntax would be int * p = new int[5];
 
@sehe who? me?
 
bob
4:30 PM
ok thanks
 
@Mysticial yup. And hi
 
@bob But you don't want to do that ...
 
@sehe Do I look like a repwhore anymore? :P
 
bob
Yes I understand that it's not good practice, but this is the easiest way given what I'm dealing with
 
@Mysticial You keep mentioning it. The second you come in, you mention rep :)
 
4:32 PM
@sehe Nowhere did I say rep in that first message.
 
@bob it's not easy because you still have to make sure someone calls delete[] (and definitely not free())
 
Ell
anyone willing to just take a look at this? pastie.org/4109399 its my basic example of boost::serialization that isn't working (unregistered class)
I'm missing something key, obviously
 
@Mysticial it was implicit :P
 
You need to call the base class serialize method from the derived class.
 
@Mysticial I didn't say that. I also didn't call you a repwhore. I said you still (appear to) have a rep fetish. It applied.
 
4:34 PM
@sehe Now I'm confused.
 
21 mins ago, by awoodland
I think you need to register both and you'll need something like &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base) in the derrived type
 
hooray for repeating yourself :P
 
Ell
sorry let me try again :L
 
@Mysticial You can have a rep fetish without actively whoring for your own rep.
 
whore someone else's rep?
 
4:35 PM
29 secs ago, by Tony The Lion
hooray for repeating yourself :P
 
To be anti-rep still implies that rep is on your mind.
Or something like that..
 
@TonyTheLion I've helped drise get rep in the past
 
@TonyTheLion I would have typed it out again but I always forget the order of all those words in that macro name
 
@TonyTheLion adore, glorify, crave, mock, denigrate, adulterate, ...
 
and M-/ doesn't work here
 
4:36 PM
@sehe those words mean entirely different things
or did you copy that from a thesaurus
 
@TonyTheLion You. So do 'cook', 'eat', 'throw', 'photograph' - but they are all things you can to with food
 
@awoodland that's not what I meant, I meant that you'd already said it and now you have to say it again (sigh), thank god for permalinks :P (My comment was sarcastic)
 
@TonyTheLion ?!? I think the regular thesaurus would come up with a list of words that mean roughly the same
 
@sehe How does that work? Unless "admiring" counts as a fetish.
 
Ell
@awoodland do you know how to use this? can't find the doc for it
 
@Mysticial It does
 
@sehe yea that's what I thought, but I was confused. Your other comment explains it
 
@sehe Fair then. :)
 
Hehe
 
> UnitedStatesofAmericaMexicoCanadaRussiaChinaJapanGermanyFranceItalyEnglandScottl‌​andIreland
dafuq?
 
4:39 PM
@Ell it'd just be ar & BOOST_LONG_MACRO_NAME(BaseClassType) inside the serialize function
 
@TonyTheLion Google comes up empty. Where from
 
@sehe the edit I just linked
 
1 min ago, by Mooing Duck
@TonyTheLion http://stackoverflow.com/posts/10937751/revisions Edit #7
 
@TonyTheLion I needed a long country name to overflow the buffer
 
4:40 PM
lol
 
Ell
@awoodland where did you find this macro? I have found boost::serialization::base_obect<>()?
I don't know what header to include
 
The Former Yugoslav Republic of Macedonia
The United Kingdom of Great Britain and Northern Ireland
 
it would have been more obvious if you named it ThisIsSupposedToBeAReallyLongSentenceThatWillObviouslyOverflowMyUndersizedShitty‌​BufferDontEverDoThis
 
"Krung-thep-maha-nakorn-boworn-ratana-kosin-mahintar-ayudhya-amaha-dilok-pop-nopa-ratana-rajthani-burirom-udom-rajniwes-mahasat-arn-amorn-pimarn-avatar-satit-sakattiya-visanukam" is supposed to be the Thai proper name for Thailand
 
holy shit
 
4:42 PM
Needless to say, that's in Wales
 
The Former Yugoslav Republic of Macedonia
 
@Ell it's either in boost/serialization/utility.hpp or boost/serialization/base_object.hpp I think
 
@sehe I'm slow
 
@sehe nobody actually calls it that other than tourists :)
 
4:42 PM
@TonyTheLion No need. I can take care of my self. I'm slow today. Chrome Cripples
 
Ell
@awoodland still getting the error :(
 
> Al Jumahiriyah al Arabiyah al Libiyah ash Shabiyah al Ishtirakiyah al Uzma
^ Supposedly Libya
 
bob
I still have a problem with my pointers though... I'm using an array v composed of 5 int that are the beginning of my array. But I also have another int* array w. How can I link these two together ? I can't just do v[6]=w, that doesn't work...
 
@bob to "link" arrays, you have to make a new array big enough for both, and copy the data into the new array.
 
4:49 PM
@bob Bob, you're doing great. You're asking all the right questions. Just keep in mind, people in this room will get impatient when you mention pointers and arbitrary (professor) restrictions...
 
How hard is it to learn multiple languages at the same time?
 
@bob seriously, in this case use a vector
 
@MooingDuck std::copy(std::begin(w), std::end(w), v);
@MooingDuck yup. v = w; :) Or, to append: v.insert(v.end(), w.begin(), w.end());
 
@sehe he wants to append, not overwrite
 
@MooingDuck ^ edit
 
bob
4:51 PM
ok I'll use a vector, but then I need to do a conversion in the end because the function is supposed to return a int*
 
ok, so System::Drawing::Image::FromHbitmap takes a IntPtr and I have a raw HBITMAP, anyone know if I can get away passing the raw HBITMAP to it?
 
@bob v.data() or &vector[0]; -- Just keep in mind that the resulting pointer will become invalid (a) when the vector reallocates (e.g. resized) or ceases to exist (lifetime)
 
@bob and how will the caller know who owns the memory that the int * points to?
 
@Ell ideone.com/AWD0i - works fine on my system with my changes. ideone doesn't link boost serialization library
 
bob
what do you mean, ecatmur?
 
4:53 PM
@bob retuning a non-const pointer is something you should completely avoid in C++ and only under extremely unusual circumstances is appropriate in C.
 
@ecatmur the pointer points to 'some data'. Who's responsible for deleting it? How long will the pointer be valid? IOW: Who owns the data pointed to?
 
@sehe said far better than I could
 
bob
I do own it, since I just created it.
 
@Mysticial the non-const is really not much of a reprieve there. There is a minor difference.
 
@Ell part of the problem was you serialized a DerrivedA but unserialized an Abstract* I think
 
4:55 PM
@bob The point is (a) you have to keep track of those things, which is error prone (b) the caller should abide by those assumptions. That means: checking the docs. Because the signature (prototype definition) is not explicit about it. Hell, the prototype doesn't even make it explicit whether int* p points to an array or a single element
 
bob
yes I understand but that's just the way the code I'm using is done, there's not much I can do about that. It requires me to return a int*.
 
@sehe I'm referring to when the function returns a pointer to something that is already owned by something else (like string::c_str).
 
bob
I'm assuming the necessary steps are taken to free the unused memory once that code is done with my pointer
 
So it shouldn't be freed anyway.
 
@bob That's ok. Just make sure you either keep the vector alive long enough or return a new-ed up array...
 
bob
4:57 PM
I'm just sending the code some data, he's in charge of using it and deleting it when it's done
 
@bob The point is, you can't if the pointer was gotten from v.data() or &v[0]
 
Ell
@awoodland thank you :)
 
@Mysticial I know. My point is that the constness really doesn't matter much for the ownershup
 
bob
@sehe why? Just because the length is unknown ?
there might be another way in the code to retrieve the length
 
@bob It's nothing to do with length.
 
4:59 PM
@bob No, because the vector still owns it, and it will destroy it 'again' when it's destructor runs
 
When a function returns a raw pointer, you need to know whether it needs to be freed.
 
bob
oh, then why is it not possible to free a pointer that comes from v.data() ?
 
1 hour ago, by Neil
I thought everyone was doing it
 
@bob the vector owns it, and will delete it when the vector is destroyed
 

« first day (611 days earlier)      last day (4346 days later) »