Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 460

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 465

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 465

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 465

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /hermes/waloraweb002/b1002/moo.warriorsofsteelcom/tdo/wp-content/plugins/spostarbust/index.php on line 465
Declaration | Techdot Internet Relay Chat Resources, Logs, and Records.
 

**** BEGIN LOGGING AT Sun Oct  9 16:16:25 2011

<Nik05>    i made a function strtoint(char const *) and strtoint(std::string const &)
<tLt>    appending a single chunk of data is probably the one case where raw unbuffered access is the best way
<Nik05>    but the std::string const & doesnt work
<Nik05>    it gives this error:
<Nik05>    undefined reference to `strtoint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’
<Nik05>    What can i do?
<Griwes>    some code, please
<Nik05>    what code do you need?
<Griwes>    <Nik05> i made a function strtoint(char const *) and strtoint(std::string const &) <- code, where you did this
<GrecKo>    Yours
<Nik05>    http://ideone.com/hnvBo here
<osrec>    tLt: when you say single chunk, you mean 1 byte?
<osrec>    or the filesystem specific chunk?
<tLt>    chunk as in .. blob
<tLt>    buffer
<tLt>    collection
<osrec>    ok
<tLt>    yaddayadda
<tLt>    i.e. when all data is contained in one operation
<Griwes>    Nik05, and show some test case, where it does not work
<Nik05>    ok i also have a header file with http://ideone.com/CLUW5 calleed strtoint.h
<peterolen>    Nik05: did you link all files?
<Nik05>    yes
<Nik05>    and this is part of file
<Nik05>    http://ideone.com/vEs21
<Nik05>    when i change bar to bar.c_str() it works fine…
<Nik05>    but it should accept std::strings too…
<tLt>    osrec: see msg
<Griwes>    Nik05, give some code, which:
<Griwes>    1) compile 2) does not work for you
<Nik05>    Griwes compiling works
<Nik05>    but linking does not
<Griwes>    omg
<Griwes>    give something that (does not work) and (compile)
<V-ille>    you need to write a testcase
<V-ille>    geordi: int strtoint(string const & str) { BARK; return 0;} int main() {string foo = “”; strtoint(foo);}
<geordi>    strtoint(const string&)
<Griwes>    better now?
<Nik05>    Griwes i already posted code…
<V-ille>    perhaps you’re not showing all relevant bits
<Griwes>    no, you only posted some parts
<Griwes>    none of them compiles
<Nik05>    this one compiles: http://ideone.com/hnvBo
<Nik05>    oh it doesnt….
<V-ille>    !give Nik05 testcase
<nolyc>    Nik05: Paste your test case (tick the compile checkbox!) to http://ideone.com/ or http://codepad.org. Using a recommended paste site increases the chances someone will take a look at it. Do _not_ paste to the channel. See the testcase checklist at http://www.eelis.net/iso-c++/testcase.xhtml .
<Griwes>    uh, not actually “compiles”, but “should compile”
<V-ille>    follow that
<Nik05>    this doesnt work… http://ideone.com/6zii2
<Nik05>    but now it does…
<SanbarComputing>    shirt:  I have been reading beej.us network guide this whole time.  It is very good.  Thanks again :)
<Nik05>    ok guys this is really strange…
<Nik05>    maybe its make that is fucking things up…
<Nik05>    but now it compiles and links ok… :S
*    whaletechno_ is now known as whaletechno
<V-ille>    make doesn’t fuck up
<V-ille>    perhaps you forget to save the file after editing it :)
<Nik05>    ah i see i forgot to add a dependency :P
<Nik05>    so it didnt compiled the file with the error… -_-
<SanbarComputing>    bye, unit193
<Nik05>    sorry guys i am an idiot
<Sausage>    !grab Nik05
<nolyc>    By your command.
<Nik05>    no dont grab me!
<V-ille>    hopefully that’s a condition recoverable from
<V-ille>    !grab Nik05
<nolyc>    By your command.
<Nik05>    you did that a few weeks ago too -_-
<V-ille>    !grab Nik05
<Nik05>    !grab Sausage
<nolyc>    By your command.
<nolyc>    By your command.
<V-ille>    happy now?
<Nik05>    no
<Sausage>    Grabspam must always be followed by quotespam
<Sausage>    !rq Nik05
<nolyc>    [12675]<Nik05> you did that a few weeks ago too -_-
<Sausage>    Fascinating!
<Nik05>    what is so funny?
<Nik05>    !rq Nik05
<nolyc>    [12674]<Nik05> no dont grab me!
<melba>    Nik05, this http://www.youtube.com/watch?v=FtZJMlOu0Sw&feature=player_detailpage#t=170s
<V-ille>    epic material
<Sausage>    90% of grabs are about grabbing
<V-ille>    !rq Sausage
<nolyc>    [11138]<Sausage> I don’t mind inserting in the back.
<Nik05>    lol
<V-ille>    !rq V-ille
<nolyc>    [11921]<V-ille> well, you may know jesus christ, but you don’t seem to know the first thing about templates
<Nik05>    jezus christ and templates… haven’t seen them both
<melba>    it’s no coincidence, jesus writes in perl
<Nik05>    java…? :P
<V-ille>    nobody writes java, not even jesus
<Nik05>    Jezus is just as crappy as Java
*    conor_ireland_ is now known as conor_ireland
<Griwes>    !grab V-ille
<nolyc>    By your command.
<Nik05>    wtf im watching Psych and they changed the young Shaun into some fag in S05….
<Pip>    Does the standard library say that every string object starts out with a value ?
<Nik05>    ho this is not social….
<Griwes>    is there something nolyc can give about standard library implementations?
<ville>    list of them or?
<TinoDidriksen>    What do you want to know?
*    tj is now known as Guest49585
<Griwes>    I want to give something like “it’s implementation dependent” for Pip
<TinoDidriksen>    !fs implement
<nolyc>    No keys matching “implement” found.
<TinoDidriksen>    !give Griwes factoids
<nolyc>    Griwes: http://www.projectiwear.org/~plasmahh/cpp/factoids.sh
<Pip>    I’m a brand new learner
<Griwes>    great, thanks
<Pip>    Having felt sufficient with C++ knowledge gained so far
<Pip>    *Havn’t
<Pip>    *Haven’t
*    Pip keeps learning
<Eelis>    Pip: every std::string object has a value, yes.
<Pip>    What about empty string ?
<Eelis>    what about it?
<Eelis>    << string()
<geordi>    <no output>
<TinoDidriksen>    It’s a well defined empty string.
<TinoDidriksen>    geordi, append .empty()
<geordi>    true
<Pip>    std::string empty_string;
<TinoDidriksen>    { std::string empty_string; cout << empty_string, empty_string.empty(); } // Pip
<geordi>    , true
<Pip>    What does .empty() do ?
<ville>    !give Pip std::string
<nolyc>    Pip: http://stdcxx.apache.org/doc/stdlibref/basic-string.html
<TinoDidriksen>    It’s one of string’s member functions.
<Enerccio>    is there a way to get the exact size of char*
<Enerccio>    ie the size it was allocated with?
<Cecen>    Enerccio: No
<ville>    std::vector<char>
<Enerccio>    but new/malloc must keep the info somewhere, no?
<ville>    yes but you have no standard way to access it
<Enerccio>    no?
<ville>    std::vector<char>
<Enerccio>    so any non standard way?
<Cecen>    Nothing sane
<TinoDidriksen>    Enerccio, the way will differ on each platform…don’t try it. Use vector or string instead.
<Enerccio>    so malloc is different for every platform?
<TinoDidriksen>    Of course
<Griwes>    it’s one of most platform-dependent things
<x0rs_w>    Can anyone explain to me while break; statements have to end each switch case option? Is switch considered a loop?
<V-ille>    they don’t “have to”
<V-ille>    but a case falls through to the next case if you don’t break
<V-ille>    so no, it’s not a loop
<x0rs_w>    V-ille, oh I see. that makes sense
<TinoDidriksen>    It’s just a reused keyword.
<salty-horse>    re-asking from yesterday: in VC++2010, “vector<vector<int>> v(10, 10)” creates a matrix with 10 rows and 10 columns. it fails to compile with the latest gcc -std=c++0x. comeau also compiles it fine. who is wrong? which constructor of vector is called?
<TinoDidriksen>    salty-horse, that should be vector<vector<int>> v(10, vector<int>(10))
<Cecen>    salty-horse: It’s a VS extension
<TinoDidriksen>    salty-horse, and to save your sanity, use Boost.Multi_Array instead.
<Cecen>    Probably a comeau extension too
<Cecen>    The correct behavior is that it shouldn’t compile
<mgaunard_>    there is no requirement that it doesn’t compile
<salty-horse>    Cecen, hey again :) I tried searching for the docs on msdn and couldn’t find it: http://msdn.microsoft.com/en-us/library/zzw4bwhd%28v=VS.100%29.aspx
<Cecen>    mgaunard_: The second 10 is being implicitly converted to std::vector<int>
<Cecen>    It’s done via an explicit cast from 10 to std::vector, which bypasses the ‘explicit’ keyword on the std::vector(size_t) constructor
<mgaunard_>    the standard mandates that this constructor is explicit?
<Cecen>    Yes.
<Cecen>    salty-horse: I checked the standard and VS’s implementation, there’s also a post about it on the MSDN forums where someone confirms it’s a work around/extension
<l_r>    i need a queue where elements might appear no mora than one time. what the best container and strategy would you use to make sure of that before adding an element to the queue?
<Cecen>    It might have worked in older standards, but with the current standard it shouldn’t compile
<salty-horse>    Cecen, thanks! then I’ll stop trying to hunt it :)
<Cecen>    l_r: Use an std::set and std::queue, I guess :(
<l_r>    std::queue would be ok, but before inserting i must make sure the element does not exist, which is an operation performing in linear time.. i need a more efficient solution while preserving a clear interface
<V-ille>    std::set?
<Cecen>    l_r: Make a wrapper around an std::queue and std::set. Use the std::set to check if the element already exists
<juliohm>    Good night, what do you think about C-like casts for primitive types only?
<V-ille>    perhaps a map would be a good idea
<V-ille>    key with the insertion sequence number
<l_r>    yes
<Cecen>    I don’t think map would enforce unique values, though
<V-ille>    ..and watch it explode with fireworks if the number ever wraps around :)
<Cecen>    Or rather, queue-ordering
<V-ille>    it does
<V-ille>    it’s sorted by the key
<V-ille>    set is sorted as well
<Cecen>    Right, but how can it enforce queue ordering _and_ uniqueness?
<Cecen>    FIFO is what I’m looking for
<Cecen>    Slow today :<
<V-ille>    by using a sequence number as a key?
<Cecen>    If it’s using a sequence number, it’s not enforcing uniqueness, is it?
<Cecen>    It’s enforcing a unique sequence number, but not a unique value
<V-ille>    oh, that. They key with a sequence number _and_ whatever makes it unique. :)
<V-ille>    *Then
<Cecen>    I don’t see how this can work, maybe I just don’t understand though.
<V-ille>    probably yet another use case for boost multi_index
<V-ille>    l_r: note that a combination of set and queue allows checking for uniqueness much faster than in liner time
<V-ille>    Cecen’s original proposal to use set and queue seems quite sane
<Cecen>    Is it logarithmic time?
<V-ille>    trying to trick it with map/set is probably not very easy to understand, if it works at all
<V-ille>    yes, I suppose it is logarithmic
<Cecen>    I’m retarded at any sort of complexity that isn’t obvious :<
<Feto>    geordi: struct s { static int constexpr x = 5; }; int main() { return s::x; }
<geordi>    Exited: ExitFailure 5
<Feto>    this is perfectly valid C++, correct?
<V-ille>    Cecen: just revert to a caveman. Set lookup fast. Queue lookup slow. Grunt grunt.
<Cecen>    ^ EXACTLY.
<l_r>    how fast is insertion is a set
<l_r>    *in
<V-ille>    plenty fast
<Feto>    queue lookup can be really fast if it’s implemented with a list
<l_r>    ok..i ll go with a set and a queue
<Cecen>    Complexity is over-rated. I’ve never seen it used in any meaningful way.
<V-ille>    queue lookup can be as fast as it pleases, it’s still linear, whereas set lookup is logarithmic
<Feto>    not so much if you implement it with a stack
<Feto>    ahh look up… sorry, I misunderstood you :D … correct, queue lookup really slow
<Cecen>    I think std::stack and std::queue are built on top of other containers
<Cecen>    Usually deque?
<Feto>    Cecen: or linked list
<Feto>    or vector
<V-ille>    deque is the default
<V-ille>    l_r: set insertion is logarithmic, which is slower than inserting into a list, but faster than inserting in the middle of a vector
<Cecen>    I need to use deque more. I don’t think I’ve ever used it, probably because it’s not an obvious choice.
<V-ille>    !containerchoice
<nolyc>    http://adrinael.net/containerchoice
<l_r>    oh..nice diagram
<l_r>    thx
<Feto>    so about my issue
<Feto>    this is perfectly correct C++, right?
<Feto>    geordi: struct s { static int constexpr x = 5; }; int main() { return s::x; }
<geordi>    No change in output.
<Cecen>    I think it requires C++11
<Cecen>    clang probably won’t accept it (?)
<Cecen>    I mean, aside from the constexpr
<Feto>    yes, I’m assuming C++0b
<V-ille>    l_r: the diagram doesn’t help us in this case :)
<Feto>    now, please kindly look at this pasty: http://ideone.com/kfs6n
<Feto>    I get the following error:
<Feto>    x.cpp:(.text._ZN2UIC2Ev[_ZN2UIC5Ev]+0x1c): undefined reference to `Cursor<int>::kMaxValue’
<V-ille>    so do I
<V-ille>    add template <typename Type> constexpr Type Cursor<Type>::kMaxValue;
<V-ille>    after the class template Cursor
<V-ille>    the paste failure in ideone is caused by ideone using too old a compiler
<Feto>    why do I need to do that?
<Feto>    why do I need to provide storage?
<V-ille>    I’m not sure whether that makes sense.
<Feto>    what I just said?
<V-ille>    no, having to define the static
<V-ille>    that doesn’t make sense, since it’s constexpr
<Feto>    yes, that’s what I think
<Feto>    and I even submitted a bug
<Feto>    but they said I still need to define it outside
<Cecen>    Is it possible the compiler is ignoring the constexpr?
<Feto>    what does the standard say?
<V-ille>    “they”?
<V-ille>    do you have a bug url?
<V-ille>    I asked Gabriel the Unforgiving for a rationale
<Feto>    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50681
<Feto>    what did he say?
<V-ille>    let’s wait until he answer the email
<Feto>    ok, thanks
<Feto>    does the standard say something?
<lordjj>    Is there a system(“PAUSE”) alternative for GCC? Doesn’t work on linux.
<Cecen>    lordjj: It’s not portable, use std::cin.get() or something similar
<lordjj>    Cecen, there’s also system(“CLS”)
<Feto>    lordjj: what’s that?  you mean running DOS’s PAUSE command?
<V-ille>    Feto: I expect the standard to say all kinds of things. What it won’t say is the rationale. And I think I’m too lazy to read it anyway. :D
<lordjj>    Feto, yes.
<Feto>    heheh ok, let’s wait for an answer… for now I guess it won’t cost me much to define it outside the class definition…
<Feto>    thanks :)
<lordjj>    Is there an alternative for system(“CLS”); to clear the screen. (Besides printing like 50 ‘\n’)?
<Cecen>    lordjj: No
<Feto>    lordjj: yes
<Cecen>    Take your unportable craziness elsewhere!
<TinoDidriksen>    !give lordjj curses
<Sausage>    C++ doesn’t define “screen”.
<V-ille>    Feto: my guess would be that static members follow the same rules constexpr or not
<Feto>    hahahah
<nolyc>    lordjj: Curses! is a 1925 film directed by Fatty Arbuckle. (No, not Garfield).
<TinoDidriksen>    …
<TinoDidriksen>    !fs curses
<nolyc>    Key search for “curses” (2 found): “curses” and “curseslib”
<TinoDidriksen>    Oh
<TinoDidriksen>    !fs curseslib
<nolyc>    The curses libraries (Windows: pdcurses; Linux: ncurses) allow you to do non-blocking input (that is, your program can respond to input -or- a lack of input and continue to run), as well as give you precise control over what is displayed on a terminal screen.
<Feto>    V-ille: but I don’t need to do that for const statics, right?
<lordjj>    that’s a lot of curses…
<Feto>    lordjj: look it up
<Feto>    geordi: give lordjj ggl ncurses
<geordi>    error: ‘give’ does not name a type
<lordjj>    Hehe
<Feto>    nolyc: give lordjj ggl ncurses
<nolyc>    lordjj: http://www.gnu.org/s/ncurses/
<Feto>    wrong servant :D
<V-ille>    Feto: hmm, indeed
<V-ille>    Feto: no, you do need to do that for const statics too
<Feto>    hmm that doesn’t make much sense to me, but I’d accept it for const.  Not for constexpr, though!
<V-ille>    well, the definition rule is the same for all cases, instead of having a special rule for constexpr
<V-ille>    that simplifies specification and implementation, but disallows something that users might find explicable and convenient
<Feto>    correct
<V-ille>    my take on this is “eww boilerplate”
<Feto>    yeah me too
<Feto>    and then another one
<Feto>    struct S { static int contexpr x = 5; }; static int constexpr S::x;
<Feto>    versus struct S { static int contexpr x; }; static int constexpr S::x = 5;
<Sausage>    You don’t need the definition though
<Sausage>    9.4.2/3
<Sausage>    It mentions both static const and static constexpr of integral type
<Feto>    let me look it up
<Feto>    !standard
<nolyc>    ISO restricts distribution of C++ standards and recent drafts. You can buy C++11 at http://tinyurl.com/isocxx11 for ~290 EUR, or C++03 at http://tinyurl.com/isocxx03 for 30 USD. The least outdated freely available draft is n3242, downloadable at http://tinyurl.com/4hsj7sd .
<V-ille>    “The member shall still be defined in a namespace scope if it is odr-used (3.2) in the program and the namespace scope definition shall not contain an initializer.”
<V-ille>    it still needs the definition
<Sausage>    Doesn’t a large amount of code rely on this for metaprogramming?
<V-ille>    rely on what?
<Sausage>    Well, I’ve never seen them declare their “static const int value = N * M;” outside of their 1 liner structs.
<V-ille>    well, they have to define it if they use it
<Sausage>    It almost sounds like an oversight in the standard
<V-ille>    so, rely on what?
<Sausage>    On not needing to define it.
<V-ille>    it sounds like people wanted the same rules to apply regardless of constness
<Sausage>    But not constexpr-ness, for sure.
<V-ille>    the thing is, a static const will _need_ the definition
<V-ille>    a static constexpr doesn’t, technically
<Feto>    hmmm
<Feto>    that’s completely backwards
<Feto>    what’s odr-used?
<V-ille>    no it is not
<V-ille>    One-Definition-Rule, it means that its name is mentioned in an evaluated context, if I remember correctly
<V-ille>    not sure about the evaluated
<Feto>    ah ok
<Sausage>    ODR shouldn’t even apply to constant expressions
<V-ille>    well, the standard says what odr-used means
<V-ille>    shouldn’t apply?
<V-ille>    wtf?
<Sausage>    Yes. You should be able to have constexpr variables with different values in different TUs since they should never have external linkage.
<V-ille>    that “shouldn’t apply” sounds like you want constexpr x = 0; constexpr x = 5; to be valid :P
<Sausage>    No, just foo.c: constepr x = 0;  bar.c: constexpr x = 5;
<V-ille>    just use different namespace or make them static?
<Cecen>    shared_from_this() can’t be used in a constructor, can it?
<Sausage>    No :(
<V-ille>    duh
<V-ille>    I just realized something
<V-ille>    a static constexpr member can be an instance of a literal class type..
<Feto>    odr would mean the opposite of what they want me to do
<V-ille>    so allowing avoiding the definition would make class types different from non-class types
<Sausage>    “A variable whose name appears as a potentially-evaluated expression is odr-used unless it is an object that satisfies the requirements for appearing in a constant expression”
<Feto>    I think struct S { static int x = 5; }; int S::x; violates odr
<Sausage>    Doesn’t that make every use of a constexpr variable not an odr-use?
<Sausage>    Therefore making the final sentence of 9.4.2/3 not apply to 9.4.2/3 at all? XD
<V-ille>    Feto: why on earth would that violate odr?
<Sausage>    (9.4.2/3 only refers to constexpr and ye olde constexpr emulation via static const integrals)
<Feto>    you’re defining it inline, and then you’re providing an out-of-line definition.
<V-ille>    no
<V-ille>    the out-of-line is the only definition
<Sausage>    It’s a declaration which is allowed an initializer which the definition steals.
<Feto>    when I’m providing the value in the inline declaration, I’m turning it into a definition, right?
<Sausage>    Looks like without a definition there’s no linkage for static constexpr members
<Sausage>    Then again, a simplified example compiles fine on geordi. Can you redude the testcase?
<V-ille>    simplified?
<Sausage>    { foo<> x; cout << x.x; } template <class T = int> struct foo { static constexpr T x = T(); };
<geordi>    0
<Feto>    correct
<Feto>    I tried that and threw me off even more
<V-ille>    puzzling
<Sausage>    It’s just a gcc bug. The guy who closed it is stupid.
<V-ille>    he’s a library person
<Feto>    that’s what *I* think
<Feto>    but who am I :)
<V-ille>    namely, the maintainer of libstdc++
<Feto>    is he an authority in the language?
<Sausage>    { foo<> x; cout << x.x; } template <class T = int> struct foo { std::pair<T, T> p; static constexpr T x = T(); foo(const std::pair<T, T>& p = std::make_pair(x, x)) : p(p) {} };
<geordi>    error: undefined reference to ‘foo<int>::x’
<V-ille>    I wouldn’t exactly call him stupid, but.. the standardese quoted states clearly that a definition is required
<Sausage>    No it doesn’t.
<l_r>    are there any portable implementations (boost?) of coroutine helper libraries?
<V-ille>    It says “the member shall still be defined”
<Sausage>    odr-use: “[...] unless it is an object that satisfies the requirements for appearing in a constant expression”
<V-ille>    ah
<V-ille>    ok
<Sausage>    Using constexpr members in the constructor is giving all kinds of weird errors
<Sausage>    Oh nevermind. I just suck at default argument I think :P
<Sausage>    Can only make it happen with std::pair
<V-ille>    odr-used says ” unless it is an object that satisfies the requirements for appearing in a constant expression (5.19) and the lvalue-to-rvalue conversion (4.1) is immediately applied. ”
<V-ille>    the question is, is an lvalue-to-rvalue conversion immediately applied?
<V-ille>    I suppose yes
<Sausage>    Apparently my brain missed that part :P
<Sausage>    What is an lvalue-to-rvalue conversion and why does std::pair’s constructor trigger it?
<Sausage>    I assume that’s a fancy way of describing the translation from variable/object to value
<Nik05>    yes Sausage…
<V-ille>    uh huh
<V-ille>    “The definition is needed (i.e. storage is required) if the object’s address is taken, either explicitly or implicitly as argument to a function expecting a (const) reference — the latter being quite common in idiomatic C++.”
<Sausage>    Beat me to it :P
<Sausage>    Hence why it’s accepted in initializer lists
<Sausage>    So Feto’s solution is to use initializer lists to initialize his pair ;P
<Sausage>    Hmm, that doesn’t work either :(
<Feto>    =(
<Sausage>    Since my version of gcc apparently accepts it, I wonder what this will print…
<Sausage>    { foo<> x; cout << x.x; } int ltor(int&& x) { cout << &x; return x; } template <class T = int> struct foo { static constexpr T x = T(2); int a; foo(int a = ltor(x)) : a(a) { } };
<geordi>    error: invalid initialization of reference of type ‘int&&’ from expression of type ‘const int’
<Sausage>    oops
<Sausage>    { foo<> x; cout << x.x; } int ltor(const int& x) { cout << &x; return x; } template <class T = int> struct foo { static constexpr T x = T(2); int a; foo(int a = ltor(x)) : a(a) { } };
<geordi>    error: undefined reference to ‘foo<int>::x’
<Feto>    thanks for the discussion.. I got to leave for a couple a hours
<V-ille>    so far it looks like the definition is needed in some cases, but not in others :P
<Sausage>    Seems it doesn’t work after all ;P
<Sausage>    Maybe std::pair changed in those few months
<Sausage>    So it’s just a gaping hole in the type system, of course.
<V-ille>    Sausage: well, you took the address of it
<V-ille>    when passing it to ltor()
<V-ille>    then it starts requiring storage
<Sausage>    Well to be fair I shouldn’t be allowed to convert a constant expression to a const reference so easily :P
<V-ille>    in the simple case nothing required storage
<EwIck>    grr… why does googling “C++11″ with any other keyword yields results about guns and 9/11
<Sausage>    It works with a constexpr ltor function
<Sausage>    Note to self: Be extra careful with constant expressions :P
<PaulBird>    how do i get/install c++11?
<V-ille>    well, yes, because a constexpr ltor doesn’t really take the address even though it’s using a reference parameter
<melba>    get a recent compiler paul
<V-ille>    the reference vanishes
<V-ille>    so, the “stupid” Paolo happens to be completely correct
<V-ille>    he’s not exactly a newbie in core language either, you know ;)
<PaulBird>    gcc4.6 is what i’d need, correct? thanks btw
<Sausage>    Psh, a fluke >_>
<V-ille>    gcc 4.7 has even more c++11 support implemented
<V-ille>    it has override controls and nsdmi, for instance
<V-ille>    hopefully soon delegating constructors and user-defined literals as well
<PaulBird>    @V-ille: thanks, i’ll look for gcc47 :)
<V-ille>    alias templates and inheriting constructors are about the only things missing
<PaulBird>    do most of you use c++11?
<V-ille>    PaulBird: you need to compile it yourself or find a snapshot, it’s not released
<Sausage>    Alias templates plz :>
<Sausage>    MPL needs to be rewritten once variadic templates and alias templates are ready
<Sausage>    apply<pair, pop_back<tuple<int, int, float>>> p; ^_^
<V-ille>    hmm
<V-ille>    even that example should work if the pair ctor is constexpr, I suppose
<Sausage>    It would work if we were taking things by copy instead of by reference all the time too >_>
<Sausage>    Only the default ctor of pair is constexpr, though.
<V-ille>    well, even if you take by reference, a constexpr function just gets rid of the references when doing substitution
<Sausage>    There’s no way to constexpr overload in C++, hence the “gaping hole” I was talking about :P
<V-ille>    so far there’s been no need to constexpr overload
<Sausage>    I’d call this a pretty simple need
<V-ille>    “this”?
<Sausage>    Initializing a pair.
<V-ille>    well, just make the two-param constructor constexpr
<V-ille>    if you pass it runtime-values, it’s not a constant expression
<Sausage>    But what about non constexpr initializers then?
<V-ille>    it just works
<Sausage>    So pair(const T1& x, const T2& y); should be constexpr and both would work with no issues?
<V-ille>    yes
<Sausage>    Doesn’t seem like the general solution though
<V-ille>    why not?
<Sausage>    Because constexpr functions suck :P
<V-ille>    uh huh
<Nik05>    guys if gcc says:
<Nik05>    foo.cc:22:101: error: blaat
<Nik05>    what does the 22:101 mean?>
<V-ille>    line 22, column 101
<Nik05>    column 101… what…?
<V-ille>    what what?
<Nik05>    and line 22 is that from top of file or from top of function?
<Nik05>    101 looks alot…
<Nik05>    :p
<V-ille>    from the top of file of course
<Sausage>    Or the last #line directive :D
<V-ille>    eww evil
<Sausage>    I’ve used it before to shorten error messages involving stupidly long absolute/relative paths in error messages.
<EwIck>    meh. nearly $400 for a PDF copy of the standard… really?
<V-ille>    yes, really
<Sausage>    $400 for a license to legally use what you read in it more like
<Sausage>    And presumably grant employees the same right
<V-ille>    oh, that $400 doesn’t give you any rights to use the contents in any way :)
<Sausage>    Sue Microsoft for implementing C++!
<V-ille>    they implement c++? That’s news.
<Sausage>    Oh wait… *trollface*
<V-ille>    indeed
<Sausage>    CLEVER. BASTARDS.
<Sausage>    I have a new plot line for my movie :D
<V-ille>    some people drooled over the possibility of having “full c++11 support” in the newest msvc, and they failed to deliver rvalue references
<V-ille>    nice going, huh?
<Sausage>    Well I don’t trust references anymore :(
<V-ille>    talk about heightened expectations
<Arafangion>    At least they’re not apple.
<Arafangion>    Nobody has sold their kidneys for MS.
<V-ille>    hard to say
<Arafangion>    Souls perhaps, but not kidneys, surely?
<melba>    ms has many governments in their pocket with nonsense contracts Arafangion
<melba>    thx to clueless politicians
<EwIck>    failed to deliver rvalue references?
*    Arafangion considers writing a new string class.
*    Sausage considers writing a new pair class :P
<melba>    would it have a socket interface
<V-ille>    oh fuck, I remembered it wrong. They failed to deliver variadic templates. :)
<EwIck>    there we go.
<Sausage>    To be fair gcc isn’t doing so well there either :P
<V-ille>    well, 4.7 supports unpacking variadics to fixed now
<V-ille>    so it’s actually doing pretty well
<Arafangion>    melba: No, but it would provide a common interface to either NSString or System::String depending on the compiler used. ;)
<Sausage>    I really can’t see why that would be so difficult :P
<EwIck>    to be even more fair, MS *had* to ship VS2010, so it’s missing a lot of stuff
<Arafangion>    I prefer llvm these days.
<EwIck>    but vNext doesn’t look to improve much.
<V-ille>    yep
<V-ille>    they “had” to ship that too
<V-ille>    so now they have some god-awful work-around in their library for the lack of variadic templates
<V-ille>    they claim their library is complete
<Sausage>    Who, boost? *trollface*
<V-ille>    no, microsoft
<V-ille>    boost does no workarounds, it’s the epitome of elegance
<Arafangion>    I wasn’t aware that MS people used that functionality.
<Sausage>    Just ignore the massive programatically generated templates with 500 parameters…
<EwIck>    I don’t actually need variadic templates except to play with them
<Arafangion>    Do we have regular variadic functions?
<V-ille>    and just ignore the fact that you can’t use them yourself
<V-ille>    Arafangion: like int printff(char* fmt, …) ? :)
<V-ille>    -f
<Arafangion>    V-ille: *shudder* – no.
<V-ille>    well, that’s a “regular” variadic function
<Arafangion>    I don’t mean VAR_ARGS.
<Arafangion>    I mean “regular”, as in, “Not a template”.
<Sausage>    So scary it needs capital letters
<V-ille>    oh, would you like something like int… ?
<Arafangion>    ville: Yes, I would like to be able to define a function that takes many arguments.
<Arafangion>    ville: And yet be type safe.
<Sausage>    So a template.
<V-ille>    then you need it to be a template
<Sausage>    The other side is passing a vector of abstract base classes.
<V-ille>    “other side”?
<Sausage>    The dynamic side :P
<V-ille>    I have no idea how that’s related
<Sausage>    Because it’s the dynamic counterpart to a variadic function?
<V-ille>    well, since vector is homogeneous, no it isn’t
<V-ille>    passing a tuple might be closer
<Sausage>    But a tuple is a template XD
<V-ille>    but, then again, that’s not dynamic-length :)
<V-ille>    so is vector
<Sausage>    But it’s a known type of a vector
<tLt>    to get type checking at runtime you can use tagged values/ptrs
<V-ille>    vector<any> might work
<Sausage>    If you were using a tuple I assumed you were going to need to capture tuple<Args…>
<Arafangion>    Hmm, I should look into variadic templates, then.
<V-ille>    tuple is a “known type of tuple” too
<Sausage>    Then you may as well use no tuple
<V-ille>    so, vector<any>
<V-ille>    or vector<variant>
<number_number>    ok, so my code has a pretty obvious problem, I want my ctrl-c to close my file and save all the data written to it before the ctrl-c, but the filename isn’t known within my function, can I pass it through to the function, or am I missing much simpler method?
<Sausage>    If there were those whatchamacallits that let you do reverse virtual functions then vector<Object> could work
<number_number>    sorry, the code: http://ideone.com/w4yAA
<V-ille>    “reverse virtual functions”, mmkay
<Sausage>    Ya… something-methods ;-;
<tLt>    aha, a gizmo!
<Arafangion>    number_number: You need to write a manager that can save the data and close, which can then be run from the interrupt handler.
<V-ille>    number_number: one option would be to make myfile global
<Sausage>    multi-method!
<tLt>    or atleast a reference / handle / fd
<pseudonymous>    I am linking a c library (that I’ve made) to a c++ program, it uses setjmp/longjmp and works fine when compiling the code in pure C – but calling the same instructions from a C++ program results in a bus error (basically invalid alignment for the instruction?) any tips ?
<tLt>    pseudonymous: whats the actual debugger output?
<V-ille>    there’s very little “reverse” in multi-methods
<tLt>    and what architecture? (x86 has no hard alignment requirements)
<Arafangion>    pseudonymous: Don’t allow the setjmp/longjump to escape the confines of that C program.
<Sausage>    The relationship is reversed
<V-ille>    not as far as I can see
<Arafangion>    pseudonymous: Likewise, don’t allow C++ exceptions to escape the confines of the C++ program.
<Sausage>    The decision is taken away from the classes and given to the algorithms, like dynamic templates.
<pseudonymous>    Araganion: not even if it’s still contained inside a function written inside a ‘extern “C” { …. }’ block ?
<Sausage>    You’re not limited to what Object can do, you’re limited to what can interpret different Objects
<V-ille>    well, ok, I suppose that’s one way to see it
<V-ille>    but I wouldn’t call it “reverse” by any measure
<tLt>    setjmp/longjmp should work as long as its not mixed with vanilla exception handlers
<V-ille>    exceptions fly just fine c++->c->c++
<pseudonymous>    tLt: that’s probably where it gets hairy ;) My only reason for using C++ at all in this context is a unit testing library I’m using (cpputest)
<Sausage>    Assuming the compilers are compatible
<tLt>    V-ille: i suspect the internal state of the runtime exception handler code can get confused
<Arafangion>    V-ille: As long as you have C++ on *both* sides of that C layer, and as long as nothing confuses it.
<V-ille>    longjmp’ing past cleanup is UB
<number_number>    V-ille: cool, works perfectly with the global variable, I kinda thought the global variables were bad practice in general no?
<tLt>    on *ix signals might be better
<V-ille>    number_number: that’s correct, but since there’s just no way to convey custom data into a signal handler, there’s very little you can do
<V-ille>    I suppose making just a pointer to myfile global would be a less-ugly solution
<Arafangion>    pseudonymous: Consider a C unit testing framework instead if that’s the only reason you’re using C++.
<V-ille>    or just setjmp properly :P
<number_number>    V-ille: anything that works != ugly in this case :D , thanks!
<tLt>    i am working with a large C++ codebase that uses setjmp/longjmp :P
<pseudonymous>    Arafangion: I was for a while, but what I found was that CppUTest had actual, semi up to date documentation and that’s kind of what settled it. But I was fearful of something just like *this* happening
<Arafangion>    tLt: Why? :)
<V-ille>    I used to work on such codebases. The scars last a lifetime.
<tLt>    Arafangion: custom exception handling foobar
<V-ille>    yep
<Arafangion>    tLt: Ala SEH?
<V-ille>    ala hysterical raisins from pre-standard times
<tLt>    SEH is language indepedent, provided by the OS, and the standard way to implement try/catch/etc on win :P
<Arafangion>    tLt: I mean, you can resume from the point of the throw?
<pseudonymous>    Hehe, that’s sort of what I’m testing right now, actually. But it’s something called CSEH in my case (http://www.freetype.org/david/reliable-c.html)
<tLt>    (i suspect that the requirement to work across like 10 platforms and accompanying compilers from Dante’s Inferno plays a role as well)
<tLt>    Arafangion: no vanilla c++ exceptions used in the code
<tLt>    and no external libraries so nothing else that will throw
<V-ille>    pseudonymous: I ran screaming when I saw the CS part
<V-ille>    yuck yuck yuck
<tLt>    i ran screaming when i saw the EH part :D
<tLt>    IMHO exceptions should ALWAYS be fatal
<pseudonymous>    V-ille: ?? Don’t know what you refer to ? But it seems rather neat to me, it’s what Nokia used to do on symbian phones back when C++ vanilla exceptions were too costly
<tLt>    otherwise its like the joy of GOTO combined with the joy of concurrency
<V-ille>    I said the scars last a lifetime, don’t open my wounds, pseudonymous
<melba>    story time?
<pseudonymous>    yes, please :P
<Arafangion>    tLt: I used to disagree with your standpoint.
<tLt>    pseudonymous: on *ix you already have exceptions .. they are called signals
<V-ille>    symbian, the greatest invention ever.. ..for shrinks
<Arafangion>    tLt: Then I found out just how frequently exceptions are overused. :(
<V-ille>    what does it mean for an exception to be “fatal”?
<Arafangion>    pseudonymous: C++ itself can do the CSEH thing, cleanly, without hacks, and without the runtime penalty unless an exception actually occurs.
<melba>    it means it should crash the plane
<Sausage>    That it calls std::terminate without unwinding the stack >:D
*    tLt just got a great horrible idea
<pseudonymous>    tLt: I don’t quite follow ? What I aim to use this CSEH thing for is basically to shorten some C code such that not every function call is followed by an “if (something went wrong) {…..}” block
<Sausage>    > C++’s default behaviour
<tLt>    userland threading implemented using … C++ exceptions !
<tLt>    *evil grin*
<Arafangion>    tLt: I think that’s been done.
<pseudonymous>    Arafangion: well, yea :) But the only reason I went to #C++ is because my troubles are with calling the C code from within a C++ program (due to the unit testing framework being C++) – If I were writing a C++ program, I’d do things differently, but I prefer C on the whole :)
<tLt>    pseudonymous: void whoops(int sig) { if (sig == SIGUSR1) fprintf(stderr, “Moooom, I made an exception! Change me!\n”); } … signal(SIGUSR1, whoops); … raise(SIGUSR1);
<DrinkMachine>    Userland just makes me think of Requiem for a Dream. It’s a pretty weird concept for a beginner.
<Arafangion>    pseudonymous: Enjoy.
*    Arafangion goes off to work.
<pseudonymous>    Arafangion: hehe yea yea, thanks though :)
<pseudonymous>    tLt: interesting(!) I’ll have to look into that some other time at the least
<Sausage>    Standard library functions in a signal handler? Good luck.
<Sausage>    Actually, I think it’s allowed :P
<Sausage>    Nevermind, double checked C99 :P
<tLt>    i promise you that signal handlers dont require pure asm code :P
<pseudonymous>    but they’d be using the kernel right ? system calls then ? which means bad performance :(
<tLt>    i am very curious how you would do ANYTHING without using system calls
<Sausage>    You can modify sig_atomic_t objects.
<Sausage>    That means you can set a flag when you recieve SIGTERM and handle it later on in your program to exit cleanly
<tLt>    iopl(3) + mmap() /dev/mem, and then bitbang the hardware?
<Sausage>    Pretty exception systems in C using macros and longjmp work okay, they usually rely on globally unique exception IDs though.
<tLt>    http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html [parental advisory: contains explicit macros]
<pseudonymous>    tLt: maybe I’m using the wrong term here – admittedly a while since I opened the book I’m drawing on but what I mean is any call where your process is halted and some magic happens to allow the kernel to execute some code for you before your process resumes. Most IPC-schemes use that, which is why something like shared-memory is infinitely faster
<tLt>    pseudonymous: context switches has to happen anyways …
<tLt>    sooner or later
<tLt>    and any dramatic change in flow like that is likely to end up faulting in pages anyways
<tLt>    plus if multithreaded you will likely need the exception handler to be a critical section, which may or may not involve a syscall and may or may not cause other threads to wait on spinlocks
<tLt>    etc etc
<tLt>    at the very least all levels of cache are gonna get invalidated + branch prediction and call stack go away
<V-ille>    !focus
<nolyc>    ##C++ focuses on C++. Discuss offtopic things elsewhere.
<Jay8>    nolyc: that’s a lie
<Jay8>    ##c++ focuses on ponies
<tLt>    we dont have topics, we have PUPPIES! PUUUPPIEEEES!!!
<Jay8>    ^
<tomalak>    just … wow
*    TomyLobo2 is now known as TomyLobo
<melba>    { f();} void f () { return throw “1″; }    // i guess this never returns right? because it evaluates the throw first
<geordi>    terminated by exception: 1
<melba>    or is it ub
<codd>    I’ve got two cpp a.cpp and b.cpp. I need to create a simple makefile that compiles them both so that I get executables ( ./a , ./b). When I use the following snippet ( http://pastebin.com/850StMZT ), it only compiles the first. Can someone tell me what is wrong?
<RePaste>    codd: The paste 850StMZT has been moved to http://ideone.com/Uw4s8 (see http://tinyurl.com/yv88ul for why)
<tLt>    codd: make compiles the first target in the file
<tLt>    so you normally start with an ‘all’ target that lists the final executable(s) as deps
<Billiard>    codd: ##workingset
<codd>    tLt, is there a way for me to add an all: line to the top for it to work? all: a b does not work
<V-ille>    melba: I don’t think there’s anything ub about that
<V-ille>    it just throws, and never gets to returning
<melba>    thanks
<V-ille>    melba: that allows writing mystical shit like void g() {} void f(int x) {return x ? throw 1 : g();} int main() {f(0);}
<V-ille>    or even more mystical shit like constexpr int g() {return 0;} constexpr int f(int x) {return x ? throw 1 : g();} int main() {constexpr int foo = f(0);}
<SanbarComputing>    What is the best real-world website, tuturoial or book for learning pragmatic, efficient and helpful OO design and implementation techniques for a medium-sized to large project for C++?
<goddard>    SanbarComputing: I would say it is a collection of sources really
<melba>    V-ille, at least it gives an error for f(1)
<SanbarComputing>    goddard:  To give you some background, I have been programming with C++ for some years, but do not feel I have really spent the proper time with pedagogical sources to really learn the best way to use it or really familiarize myself with the language itself, it capabilities (to be able to best choose those that fit a particular need) and basic OO design, analysis, implementation, test, etc. techniques.  Is there a good website that lists
<roxfan>    irc is not a forum/maillist, don’t cram a whole post in one line
<roxfan>    it cut off at “…website that lists”
<Billiard>    roxfan: better than multiple lines
<SanbarComputing>    For instance, I have heard C++: How to program is good, but would be really interested in it if it couched learning the language in terms of learning proper OO design and implemntation techniques while learning the language
<SanbarComputing>    Sorry:  Is there a good website that lists the collection of sources well, or can you give me a starting point for some of them at least?
<goddard>    SanbarComputing: I think your are looking for something very specific and only you will find it by searching for it anything you find here will likely just be chatter
<pseudonymous>    SanbarComputing: you probably have more experience than me with C++ – But for in-depth language details, Stroustrup’s own book isn’t bad – as for OO design, that’s almost language-agnostic, books like the Gang of Four (GoF) on design patterns may provide inspiration
<SanbarComputing>    goddard:  Yes, thank you – I can see how that would be.  Very insightful.  Thank you.
<pseudonymous>    SanbarComputing: simpler than whole design patterns – you could look into a set of design recommendations. For instance, I was required to familiarise myself with the “Grasp Principles” during a course on OO-design
<pseudonymous>    Btw if it’s not too-offtopic with people – anyone here using C++11 then ? Thoughts ? (just wanted to hear what people think of it)
<NoorulIslaam>    just making sure here… im compiling C++ on a platform that does not have exception and rtti support by default. if i have virtual or pure virtual methods in my classes, does that require me to turn on rtti? i do not use any try/throw/catch blocks
<Billiard>    NoorulIslaam: simply using virtual functions do not require rtti
<NoorulIslaam>    thanks
<snow_usa>    ok
<DynV>    I’m trying to practice recursive but I’m at a loss ; the problem which the give solution is 3 embedded for giving all the change that you can make with a dollar without pennies (quarters, dimes & nickles). What I came up with until now is http://dpaste.org/ht6BM/ This isn’t required for my course but if someone is curious about recursivity like me but have more experience, a tip would be…
<DynV>    …helpful. :)
<tLt>    is there some channel here that deals with non-language-specific data structure issues and such ?
<Zogatribe>    tLt: maybe formulate your question so the answer is specific to C++? :)
<tLt>    then the answer would be like “use the efficient_search_algorithm() method in boost::non_existent::ring_buffer” :D
<ville>    !otherchannels
<nolyc>    ##c++-basic, ##c++-general, ##c++-social and ##iso-c++
<Jay8>    #geordi is kind of one
<o]>    do you have a crash course on enable_if? :(
<Billiard>    boost website tutorials?
*    newbie is now known as Guest55643
*    Stryyker2 is now known as Stryyker
<V-ille>    how about http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/enable-if
<JordiGH>    {vector<int> v; cout << int(1)/int(v.size());} // Why does geordi say this is a floating point exception? I see no floating points.
<geordi>    Floating point exception
<BlastHardcheese>    JordiGH: what if v.size() is 0
<JordiGH>    v.size() *is* 0.
<JordiGH>    I just want to know what does floating point have to do with it.
<BlastHardcheese>    what happens when you divide by zero
<JordiGH>    What does this have to do with floating points?
<ville>    ub
<JordiGH>    There is no floating point anywhere.
<JordiGH>    Oh, so it’s just plain UB?
<JordiGH>    Zero division by ints is zero?
<BlastHardcheese>    division by zero is a fatal error
<JordiGH>    It’s not UB for floats if std::numeric_limits<double>isiec754() is true.
<JordiGH>    BlastHardcheese: Only for ints. It should not be an exception for doubles.
<JordiGH>    {vector<int> v; cout << int(1)/double(v.size());} //Just plain inf
<geordi>    inf
<JordiGH>    But is that a geordism? “Floating point exception”?
<peterolen>    no, I can get FPE in my own programs sometimes
<JordiGH>    peterolen: If you specifically enable it, right?
<JordiGH>    Oh, wait, you mean, for integer division?
<peterolen>    yes integer division
*    JordiGH doesn’t get how that can make sense.
<JordiGH>    Why floating point?
<peterolen>    no idea. It doesn’t make sense
<tLt>    its simply what happened to be used as the signal
<tLt>    cmpare eg SIGSEGV thats used regardless of whether the CPU even supports segments
<JordiGH>    Is it a Unix signal?
<JordiGH>    FPE?
<tLt>    yay
<JordiGH>    Ah.
<JordiGH>    Okay, that makes sense.
<peterolen>    JordiGH: I just made a my own abbreviation of Floating Point Exception
<tLt>    there is actually an exception (well, interrupt) specifically for divison by zero on x86 though !
<JordiGH>    Not FPE?
<tLt>    i suppose its because x86 didnt originally have a builtin fpu
<tLt>    actual behaviour on actual fpu exceptions is configurable – doesnt have to cause an actual interrupt but instead set a flag … there are other funny ones as well .. like arithmetic overflow (triggered by INTO), array bounds exception (same, BOUND) and alignment error (there’s a flag to enable alignment enforcement) :)
*    invariable is now known as variable
*    Guest55643 is now known as Daditos
<Feto>    ok back
<orbitz>    thankg od
<Feto>    :P
<Feto>    my vm got almost unbearably slow when I installed the vmware tools :(
<Feto>    maybe if I reduce the number of cpus and reboot….
<Feto>    ok back :)
<Feto>    wow… kdeinit4 is taking 636MB, kwin 412M and chrome has two processes taking 918 each wtf!?
<Feto>    that’s 3G already =/
<o]>    your computer is crazy
<Feto>    I think I’ll just g o back to wmaker now =\
<peterolen>    Feto: the two chrome processes probably share the same memory
<JordiGH>    Huh, Chrome uses shared memory?
<JordiGH>    Wasn’t that the whole point of “separate processes, no race conditions!” marketing thing?
<orbitz>    i don’t remmeber race conditions being in the marketing
<orbitz>    i remember separate processes, one crashing doesn’t kill the whoel browser, in their markting
<JordiGH>    Well, I guess the marketing was, “one page crashes, only one tab crashes!”
<JordiGH>    Is it truly impossible to accurately measure memory usage?
<orbitz>    JordiGH: what do you mean?
<orbitz>    JordiGH: in what context?
<JordiGH>    I don’t know, it’s like you don’t know which processes are sharing a library or sometimes using shared memory.
<orbitz>    Oh yes
<orbitz>    i tis challenging
<orbitz>    It must be accessible in some way thouhg
<o]>    hmm enable_if is used only on overload resolution?
<Feto>    ok back again :)
<TheBlunderbuss>    <– C++ newbie here.  Been using Linux for 6 years. Bash helped tie programs together. Now I want to tweak the programs :)
<Feto>    top
<JordiGH>    TheBlunderbuss: This channel isn’t very friendy to newbies…
<EwIck>    struct A { std::unique_ptr<B> my_b; };    // will ‘A’ have compiler-generated move semantics in standard C++11? (doesn’t in vs2010)
<Feto>    it probably should
<EwIck>    I was looking for more than just probably
<Feto>    and more than just should? :)
<EwIck>    actually, precisely either ‘yes’ or ‘no’ would make my day
<sig->    can you, like, try and see, and then tell us too?
<EwIck>    I don’t have a working C++11 compiler.
<sig->    you could write a small snippet that, when executed, says “yes” or “no”, and put it into http://ideone.com/
<peterolen>    I’m not sure about anything anymore
<sig->    not sure if they have the most recent C++11 compiler either, though  /:  there is a C++0x option
<Arafangion>    JordiGH: Understatement much? ;)
<EwIck>    I could, but there being an option for “C++0x” tells me it may not include the changes in move semantics they made late in the process
<Arafangion>    TheBlunderbuss: I think the channel is friendly to newbies who want to learn…  But…  They rarely give tutorials and we generally expect them to at least learn the basics from good books.
<peterolen>    you can use geordi if you want more recent version
<Arafangion>    What compiler is geordi?
<chattaboxa>    ?
<Arafangion>    llvm-based or gcc-based?
<chattaboxa>    GCC
<Arafangion>    Neat.
<EwIck>    oh right, geordi
<Arafangion>    Why wouldn’t you just… install a more recent version?
<chattaboxa>    What?
<peterolen>    geordi: -v
<geordi>    g++ (GCC) 4.7.0 20110929 (experimental)
<EwIck>    because I don’t have any version to begin with. using geordi is quicker.
<EwIck>    I’m a visual studio whore
<Chattaboxa>    ah back
<TheBlunderbuss>    Arafangion: I don’t expect to be hand-fed. I’m getting started with a copy of  “C++ for Dummies”
<Chattaboxa>    was so happy when i compiled eggdrop for ios :)
<Arafangion>    TheBlunderbuss: Just don’t ever recommend that book.
<Arafangion>    TheBlunderbuss: Considerr burning it. :)
<EwIck>    for the record, the answer was ‘yes’.
<Feto>    I’m only using about 300MB now :D
<Feto>    kewl
<Feto>    stupid KDE, never using it again!! =/
<EwIck>    I’m using 2GB, and I’m still running windows 7 regardless. Awesomeness requires memory.
<Feto>    haha yeah but I’m on a vm :P
<Feto>    wait
<Feto>    did you just called windorks awesome?? =/
<EwIck>    No, I called windows awesome.
<Feto>    =(
<Terminus>    there was a time i thought 2GB RAM was more than i’d ever need. =(
<ArchGT>    Feto: you mean winsucks
<EwIck>    it is a dreamland for both the user and the developer.
<Feto>    there was a time I was psyched because my pc had 1 full meg, instead of the 640K everybody else had
<Feto>    :)
<medgno>    Feto: but I thought 640K was enough for everyone
<Feto>    should’ve been :”)
<EwIck>    hmm, 640K for everyone that means… 1.0966666e-4 byte per human being
<Terminus>    Feto: any nostalgia for 20-bit memory addresses as well? =D
<Terminus>    the whole segment:offset thing gave me brain damage for a few years.
<Feto>    yeah, the A20-line gate culprit :)
<Terminus>    which persists to this day. lol
<Feto>    we have to thank ibm+intel for the neverending fun :)
<Terminus>    at least we’re starting to get EFI now. hehe
<Feto>    is that a standard?
<Terminus>    dunno. if it’s not an official standard, then most likely a defacto one. apple uses it, asus is starting to produce mobos with it. i don’t see anybody else veering away from that direction.
<coppro>    win 14
<Feto>    so, most mobos don’t right now?
<Feto>    only some of the new ones coming out?
<Terminus>    Feto: yeah, just some of them.
<Feto>    ok
<Feto>    I need to read about it
<Terminus>    i think the mobos from asus that support EFI that i’ve seen are only AMD mobos.
<Feto>    that’s cool
<Feto>    I’ll probably have to by an amd mobo next time I upgrade
<Feto>    I did upgrade this year around march-may though
<Feto>    so probably by the time I upgrade again in ’13 it’ll be commonplace
<Terminus>    heh, i was wrong. the intel mobos from asus also use EFI now.
<Feto>    cool
<Feto>    I like asus… that’s what I’m using :)
<Terminus>    i’m still holding out for ivy bridge. my athlon x2 ought to last till next year.
<Feto>    what’s ivy bridge?
<Feto>    athlon x2?
<Feto>    what is it? 6 yo?
<Terminus>    intel’s next generation. 22nm manufacturing process, among other improvements.
<Terminus>    my athlon x2 is close to 5 years old now i think. i’m itching to upgrade it coz the gtx 570 on it is being bottlenecked.
<Feto>    and you’re going for intel…?
<Terminus>    yep. intel wins on performance right now. even on a budget, i might go intel instead of amd.
<Feto>    psch
<Feto>    I’m sure you’ll change your mind next year, when it’s time to hit the shelves
<Feto>    (or the newegg :P )
<Terminus>    MOV operations can now take place in the register renaming stage instead of making it occupy an execution port. The x86 MOV instruction simply copies the contents of a register into another register. In Ivy Bridge MOVs are executed by simply pointing one register at the location of the destination register. This is enabled by the physical register file first introduced in Sandy Bridge, in addition to a whole lot of clever logic within IVB. Although MOVs st
<Terminus>    that is one reason why i’m excited about it. also, there’s the new RNG on it.
<Feto>    doesn’t amd have register renaming since like 98?
<Terminus>    really? hmmm… didn’t know that.
<Terminus>    in any case, the die shrink is still worth quite a bit. as long as i keep my upgrade next year within $500, i’m happy.
<Feto>    cool
<Feto>    well, I got a pretty heavy system right now, so no upgrades in sight for at least the next couple of years :)
<Feto>    which is a pitty, coz that means no efi for me for a while :(
<Feto>    I can use BOCHS though… there must be an efi module for BOCHS, right?
<tLt>    Feto: more like 96 if you count the ancestor of K6 (nexgen 586)
<Terminus>    once i upgrade, my current box becomes my new server. old server gave up early this year.
<Terminus>    anyway, lunchtime.
<Feto>    tLt: I was going to say 96, really, but then I thought K6 was the first to have it
<tLt>    K5 didnt
<Feto>    5×86 did?
<tLt>    5×86 == Cyrix
<Feto>    amd, right?
<tLt>    cyrix is cyrix, amd is amd
<Feto>    hahah yeah but isn’t the 5×86 amd?
<tLt>    no its cyrix
<tLt>    AMD K5 was a classic x86 chip
<Feto>    http://en.wikipedia.org/wiki/Am5x86
<Feto>    I did have one of those installed in that beautiful year of 1996 :)
<tLt>    Nexgen 586 was the first “I can’t belive it’s not x86 chip!”
<Feto>    this is a 486 chip that everybody I knew was calling a 586
<Feto>    it’s a 486 chip with a 5x bus multiplier
<tLt>    AMD bought Nexgen as they were working on the ‘nexgen 686′
<tLt>    and this is what became AMD K6
<tLt>    this microarchitecture was called RISC86
<Feto>    so amd bought the company and released the cpu?
<Feto>    ah yeah I remember that
<tLt>    basically, before the k6 amd was a third-rate el cheapo x86 clone peddler
<Feto>    and they also hired an Alpha guy
<tLt>    while nexgen was a small company with tiny resources and were something like 10 years behind schedule
<tLt>    intels equivalent microarchitecture switch happened with the ppro and pII
<Feto>    yeah I remember selling a couple pentium and pentium mmx systems
<Feto>    they were carp :P
<chattaboxa>    Yummy
<yuriks>    http://ideone.com/3RcNw
<yuriks>    is this not how you use enable_if?
<tLt>    the big difference 486 => pentium apart from clock speed was that pentium could execute two instructions concurrently
<tLt>    (U and V pipe)
<Feto>    but K5 and K6 could do 4
<tLt>    K5 and K6 have exactly nothing in common :P
<tLt>    just like pentium and pII
<Feto>    I remember they were boasting these words all the time “4-way instruction fetch and 4-way superscalar”
<tLt>    yeah thats K6
<tLt>    RISC86 microarch
<Feto>    they do have the company who makes them in common :)
<Billiard>    yuriks: correct, not
<tLt>    both intel and amd have their own fabs
<Feto>    ah you’re probably right… that was k6
<tLt>    or ah .. misunderstood
<Billiard>    yuriks: you are looking for template specialization there, not enable_if
<yuriks>    Billiard: damn, time to bring up the macros again
<Billiard>    …
<Feto>    hahahah!!!
<Feto>    Billiard: that was a message well delivered :D
<tLt>    pentium can be most famously remembered for being the last x86 generation where you could predict the execution time per instruction
<Billiard>    yuriks: using template specializations would not require writing much more than you have there currently..
<yuriks>    Feto: seriously, I’m not copying this class 4 times and maintaining separate copies :P
<Billiard>    just specialize the constructor..
<yuriks>    Billiard: I need to copy the entire rest of the class on each specialization though
<Billiard>    no you don’t
<Feto>    tLt: that made performance prediction so easy… that’s why some ph.d. thesis (like my friend’s) right now are close to useless
<tLt>    and anyone who coded back then will remember pairing instructions for max parallellism (the V pipe could only handle a subset of instructions, and only if there wasnt any register dependencies)
<yuriks>    Billiard: hmm, elaborate
<tLt>    Feto: bwahahaa
<Feto>    carp!! really??
<Billiard>    yuriks: well in your case you don’t even need specialization, just cout << N, but i assume your real situation is not quite as simple
<Feto>    I thought they were both capable of executing the full instruction set
<tLt>    iirc V pipe only swallowed ALU instrs
<yuriks>    Billiard: yes, my real case is a rather larger class where most of it is the same, with 3 sets of special functions for N = 1, 2, 3 or 4
<Feto>    with close to 0.5 billion transistors…
<tLt>    but i went 486 => K6 personally so i never had to pay that much attention to it
<Feto>    I was cyrix twice, then amd since
<Billiard>    waiting for ideone to load…
<Feto>    cyrix 286->486, then amd 486->k5->k6->…
<Feto>    never owned an Intel
<Feto>    cyrix had this 486DLC which was pretty much a 486SX, except a bit slower :)
<Feto>    that’s what I had back in 93-96
<Billiard>    yuriks: http://ideone.com/ZDZrL
<yuriks>    whoa, I totally didn’t know you could do that. I thought you had to specialize the whole class.
<yuriks>    Billiard: hmm, what if the two specializations take different numbers of arguments?
<Feto>    and then, let their eyes be opened :)
<rageous>    How can I get gdb to redirect to an output file?
<Billiard>    yuriks: then you have to specialize the class afaik
<yuriks>    Billiard: bah
<Feto>    back to macros? :)
<yuriks>    it seems so :P
<Feto>    hahahahah :)
<yuriks>    or I can kludge it up and just stick static_asserts inside the functions I don’t want
<Feto>    or just call exit
<Feto>    :)
<yuriks>    well, that prevents me from calling invalid functions, but they still give me ambiguous overload errors sometimes
<yuriks>    argh
*    Olipro_ is now known as Guest77940
*    silverwind is now known as systemfault
*    JakeyChan_ is now known as JakeyChan
<k0nichiwa>    why doesn’t map or set have a version of find that accepts both an iterator position and the value you want ot find ?
<k0nichiwa>    if you frequenly do finds for values that are close together
<Billiard>    k0nichiwa: use std::find for that
<Billiard>    well, maybe that won’t work for all cases
<zjo>    can anyone explain whats wrong with the way im trying to read in data from a file and store it into a two dimensional array
<zjo>    http://pastebin.com/SBQmxp14
<RePaste>    zjo: The paste SBQmxp14 has been moved to http://ideone.com/96AEX (see http://tinyurl.com/yv88ul for why)
<Billiard>    !give zjo while eof
<Billiard>    !give zjo eof
<nolyc>    zjo: Using “while (!stream.eof()) {}” is almost certainly wrong. Use the stream’s state as the tested value instead: while (std::getline(stream, str)) {}. For further explanation see http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5
<zjo>    thanks for that, i know thats not why im getting array error though
<Billiard>    how do you know?
<Billiard>    you must know what is wrong then? :/
<zjo>    because i have other programs that use the same !infile.eof()
<zjo>    and it reads fine
<zjo>    but i didnt use arrays in those
<Billiard>    they are all wrong
<Billiard>    !give zjo testcase
<nolyc>    zjo: Paste your test case (tick the compile checkbox!) to http://ideone.com/ or http://codepad.org. Using a recommended paste site increases the chances someone will take a look at it. Do _not_ paste to the channel. See the testcase checklist at http://www.eelis.net/iso-c++/testcase.xhtml .
<Billiard>    read the checklist there ^
<yeaok>    i am not getting anywhere parsing this file using C
<yeaok>    maybe one of you might take a look and give me a fewpointers
<yeaok>    ?
<Billiard>    yeaok: this is a c++ channel
<zjo>    http://codepad.org/soX1JvQu
<Billiard>    !give zjo notatestcase
<nolyc>    zjo: Stop! A testcase must 1) be self-contained and 2) reproduce the problem. Don’t paste another link here until: I) you’ve pasted your testcase to codepad.org (or ideone.com if it needs input), II) the ‘run code’ box is checked, III) there are no irrelevant compile errors and IV) it reproduces the problem.
<zjo>    ignore the openGL errors
<zjo>    i dont get those errors on my system obviously because i have openGL libraries
<zjo>    im doing something wrong with line 70
<Billiard>    zjo: provide a testcase
<zjo>    left of ‘.x’ must have class/struct/union        type is ‘float’
<Billiard>    your first paste was closer to a testcase
<Billiard>    zjo: ill give you a hint though, ctrl+f point
<zjo>    meh no idea :/
<Billiard>    zjo: create a testcase and ill tell you exactly what is wrong, i want you to create a testcase because this should be part of your debugging procedure and you may find the issue by doing it
<zjo>    http://codepad.org/2xk4WlGw
<zjo>    like that?
<Billiard>    i suppose
<Billiard>    zjo: what type of array is “data” ?
<zjo>    float
<Billiard>    what does data[n][m] evaluate to?
<Billiard>    (same answer)
<zjo>    yeahfloat
<Billiard>    then does some_float.x make any sense?
<Billiard>    you meant for your data array to be a 2d array of “point”
<zjo>    so my array is of type point?
<Billiard>    that is what you wanted isn’t it..
<Billiard>    you aren’t even using point
<Billiard>    (my hint ctrl+f point, point is only mentioned once in the program)
<zjo>    point data[500][14] doesnt make much sense to me really
<Billiard>    thats not good
<zjo>    each line of my data file is 14 float numbers .. x1 y1 x2 y2 .. x7 y7
<zjo>    i just want to read them in as pairs of points
<zjo>    thats what im trying to do anyways
<Billiard>    do you understand you aren’t using your struct point at all currently?
<k0nichiwa>    just seems to me that if your finding a position close to a previous position <map> could take advantage of that
<k0nichiwa>    i didnt think std::find took an iterator for a previous “likely close” position
<zjo>    data = new point[n*m]
<zjo>    would that work?
<Billiard>    zjo: no, you don’t need new..
<Edisto>    can somene tell me where in my includes am i going wrong i keep getting errors saying some of my included files not included http://pastebin.com/pfUJ1bss
<RePaste>    Edisto: The paste pfUJ1bss has been moved to http://ideone.com/A7nPV (see http://tinyurl.com/yv88ul for why)
<Edisto>    i made it simpler so its not alot of code and just included the include code
<Billiard>    Edisto: you probably have circular references in your includes
<Billiard>    you can not have two headers include eachother directly or indirectly
<zjo>    I’m just tempted to not even store the data into an array then since i cant figure it out .. just do cin >> x1 >> y1 >> x2 >> y2 .. >> x7 >> y7
<zjo>    I guess that would work
<Billiard>    zjo: your program’s logic is equivalent to this one’s http://www.ideone.com/5twng
<Edisto>    i see thanks billiard
<zjo>    Billiard: so I should do point[n][m].x
<zjo>    i dont have point as an array
<Billiard>    zjo: i think you need a c++ book
<Billiard>    you do not understand how structs and arrays work
<Edisto>    hmmm…
<reko_t>    mmh!
<Edisto>    you can make a cpp file that has every file included in it then just have every file include that one right?
<reko_t>    well sounds like it should be a header, but yes
<reko_t>    although it’s not a very good idea
<reko_t>    unless those headers don’t change
<reko_t>    in which case you should look into precompiled headers in your compiler’s docs
<reko_t>    basically if you include a header in every cpp file, that means that whenever you edit that header, every single source file for your project must be recompiled
<reko_t>    which for larger projects can be quite fatal in terms of compile times
<k0nichiwa>    precompiled headers i think include all the headers into one file
<k0nichiwa>    or maybe its just the std lib type headers that get put into it
<Edisto>    hmmm… this isn’t working either this is lame
<Edisto>    I have 4 headers that #include “head.h” which has all the headers included and i include it in main.cpp but still i keep getting undefined errors
<Billiard>    !give Edisto undefined reference
<nolyc>    Edisto: Undefined reference is a linker error. It’s not a compile error. #includes don’t help. You did not define the thing in the error message, you forgot to link the file that defines it, you forgot to link to the library that defines it, or, if it’s a static library, you have the wrong order on the linker command line. Check which one. (Note that some linkers call it an unresolved external)
<Apple5>    hey guys
*    k0nichiwa thinks there should be more 24 hour coffee shops
<Apple5>    can i ask a question
<k0nichiwa>    dont ask to ask
<ccocoa>    why not
<genjix>    nope
<k0nichiwa>    just ask
<Billiard>    Apple5: don’t ask to ask, just ask (if it is a c++ question)
<Apple5>    ok so what would happen if i got a program to run that had errors in it
<Apple5>    would the computer just explode or something
<Billiard>    define errors
<Billiard>    yes, the computer would explode and it would kill many people
<V-ille>    yes, computers routinely explode
<genjix>    Apple5: yep it would overheat and set on fire
<Apple5>    missing a ; or an operator is wrong but it runs anyway
<genjix>    especially macs
<genjix>    because they have faulty batteries
<Billiard>    Apple5: depends on what wrong means
<Apple5>    well it was serious and than itd be converted into like 110101001
<Billiard>    if the program is still well defined it will function producing undesirable results
<Billiard>    if not, the program is allowed to asplode the computer
<Apple5>    is there a way i can do that to make it run an explode
<Billiard>    yes, but it is illigal and we don’t talk about it here
<Apple5>    ohk :p
<genjix>    yep
<genjix>    there are secret channels but they are unspoken of around these parts
<Apple5>    can you direct me to any of them
<genjix>    you need to know the right people.
<Billiard>    Apple5: try #c++-antisocial
<Apple5>    lol is only me there :)
<genjix>    occasionally there’s a user called ‘merdox’. i heard he has connections
<genjix>    only a low player, but he is connected right to the top
<Apple5>    yayy, i want to make a program that if anyone runs it it will overheat their processors and ignite the computers
<genjix>    i cant speak anymore of this. i have a wife and children.
<Apple5>    :o
<Billiard>    Apple5: perhaps you can watch “live free or die hard” for hints
<Apple5>    ive got another serious yet probably stupid at the same time question if anyone wants to help
<Billiard>    Apple5: I think the peopl at #c have no problems talking about how to make computers explode
<k0nichiwa>    objective C caches method calls so that, after the first invocation, they are 50 percent faster than a c++ virtual method invocation
<k0nichiwa>    why doesn’t c++ do something similar i wonder
<reko_t>    caches how?
<Billiard>    k0nichiwa: i doubt its faster, i’d like to see some tests, also, there is no reason a c++ compiler couldn’t cache a function pointer from a vtable for future calls
<k0nichiwa>    Billiard, from this data http://mikeash.com/pyblog/performance-comparisons-of-common-operations.html
<k0nichiwa>    reko_t, see the link
*    Maya-sama is now known as hackkitten
<Billiard>    k0nichiwa: all i see is objc is slower, not 50% faster with caching
<k0nichiwa>    to cache it it may have to store the lookup result with each instance
<k0nichiwa>    the virtual method call specifically Billiard
<k0nichiwa>    obj-c 0.9 nano-secons, c++ 1.4 nano-seconds
<Billiard>    call me when it becomes the bottleneck of the program
<Billiard>    and when the rest of the objc is faster than c++
*    genjix is now known as nerf
*    nerf is now known as genjix
<swine_>    hey, for some reason byte order is getting revered when i’m doing a memcpy to a data structure from an ifstream buffer
<swine_>    any idea why this could be happening ?
<swine_>    er, reversed
<reko_t>    !give swine_ test case
<swine_>    reko_t, is there a pastebin that you gusy use ?
<reko_t>    ideone.com
<Billiard>    swine_: avoid memcpy
<swine_>    Billiard, what should i use then ?
<Billiard>    use std::copy
<swine_>    http://ideone.com/l7djK
<swine_>    the byte order of this data structure is all messed up …
<swine_>    Billiard, how can i use copy for this ? i’m copying memory
<swine_>    i see magic = c0c0feca
<swine_>    instead of cafec0c0
<Billiard>    swine_: learn about endianess
<swine_>    Billiard, i know about endianness
<Billiard>    and std::copy can still be used
<swine_>    Billiard, the data should be little endian in both cases
<Billiard>    swine_: you need to know more then apparently
<swine_>    it’s coming from the filesystem
<swine_>    why the hell would endianness change ?
<Billiard>    we have no clue what you are doing
<Billiard>    where this data came from, etc
<swine_>    look at the code
<swine_>    i just pasted it
<swine_>    http://ideone.com/l7djK
<Billiard>    its reading a nonexistent file and crashes
<swine_>    yes, because you don’t have the file
<swine_>    i do
<Billiard>    obv
<swine_>    and the byte order is getting reversed from what’s actually in the file
<Billiard>    says you
<swine_>    the file magic is cafec0c0
<swine_>    i can see it with a hex editor
<swine_>    my structure has c0c0feca in it
<kalven>    then it’s big endian
<Billiard>    you need to learn more about endianess
<swine_>    kalven, wtf would the data be big endian on the fs ?
<kalven>    swine_: drop the wtfs and hells. it has nothing to do with the fs. it’ll be in whatever endian format the application that wrote the data picked.
<reko_t>    swine_: it depends on the format of whatever you’re reading from.. it’s quite common to save something in big-endian format
<swine_>    kalven, xxd shoes “cafec0c0″
<Billiard>    swine_: (ca, fe, c0, c0) stored in memory has the value c0c0feca for a little endian integer
<Billiard>    like i said, learn about endianess
<swine_>    dude, i know about endianness
<swine_>    but this makes no sense
<Billiard>    swine_: (ca, fe, c0, c0) stored in memory has the value c0c0feca for a little endian integer
<borisbn>    swine_: bytes (!!!!!!), you see in hex editor are: 0th – CA, 1st – FE, 2nd – C0, 3rd – C0. in uint32_t they are 0xC0C0FECA
<kalven>    swine_: yes, and if your hex editor shows cafec0c0 then THE FILE IS IN BIG ENDIAN
<swine_>    kalven, how would the hex editor know anything about the endianness of the file ?
<Billiard>    rofl
<kalven>    ugh
<alcuadrado>    is (void) necessary/recommended as the argument list of the default contructor in classes? AFAIK in C “()” is not the same as “(void)” in prototypes
<kalven>    swine_: it doesn’t.. it just shows you bytes
<swine_>    kalven, right
<Billiard>    swine_: learn about byte endianness
<swine_>    oh, i see what’s going on now
<swine_>    lame
<melba>     alcuadrado don’t write void, just ()
<swine_>    thanks thoguh
<genjix>    alcuadrado: no need for it
<kalven>    your attitude is lame
<reko_t>    i love the “thanks though”
<swine_>    well it helped :)
<melba>    isn’t reading a struct like this totally wrong?
<alcuadrado>    melba, genjix, so in C++ contect () == (void)?
<borisbn>    swine_: when you print your “magic” printf prints 3rd byte, 2nd byte, 1st byte and then 0th byte. It called “Big Endian”
<Billiard>    borisbn: actually, that’s called little endian
<melba>    alcuadrado, what ?
<reko_t>    borisbn: in little endian the least significant byte is stored in byte 0
<reko_t>    in big endian the most significant byte is
<borisbn>    ouuups, little, of course. i’m lazy and “big” is shorter to type  :)
<genjix>    alcuadrado: google http://stackoverflow.com/questions/693788/c-void-arguments
<alcuadrado>    that was I was asking. thanks for your answer, and sorry for not googling it before asking
<genjix>    lol there’s a comment there by litb
<melba>    genjix, i’m reading this http://stackoverflow.com/questions/289559/class-layout-in-c-why-are-members-sometimes-ordered
<melba>    and it has one too
<melba>    lol
*    abhijain is now known as rahul
*    rahul is now known as dhaval
*    vsrao_ is now known as vsrao
<Silex>    how can I do MVC when the library I use has the input in the view classes already? seems I have to do MVP in that case
<BlastHardcheese>    !winprog
<nolyc>    You should ask your Windows programming questions in #winapi or ##windows-coding or irc://irc.efnet.org/winprog
<reko_t>    why do you assume he’s talking about windows programming?
<TinoDidriksen>    He said MVC, not MFC…
<masterkorp>    agreed
<zap0>    i’m sitting on the fence.
<PlasmaHH>    efence?
<tomalak>    http://www.ideone.com/OS4zV <— wtf?
<Silex>    yeah, my question is about design patterns
<Silex>    maybe there’s a design patterns channel tho?
<tomalak>    maybe there is!
<TinoDidriksen>    tomalak, indeed…can only access objects that are D. It’s been discussed many times; it’s a cute but valid case.
<tomalak>    I don’t get it
<tomalak>    wtf is `protected` for then?
<mama>    you’re confusing stuff
<TinoDidriksen>    To let children access it. You’re not accessing a parent there, though.
<Billiard>    tomalak: to access your own base! not some unrelated class A instance
<mama>    you think that inheritable works like ‘friend’ on protected members
<mama>    *inheritance
<tomalak>    Billiard: but `private` works on unrelated instances of the same type
<tomalak>    in fact, `protected` works on unrelated instances of the same type
<tomalak>    just not unrelated instances of the base type
<Billiard>    correct
<tomalak>    http://stackoverflow.com/questions/7711237/how-to-access-protected-base-class-function-from-derived-class-through-base-clas/7711459#7711459
<nolyc>    <http://tinyurl.com/672lq2n> (at stackoverflow.com)
<tomalak>    is that right?
<tomalak>    mama: It pretty much does, except for less-derived types
<Billiard>    tomalak: you are asking if he quoted the standard correctly? :|
<tomalak>    I’m asking whether I quoted the right passage, and whether my interpretation of it is correct
<Billiard>    oh thats you
<tomalak>    yes, that’s me
<tomalak>    did the 36.3k and 5 gold badges not give it away? ;)
<mama>    whore
<PlasmaHH>    !fs protect
<nolyc>    #define ACCESS(A, M, N) struct N : get_a1<void A>::type { using get_a1<void A>::type::M; } \ template<typename T> struct get_a1; template<typename R, typename A1> struct get_a1<R(A1)> { typedef A1 type; }; ACCESS((stack<int>), c, get_c); int main() { stack<int> p; p.push(10); p.push(11); cout << (p.*&get_c::c).front(); } // Your data is not safe anymore!
<tomalak>    I tried parsing that once
<Billiard>    no, mah data!
<melba>    p.*&
<tomalak>    melba: what about it?
<tomalak>    http://stackoverflow.com/questions/7708644/undefined-reference-to-stdhashstring#comment-9375559 lol
<Protogenes>    hello, is there some basic type i can use to store a functor created by std::bind with specific return value and parameter types?
<tomalak>    yes
<tomalak>    !next
<nolyc>    Another satisfied customer, next!
<Protogenes>    and what would the name/type be?
<mama>    Protogenes, std::function<return_type(arg1_type, arg2_type)>
<tomalak>    take a guess
<tomalak>    …. or be spoonfed by mama
<mama>    don’t be a dick, dick
<Protogenes>    thanks mama
<hawg>    hello… I have not programmed since college. Been working as a sys admin. Can anyone recommend a good reference as where to start if I would like to pickup C++ again?
<hawg>    np topic :)
<tomalak>    mama: if you’re going to help people, actually help them
<TinoDidriksen>    !give hawg basics
<nolyc>    hawg: Freely available resources for learning the basics of C++: http://code.google.com/edu/courses.html and http://stackoverflow.com/questions/194812/list-of-freely-available-programming-books and http://jcatki.no-ip.org/fncpp/Resources and http://cppreference.com/ and http://learncpp.com/
<tomalak>    helping them better than you’re helping them is not being a “dick”
<tomalak>    it’s being more intelligent than you
<hawg>    thankyou
<tomalak>    meanwhile, wtf:
<tomalak>    { std::function<int(int,int)> f = std::bind(&g, 3, 4); cout << f(); } int g(int a, int b) { return a + 2*b; }
<geordi>    error: no match for call to ‘(function<int(int, int)>) ()’
<tomalak>    have i gone mad
<tomalak>    oh
<mama>    yes, you
<tomalak>    duh
<mama>    ‘re quite obviously an idiot
<tomalak>    { std::function<int()> f = std::bind(&g, 3, 4); cout << f(); } int g(int a, int b) { return a + 2*b; }
<tomalak>    :D
<geordi>    11
<tomalak>    mama: I suggest shutting the fuck up if you cannot be a constructive part of this channel.
<mama>    well, i’m the most ctive part of this channel simply by telling you to stfu
<tomalak>    !ops
<nolyc>    Adrinael ville wcstok LIM orbitz woggle PlasmaHH Eelis are ops in this channel
<kalven>    getting tomalak to shut up would be productive
<tomalak>    get rid of this troll
<mama>    lul
<tomalak>    { std::function<int()> f = std::bind(&std::plus<int>, 3, 4); cout << f(); } // what am I doing wrong in this code?
<geordi>    error: expected primary-expression before ‘,’ token
<kalven>    trying to take the address of a class..
<tomalak>    { std::function<int()> f = std::bind(std::plus<int>(), 3, 4); cout << f(); } // never mind
<geordi>    7
<tomalak>    I hope that this demonstration has been of some use to you, Protogenes
<Protogenes>    all i needed was the hint to std::function. i never used that so i didn’t know
*    SlashLife_ is now known as SlashLife
*    X-Scale is now known as Guest42831
*    X-Scale` is now known as X-Scale
<kralyk>    Hi… would someone please check if I screwed the delete stuff or not? Thanks!    http://ideone.com/s9ko1
<kralyk>    I mean alloc/dealloc
<kralyk>    Hmm? No one’s willing to check if my alloc/dealloc is sane enough? Just a few lines…   http://ideone.com/s9ko1
<kralyk>    btw  _state is declared as void*
<goldenmean>    kralyk – Read the code. delete static_cast<fpu_control_t*>(_state), it seems ok to me atleast.
<TinoDidriksen>    kralyk, valgrind it…
<kralyk>    goldenmean: ok thanks
<kralyk>    TinoDidriksen: uhh, ok, will try…
<PlasmaHH>    that code makes eyes bleed, everyone is rushing to the hospitals instead of answering your question
<goldenmean>    kralyk – what is fpu_control_t, mostly a class, hope its not a typedef to some array type ??
<kralyk>    goldenmean: no it’s some int, unsigned int possibly
<kralyk>    I might as well use malloc…
<kralyk>    PlasmaHH: any suggestions? ^^
<goldenmean>    just to be safe then u might as well do  delete [] static_cast<fpu_control_t*>(_state)
<PlasmaHH>    kralyk: get rid of the ugly casts.. but when you suggest to use malloc, you might want to make those things C functions anyways.
<kralyk>    PlasmaHH: they’re class member :D
<kralyk>    *memebers
<PlasmaHH>    so?
<kralyk>    oh… yea.
<kralyk>    here’s the header btw: http://ideone.com/9dodF
<TinoDidriksen>    Why is it a void* ?
<TinoDidriksen>    And why is all that static? Use a namespace instead.
<kralyk>    because the type is different on each platform
<Silex>    is there a channel about design patterns questions?
<PlasmaHH>    !alis
<nolyc>    alis is a freenode service bot designed to help find channels on freenode instead of asking in other channels that aren’t meant to be your gateway into freenode (like ##c++). /msg alis help list to get started.
<PlasmaHH>    kralyk: then make a typedef that depends on the platform?
<kralyk>    TinoDidriksen: oh, yea you’re right I’ll make it a namespace. Btw vlagrind says no leaks
<kralyk>    PlasmaHH: hm, I don’t really see how to do that
<PlasmaHH>    kralyk: #ifdef whatever typedef xxx yy; #endif
<kralyk>    PlasmaHH: uh, I got the .cpp files conditionally included by cmake
<kralyk>    I would have to include another header or something…
<kralyk>    could be done, but a little messy imo,
<PlasmaHH>    using void* and casts is more messy
<PlasmaHH>    the code can be reduced to use one single cast only anyways.
<andyc>    Hello
<andyc>    I have a newbie question.  I’m used to using C and not C++ and I’m  little confused by references (&).  I want to have an object reference as a member variable in a class, but when I define it in class.h, Object& obj_; I get compiler errors because the object is not initialised, but I can’t initialise it until the constructor.  Should I just be using pointers in this case?
<PlasmaHH>    andyc: no, you should initialize it in the ctor.
<TinoDidriksen>    andyc, you can initialize it in the constructor initializer, but not in the constructor body.
<TinoDidriksen>    Using a reference member makes the objects un-assignable, though.
<andyc>    So I don’t define it as a private member in class.h?
<kralyk>    PlasmaHH: ok, I guess I’ll use namespace + typedef. Thanks everyone.
<PlasmaHH>    andyc: you probably dont know what initializing in the ctor means… what book are you using to learn c++?
<andyc>    cplusplus.com
<Griwes>    (and now he says you are doing that wrong)
<PlasmaHH>    andyc: I asked what book…
<PlasmaHH>    !cplusplus.com
<nolyc>    cplusplus.com is not a good site for learning C++. It doesn’t cover C++ very well. If you are serious about learning C++, we recommend that you get a decent book instead. See !book
<TinoDidriksen>    !give andyc basics
<nolyc>    andyc: Freely available resources for learning the basics of C++: http://code.google.com/edu/courses.html and http://stackoverflow.com/questions/194812/list-of-freely-available-programming-books and http://jcatki.no-ip.org/fncpp/Resources and http://cppreference.com/ and http://learncpp.com/
<PlasmaHH>    learncpp.com? already reading the toc makes me want to crush it
<andyc>    Thanks for the links – I’ll have a look now
<TinoDidriksen>    It’s actually not bad…
<TinoDidriksen>    It does use Hungarian notation, but that’s the only direct flaw I could see.
<PlasmaHH>    “C/C++” does not exist.
<kralyk>    PlasmaHH: it sometimes does, sadly…
<PlasmaHH>    kralyk: let me give you a nice quote about this: “personally, I take most uses of the compound “C/C++” as an indication of ignorance. ”
<Protogenes>    !book
<nolyc>    http://jcatki.no-ip.org/fncpp/Resources
<melba>    where do “ ” quoting come from
<TinoDidriksen>    LaTeX?
<PlasmaHH>    !badbook
<nolyc>    Any book with ‘idiots’, ‘dummies’, ‘minutes’, ‘hours’, ‘days’, or the name of a specific compiler or product in its title is a bad book. Also, any book which has “#include <iostream.h>” (as opposed to “#include <iostream>”) in the beginning chapters is a bad book.
<PlasmaHH>    I think we should reformulate that to “are written for a specific compiler or product” or similar, and then apply it also to “tuts”
<Arafangion>    Compound languages are painful. :(
<Arafangion>    There are far worse monstrosities than C/C++.
<Protogenes>    example?
<Arafangion>    Well, there’s C++/CLI.
<Protogenes>    alirght… convinced
<Arafangion>    I’m not finished, there’s worse
<Arafangion>    There’s ObjC++.
<Silex>    ObjC++ is worse than C++/CLI?
<Protogenes>    why is objc++ bad?
<Arafangion>    Protogenes: Consider how exceptions and ObjC works.
<Protogenes>    I don’t know nothing about exception handling in ObjC(++)
<Arafangion>    It’s setjmp/longjmp based.
<Arafangion>    Or at least it is in the legacy runtime, afaik.
<Protogenes>    okay
<Arafangion>    That said, after having done both for a while, I think I prefer ObjC++.
<Arafangion>    Then again… I dunno.
<Arafangion>    You can mix ObjC and C++ more easily…  But you trigger undefined behaviour much more easily.
<Arafangion>    C++/CLI, by contrast, tries very hard to prevent undefined behaviour, which is a Good Thing.
<PlasmaHH>    for you maybe
<Protogenes>    juggling with running chainsaws as my teacher in school always said
<kralyk>    objC++ is just a gnu extension isn’t it?
<Arafangion>    kralyk: No.
<Protogenes>    mama i changed my code to use std::bind.. and of course i get alot of errors when compiling, is it right that i can’t pass constants to bind because everything is passed by reference?
<Arafangion>    PlasmaHH: What are you implying by that?
<mama>    Protogenes, everything is passed by value to bind
<mama>    use std::ref() or cref() if you need to pass a reference
<genjix>    objective-c, c#, d … so many c++ spin-offs
<genjix>    ok we get it. take the fail elsewhere. :p
<Protogenes>    constants are okay then. if i use a custom functor, do i need to define some types or anything so that bind works with it?
<bwright>    {} struct A {union{int m[4][4]; int m[16]; A() {m[0][2] = 1;}};
<geordi>    error: Unexpected end of request. Expected ‘}’ or balanced code.
<bwright>    {} struct A {union{int m[4][4]; int m[16]; A() {m[0][2] = 1;}}};
<geordi>    error: declaration of ‘int A::<anonymous union>::m [16]‘
<bwright>    {} struct A {union{int m[4][4]; int m_linear[16]; A() {m[0][2] = 1;}}};
<geordi>    error: ISO C++ forbids declaration of ‘A’ with no type
<bwright>    hmm
<bwright>    Is this possible?
<Arafangion>    genjix: ObjC is not a spinoff from C++.
<bwright>    I believe it is
<PlasmaHH>    Arafangion: that is not a “Good Thing” for everyone.
<Protogenes>    mama if i use a custom functor, do i need to define some types or anything so that bind works with it?
<borisbn>    bwright: {} struct A {union{int m[4][4]; int m_linear[16];}; A() {m[0][2] = 1;}};
<Protogenes>    i get an error with 8 times nested template and i can’t dig through the stl back to identify what i do wrong
<genjix>    Arafangion: haha try again
<mama>    Protogenes, probably not.  can you get a testcase?
<Arafangion>    PlasmaHH: Indeed, no, not for *everyone*
<genjix>    Arafangion: it looks exactly like c++
<bwright>    what will happen if I use m_linear?
<Arafangion>    genjix: ObjC? It’s a smalltalk and C hybrid.
<kralyk>    bwright: I don’t think it is, it’s more like C++ done differently, ie C spinoff.
<Protogenes>    mama i will try to strip the code down
<Arafangion>    genjix: It follows the smalltalk model rather than simular.
<Arafangion>    *simula.
<genjix>    Arafangion: oh you’re right. i just looked it up
<bwright>    kralyk: It is used in the Ogre engine.
<kralyk>    dont know that sry
<kralyk>    Also, C#’s more of a Java spinoff than c++ directly, imho.
<genjix>    i’m wrong… i wonder why i thought it was a c++ type language (like java and c#)
<bwright>    It is because you want column major for most operations on matricies in relation to transformations and c++ is row major.
<Arafangion>    PlasmaHH: If I don’t trust the programmers, then I want a restrictive language. :(
<borisbn>    bwright: http://www.ideone.com/EMva3
<bwright>    This is an amazing trick ^_^
<bwright>    cool thanks.
<PlasmaHH>    Arafangion: if I want speed, I want a language that does not do more than what I need
<Arafangion>    PlasmaHH: You, I would trust, but most programmers have no idea.
<Protogenes>    mama there it is http://ideone.com/4PUab
<mama>    Protogenes, but the above compiles…
<mama>    Protogenes, are you sure you’re working in the C++11 mode?
<mama>    Protogenes, those things are in tr1 if you’re stuck with C++03
<Protogenes>    i think so. lambdas and crap is working ^^
<Protogenes>    i’m using VS10, not the gcc
<mama>    well, if you want us to help you with a problem, you should preferably provide a test case that shows the problem, not a one that works
<mama>    that’s vs10 saying about that code?
<mama>    *what’s
<Protogenes>    http://ideone.com/z3gWZ mama
<mama>    Protogenes, no idea
<Protogenes>    :( thank you
<Protogenes>    anyone else?
<tomalak>    what’s the question
<Protogenes>    tomalak http://ideone.com/z3gWZ
<Protogenes>    code: http://ideone.com/4PUab
<AlecTaylor>    hi
<AlecTaylor>    Someone just told me that C99 code can’t be embedded within C++ code. Is this true? – I thought C++ was backwards compatible!
<TinoDidriksen>    C99 was made after C++
<AlecTaylor>    TinoDidriksen: But C++ revisions have been made since C99
<c_nick>    hi
<tomalak>    C++11 references C99
<tomalak>    which surprised me
<c_nick>    can someone suggest me few C/C++ Frameworks
<TinoDidriksen>    So…C++98 and C++03 is mostly backwards compatible with C89. C++11 is somewhat compatible with C99.
<Protogenes>    c_nick for what?
<tomalak>    actually, so does C++03
<tomalak>    1.2
<tomalak>    c_nick: no
<tomalak>    AlecTaylor: it’s not entirely backwards compatible
<tomalak>    whoever you were talking to was making gross generalisations that cannot be applied to real life
<Protogenes>    and reminds me of: C++ isn’t C.. and neither a superset
<tomalak>    Protogenes: http://ideone.com/9djlD fix the testcase
<c_nick>    well.. basically i want to know a couple of C/C++ Frameworks
<tomalak>    and always click ‘run code’
<Silex>    C++03 is *mostly* backward compatible with C89. The gap with C99 is much bigger
<tomalak>    c_nick: you’re going about it wrong
<tomalak>    c_nick: come up with a need first
<TinoDidriksen>    c_nick, frameworks for what purpose?
<tomalak>    c_nick: Can you suggest me a few road vehicles suitable for my needs please
<c_nick>    tomalak, what needs
<c_nick>    xD now i get it
<Protogenes>    C++ is a language
<tomalak>    c_nick: not telling you
<AlecTaylor>    Thanks TinoDidriksen+tomalak
<tomalak>    gdgd
<tomalak>    AlecTaylor: you’re welcome?
<Protogenes>    tomalak my testcase is just fine
<Protogenes>    you need a new compiler
<c_nick>    Well i have been working on SQlite3, Phonegap, win32 and i have to write about frameworks .. i dont know if i should include them in the list of frameworks worked on in my progress sheet xD
<Protogenes>    !google C++ framework
<nolyc>    openFrameworks: <http://www.openframeworks.cc/>; Platinum C++ Framework: <http://www.pt-framework.org/>; Which is the best c++ web framework? – Stack Overflow: <http://stackoverflow.com/questions/746309/which-is-the-best-c-web-framework>; GNU Common C++ – GNU Project – Free Software Foundation (FSF): <http://www.gnu.org/s/commoncpp/>; Qt – Cross-platform application and UI framework — Qt – A (1 more message)
<AlecTaylor>    Wt is the best C++ web framework
<Protogenes>    what is web?
<AlecTaylor>    a big donut
<kalven>    does it have a lot of competition?
<melba>    lol
<c_nick>    :(
<AlecTaylor>    xD
<Protogenes>    tomalak http://ideone.com/z3gWZ code: http://ideone.com/4PUab  use a newer compiler version
<bwright>    How would I implement a column indexable matrix in C++ that could be resolved to a 1 row matrix?
<bwright>    column major**
<bwright>    union { T m[4][4]; T m_l[16]; }; achives row major.
<mama>    tomalak, his code is C++11, not C++03
<TinoDidriksen>    Use Boost.Multi_Array ?
*    JotaK2 is now known as JotaK
<borisbn>    bwright: work only with linear. then you can choose [y * col_count + x] or [x * row_count + y]
*    Guest77940 is now known as Olipro
<mitch0>    hehe: “clang fails assertion given function with >256 parameters”
<kalven>    obviously not ready for production use…
<Protogenes>    256 params oO wtf
<Silex>    kalven: ;)
<borisbn>    they use params[ 256 ]; let’s tell them about std::vector :)
<Silex>    it’s more because they use a uint8_t to count the number of functions params
<borisbn>    ok, let’s tell them about uint32_t
<borisbn>    4 billion params is better, then 256 :)
<Griwes>    nobody is ever gonna use a function with 256 params
<cygal>    Griwes: it does exist
<Protogenes>    must .. not … punch … programmer
<Silex>    this explains it: the ML is saying they’ll handle the special case where it’s >256
<Silex>    shit
<Silex>    http://comments.gmane.org/gmane.comp.compilers.clang.devel/17437
<Protogenes>    anyone http://ideone.com/z3gWZ code: http://ideone.com/4PUab ?
<viric>    Helllo c++fans
<viric>    What do you think std::numeric_limits<unsigned int>::is_integer should be?
<Protogenes>    { std::cout << std::numeric_limits<unsigned int>::is_integer }
<geordi>    error: expected ‘;’ before ‘}’ token
<TinoDidriksen>    true, naturally…
<Protogenes>    { std::cout << std::numeric_limits<unsigned int>::is_integer; }
<geordi>    true
*    Pip_ is now known as Pip
<viric>    I think msvc thinks it should return false
<Silex>    that sounds unlikely
<viric>    ah no, it returns true.
<TinoDidriksen>    Returns true in my VC++ 2010
<borisbn>    true in msvc 2008
<Pip>    Should I use boost ?
<TinoDidriksen>    Yes
<Pip>    For what ?
<borisbn>    how do you say in this case ?
<borisbn>    !next
<nolyc>    Another satisfied customer, next!
<kalven>    doesn’t matter, just use it
<viric>    thank you
<TinoDidriksen>    You should use Boost for any of the uses it has…
<Pip>    Then first of all, let me install it
<TinoDidriksen>    Pip, Boost can do: http://www.boost.org/doc/libs/?view=categorized
<viric>    hm I’ve code with templates; some code lines emit warnings depending on the instantiating type. But those lines are never reached by execution (if()…). How can I get rid of those warnings?
<TinoDidriksen>    viric, my solution is http://ideone.com/Fp89c
<TinoDidriksen>    Depends on which warning you have.
<viric>    I thought of that trick
<viric>    ‘-’ operator on unsigned
<Heisenmink>    how is the stack size determined?
<TinoDidriksen>    Heisenmink, at runtime, by the OS
<Heisenmink>    TinoDidriksen, how can I know, when programming, how much I can recurse?
<TinoDidriksen>    Heisenmink, you can’t know…
<Protogenes>    mama found a workaround… using lambda instead of std::bind http://social.msdn.microsoft.com/Forums/eu/vclanguage/thread/1eee1e66-9f8d-4040-8a14-9e8bab24dd54
<Protogenes>    thx for you help bye
<Heisenmink>    TinoDidriksen, so any program I make can crash on some systems because of stack overflow?
<TinoDidriksen>    Heisenmink, yep…so don’t abuse the stack.
<Heisenmink>    TinoDidriksen, abuse in what sense? What should I avoid doing?
<Protogenes>    avoid int foo[10000]
<TinoDidriksen>    Avoid making 10000 element stack arrays…
<TinoDidriksen>    Et
<TinoDidriksen>    c
<Protogenes>    TinoDidriksen malloca is fun too :D
<Heisenmink>    So I should just see the stack as a very limited resource?
<TinoDidriksen>    Yes
<Heisenmink>    ok, thanks for the answers
<viric>    Heisenmink: on linux, it easily goes to 2MB or so…
<Protogenes>    maybe not very limited.. the compiler should warn you if a stackframe is too large
<viric>    Heisenmink: ‘ulimit -s’ shows your stack size limit
<TinoDidriksen>    Stack sizes on modern Linux is 8-10mb.
<viric>    There may be no trouble in Foo f[10000] if that does not get called recursively
<viric>    stack allocation is faster than heap
<Protogenes>    alot faster
<PlasmaHH>    Protogenes: because the compiler knows what the runtime configurable stack frame limit you run your stuff under will be?
<Griwes>    “stack allocation” is just moving the stack pointer
<viric>    exactly
<viric>    so Foo f[10000] may be a very good idea in some cases
<Griwes>    so it simply must be faster than dynamic allocation
<Griwes>    :P
<Protogenes>    PlasmaHH it just warns when > 65536
<Protogenes>    default ^^
<PlasmaHH>    Protogenes: and how to silence that warning? it would trigger for my stuff everywhere
<Protogenes>    skip -Wextra for gcc i assume
<PlasmaHH>    yeah, since all the others in -Wextra are useless…
<Protogenes>    if you think so…
<Protogenes>    well i got to go
<PlasmaHH>    you seem to, otherwise you would not suggest it as the canonical workaround for silencing a stupid useless warning…
<Protogenes>    i never had functions that use >65536 of stackframe
<PlasmaHH>    and you are representative for the majority of useful code out there?
<Protogenes>    it’s just a difference about how you work
<Protogenes>    nobody complaines about my code
<Protogenes>    you can’t force me to share your _opinion_ .. so you don’t like -Wextra… whatever it does you can overwrite with a special -w*** flag
<Protogenes>    bye
<melba>    bye
<PlasmaHH>    nobody complains about the code that I showed nobody too. how suprising.
<PlasmaHH>    hmpf, naming stuff is really not easy… I have an enumerator that would best have the name volatile…
<borisbn>    I have a warning ” format %llu expects type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ ” at my g++ 4.5. I can’t repeat it at ideone, because it doesn’t warn on this http://www.ideone.com/qtrj1 can you tell me, how should I change my code to get rid this warn
<mitch0>    one option is to stop using printf (and friends)
<borisbn>    mitch0: in new projects i do not use it, but it’s an old stuff (but it works). I don’t want to change all printf/scanf to cout/cin. it’s a big job, but with no sense for this particular case
<PlasmaHH>    borisbn: you need different format flags for uin64_t depending on what platform you are on
<borisbn>    and what should I do, if it would be “pure” C code ?
<PlasmaHH>    borisbn: then you would ask in ##c
<bwright>    How smart are C compiles at unwrapping loops and concatenating assignments?
<mitch0>    well, probably on your current setup uint64_t is “unsigned long” insted of “unsigned long long”, so either changed the format string (based on some macro) or change your type to “u l l”
<PlasmaHH>    bwright: you better ask in a c channel
<bwright>    C++*
<borisbn>    could you tell me, how can i verify a “real” type of uint64_t ? typeof( uint64_t ).name() ?
<PlasmaHH>    borisbn: “verify”?
<borisbn>    oah… that english :) check/get/test
<dli>    borisbn, wikipedia contains something about this trouble: http://en.wikipedia.org/wiki/Stdint.h
<bwright>    name is only going to be a constant valvue for a single execution of the program right?
<bwright>    Somewhere in the standard.
<dli>    borisbn, about the ‘real’ type, the operator sizeof is handy
<borisbn>    dli: I think sizeof( uint64_t ) is always 64 / 8 (if one byte is 8 bits)
<bwright>    Doesn’t they keyword mutable destroy the idea of const correctness?
<dli>    borisbn, the problem is “unsigned long long” here
<PlasmaHH>    bwright: on the contrary!
<bwright>    Sounds like a side effect in a pure function to me!
<bwright>    not that a const function is pure, it can have side effects it simply can’t modify this
<bwright>    PlasmaHH: But you explicitly can modify this if you make part of this mutable.
<bwright>    -_- I mean at least it is explicit so it is clear.
<PlasmaHH>    bwright: you are confusing a logical constness by a physical constness.
<borisbn>    bwright: mutable often use with mutex objects. if your const function doesn’t change the data of object, but need to lock that data to read. lock functions are non-const. that’s why you can’t use them in const ones. but… you can say, that mutex is mutable, and lock them as you wish
<bwright>    I suppose another good example would be reference counting.
<bwright>    mm ok.
<mitch0>    or caching
<bwright>    borisbn: I was thinking of why a double array with a union was a better choice then linear and here is my argument.
<bwright>    3 and 4 dimensional square matricies are common.
<bwright>    for 2D and 3D respectively.
<bwright>    for(u32 i = 0; i < N; ++i) m[i][i] = scale[i];
<PlasmaHH>    a double array with a unicorn?
<bwright>    that is the definiton to set the scale.
<TinoDidriksen>    Use a real matrix class that solves your problem then, or make one with iterators to present row/column major views. But pretty sure Multi_Array can do most of what you want…
<bwright>    I could but I am writing my own matrix class?
<bwright>    Because that is sort of the point.
<TinoDidriksen>    Ok. I see no need for unions, though.
<bwright>    Ogre uses them, they are a big graphics engine
<borisbn>    bwright: what is the real goal ? speed or convenience ?
<bwright>    gl transformations only apply to 1d arrays
<bwright>    because they work column major and it clears up any ambiguity.
<ville>    bwright: it is UB to read from union member that wasn’t the one used for writing into it.
<bwright>    UB?
<ville>    !ub
<nolyc>    Undefined behavior results when programs attempt to do things for which the standard defines no semantics, and requires no diagnostic either. Examples include dereferencing invalid pointers and dividing by zero. Executing such programs may cause them to produce incorrect results, crash, silently “work”, or even format the hard drive.
<Griwes>    undefined behavior
<snuggl>    bwright: if using GLM is an option, do that
<bwright>    yes but it is the first identifier in the class.
<bwright>    of the same type.
<snuggl>    bwright: its a math class designed for GL folloing the glsl spec
<PlasmaHH>    ville: there are some nice exceptions, like when for standard layout structs, the first member of both union members is of the same type ;)
<bwright>    Yes if I was building a game I wouldn’t be doing it all by hand, I have already written a scene graph and a quake 2 model loader.
<bwright>    So it is more about the experience of writing it as opposed to it being better then other implementations.
<TinoDidriksen>    { union { int x[1][1]; int y[2]; } w; w.x[0][0] = 5; cout << w.y[0]; } // bwright, this is UB. It’ll work almost anywhere, but it is NOT guaranteed to work…
<geordi>    5
<snuggl>    bwright: ah
<bwright>    hmm.
<borisbn>    TinoDidriksen: why this is UB ?
<TinoDidriksen>    ’cause the standard says so.
<bwright>    is it implied?
<borisbn>    do you mean, that some compiler will place x and y (in your exam) in different places in memory ?
<borisbn>    s/will/can
<TinoDidriksen>    It’s explicit. Reading from a union member that you didn’t write to is UB.
*    borisbn goes to read standard about unions
<bwright>    It is used in Ogre maybe I should mention it to them.
<TinoDidriksen>    They know
<bwright>    yeh they just don’t care
<TinoDidriksen>    They don’t care. It works on their platforms.
<bwright>    Yes I am kind of a standard nerd though
<bwright>    So maybe I will get rid of it.
*    X-Scale is now known as Guest76393
<bwright>    Then again it is a bit different in gaming. I mean it is common practise to pack structs and load little endian data from a file straight into a struct.
<radifar>    hi all
<ville>    It’s quite funny that for some reason a lot of people think that the people working for game industry are some sort uber-programmers. Hmm sad-funny perhaps.
<radifar>    anyone here could tell me what does the bracket in “typedef SingletonClass<GameClass> Game” mean?
<ville>    radifar: template
*    Guest76393 is now known as X-Scale
<radifar>    oh, thanks ville, I just need a clue, and now I’ll google it
<ville>    radifar: typedef std::vector<car> cars;
<ville>    radifar: if you haven’t used the standard library’s containers before…
<mama>    i wonder, was there any use for typedefs in C except for typedef struct {…} foo; ?
<ville>    typedef int BOOL
<ville>    ever present in just about every C++ program
<borisbn>    mama: function type – typedef void(func_t*)(int);
<mama>    doesn’t really deserve the name
<mama>    borisbn, ahh, right
<o]>    ville: even on linux?
<mama>    i forgot you can have obscure types without templates
<ccocoa>    I think Win32 had a bunch of typedefs, might just be #defines though.
<Kaedenn>    ccocoa: both
<bwright>    typedef float vector[3];
<Kaedenn>    ccocoa: sometimes it defined a typedef =/
<Kaedenn>    bwright: eww, that type has specific limitations
<Raydiation>    is getline for stream only? src/server.cpp:145:33: error: no matching function for call to ‘getline(std::string&, std::string&)’ https://github.com/Raydiation/bif3-hts-langerposs/blob/master/src/server.cpp#L144
<Kaedenn>    Raydiation: yes
<bwright>    Kaedenn: Yes?
<Raydiation>    then is there a way to cut off the first line of a string and save the rest into a string?
<bwright>    Kaedenn: It is a row vector. that is the point.
<bwright>    But yes I suppose who would really do that anyway.
<Raydiation>    i solved with this http://paste.pocoo.org/show/490448/
<borisbn>    TinoDidriksen: the only thing i found about unions is (9.2 clause 17): If a POD-union contains two or more POD-structs that share a common initial sequence, and if the POD-union object currently contains one of these POD-structs, it is permitted to inspect the common initial part of any of them.
<borisbn>    i understood it in that way -  union { int x[1][1]; int y[2]; } w; w.x[0][0] = 5; cout << w.y[0]; – is NOT UB. Am I mistaken ?
<bwright>    boom.
<bwright>    Well I hope it is :)
<mama>    it’s x[1][1] is continuous chunk of memory?
<jrwren>    no
<jrwren>    err, oops, wrong lang channel, so my answer is “I don’t know”
<JordiGH>    Is there a C++ way to get INTPTR_MAX?
<borisbn>    { cout << std::numeric_limits<int*>::max(); }
<JordiGH>    Yeah, tried that already.
<geordi>    0
<borisbn>    ha
<JordiGH>    << INTPTR_MAX
<bwright>    What is actually happening that allows M<T[D]> to be valid syntax?
<geordi>    9223372036854775807
<bwright>    What does it mean?
<Pip>    “Comparisons of program metrics (class counts, method counts, and so on) suggest that a program written in the Java programming language can be four times smaller than the same program written in C++.” —-> is that true ?
<JordiGH>    bwright: Not enough context to parse that.
<JordiGH>    Pip: Sounds like REM. First of all, you can write any C++ program with zero class counts and zero method counts. C++ doesn’t even have methods.
<bwright>    {} template <typename T> struct A {}; template <typename T, size_t D> A <T[D]> {};
<geordi>    error: expected unqualified-id before ‘{‘ token
<borisbn>    Pip: in some cases can be 40 time smaller
<JordiGH>    Pip: You can’t write a Java program with zero class counts.
<Pip>    lol
<JordiGH>    lol
<borisbn>    I think, they mean a source code, but not executable
<Pip>    Yep
*    X-Scale is now known as Guest55289
<bwright>    C++ will use less system resources then java ^_^. I don’t think that is an insane generalization.
<JordiGH>    I’m still calling REM.
*    Guest55289 is now known as X-Scale
<teemo>    I have the following code: http://codepad.org/PFBwtuMY – I was wondering if could rearrange the ifdefs in anyway, so that I don’t have duplicate code?
<TinoDidriksen>    << std::numeric_limits<intptr_t>::max(); // JordiGH
<geordi>    9223372036854775807
<JordiGH>    C++11?
<TinoDidriksen>    No
<TinoDidriksen>    intptr_t is not int*
<mama>    << TYPE<intptr_t>
<geordi>    long
<mama>    h u h
<borisbn>    teemo: http://codepad.org/LwigSVhp
<JordiGH>    But intptr_t is C++03?
<JordiGH>    Where is it?
<TinoDidriksen>    intptr_t and uintptr_t are the integral type you can temporarily use to store pointers as integers.
<PlasmaHH>    they are c++11
<TinoDidriksen>    Oh like that. It’s C99, so C++11.
<teemo>    borisbn, thats a good idea, use another define
<TinoDidriksen>    <cstdint>
<teemo>    nice
<PlasmaHH>    teemo: #if !defined(W) || defined(L)
<Eelis>    TinoDidriksen: that “It’s C99, so C++11.” deduction is not actually valid; there are plenty of C99 things that were not adopted into C++11.
<JordiGH>    Is C99′s complex type in C++11?
<Eelis>    nope
<borisbn>    problem 2000: 99 is greater then 11 :) :) :)
<PlasmaHH>    JordiGH: they are however designed to be binary compatible
<PlasmaHH>    { complex<double> z; reinterpret_cast< double(&)[2]>(z)[0] = 5; cout << z; }
<geordi>    (5,0)
<teemo>    Are these the same: http://codepad.org/ajNLS3OJ ?
<PlasmaHH>    teemo: make a truth table
<Jockey4her>    i tried to translate a state assigning function to C++ from C, but get: argument of type void(App::*)() is incompatible with parameter of type App::PROG_FUNC*
<Jockey4her>    http://codepad.org/eO57ubqM
<JordiGH>    Jockey4her: wtf is PROG_FUNC?
<Jockey4her>    void function
<JordiGH>    wtf is a void function?
<JordiGH>    typedef void (PROG_FUNC*)(void)?
<borisbn>    typedef void (PROG_FUNC*)();
<borisbn>    aghr… late again :)
<Jockey4her>    a pointer to a function that returns a void
<JordiGH>    Jockey4her: I think you’re confusing member functions with normal functions. Member functions take a this* pointer, so they’re of a different type than free-standing functions.
<Jockey4her>    thanks, i will dig in that direction
<borisbn>    Jockey4her: change typedef and declare progState as PROG_FUNC    progState;
<JordiGH>    void(App::*)() takes a parameter that PROG_FUNC doesn’t take, namely, the this* pointer.
<borisbn>    void App::SetProgState(PROG_FUNC *newState) should be the same – void App::SetProgState(PROG_FUNC newState)
<Jockey4her>    great, ty
<borisbn>    Jockey4her: and if your DoStartup is a member of A, then typedef should be typedef void(A::PROG_FUNC*)();
<borisbn>    doh. error
<borisbn>     typedef void(A::*PROG_FUNC)();
<x0rs_w>    Can anyone who is familiar with Python tell me what the most direct substitutes for Python lists and dicts are in c++? From what I have seen so far I am equating vectors with lists and maps with dicts as being the most similar (other than being type specific in c++). Would this be close to accurate? At least concerning the standard library?
<snuggl>    x0rs_w: sure
<x0rs_w>    snuggl, ok cool
<ville>    !give x0rs_w container choice
<nolyc>    x0rs_w: http://adrinael.net/containerchoice
<rhc>    x0rs_w: yep
<rhc>    and tuples are kinda like std::array
<rhc>    or boost::tuple if you want diff types
<Jaydock>    hello everyone :) does anyone happen to know anything about the maya api at all?
<mgaunard>    Jaydock: no
<x0rs_w>    rhc: oh wow, I didn’t realize support existed for containing different types
<migimunz>    is there a way to make a class template B a friend of my class A, so that every specialization of B is automatically a friend of A?
<ville>    yes
<rhc>    x0rs_w: its not as flexible as it sounds
<ville>    boost any?
<rhc>    boost tuple
<flux>    hm, the standard tuples don’t support different types?
<rhc>    what’s a standard tuple?
<rhc>    or did they add boost tuple to std
<flux>    I was guessing C++11 had those
<flux>    what tuples were you referring to, that are like std::array?
<ville>    rhc: rather I am suggesting it for heterogenous container
<flux>    it looked like you were comparing to boost tuples that had the ability to have different types :)
<rhc>    ville: ah
<dan_w>    hi all. I am looking at implementing a basic state machine to simplify my code and remove a big bunch of switch statements, etc. but am having trouble understanding the simplest way to declare my states and graph
*    tj is now known as Guest26405
<ASIRINeiluj>    dan_w: isn’t an integer for the state and a 2 dimensional array good enough for you ?
<dan_w>    ASIRINeiluj : what would a 2d array do?
<dan_w>    hold the states?
<dan_w>    i see
<dan_w>    a vector
<ASIRINeiluj>    hold the next state in function of the current state and input found
<ASIRINeiluj>    then the state machine would be something like while ( !input.eof() ) { state = matrix[state][input.get()]; }
<ASIRINeiluj>    but it all depends on what you really want to do
<TinoDidriksen>    !eof’
<TinoDidriksen>    !eof
<nolyc>    Using “while (!stream.eof()) {}” is almost certainly wrong. Use the stream’s state as the tested value instead: while (std::getline(stream, str)) {}. For further explanation see http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5
<dan_w>    lol, off topic!
<dan_w>    i get that
<ASIRINeiluj>    TinoDidriksen: this was rather pseudocode
<TinoDidriksen>    Yeah, just making sure pseudo doesn’t get taken literally…
<dan_w>    ok thanks for the help, i will have another go at coding and try to return with better questions. thanks ASIRINeiluj, TinoDidriksen
<dan_w>    TinoDidriksen: thanks, i probably would copy and paste that!
<bwright>    does std::bind1st return a function?
<bwright>    such that std::for_each(c.begin(), c.end(), std::bind1st(std::mutliplies<T>(), scalar));
<bwright>    is a valid definition.
<bwright>    valid call****
<rhc>    yeah it should
<rhc>    unary_function
<bwright>    alright thanks.
<bwright>    what is the iterator type of T array[n]?
<melba>    T*
<bwright>    so if I am overloading begin() and end()
<bwright>    I would use T* begin() and T* end()
<bwright>    I suppose I can mask it with a typedef T* iterator.
<lesterwood>    i am doing this project, where we have a “board’ and this board has “start and end points”, along with “barriers”, the idea is to write a algorithm to find the shortest path
<lesterwood>    can someone help me out with the general design of this
<dontafan>    http://www.policyalmanac.org/games/aStarTutorial.htm
<dontafan>    i dont know if its what are you looking for but may be helpful…
<JordiGH>    Tutorial?
<bwright>    http://ideone.com/mblX6  in that case is the idiomatic approach I guess.
<melba>    m + D – 1
<melba>    { int arr[20]; cout << arr[19] << ” “<< arr[20]; }
<geordi>    0 0
<melba>    { int arr[20]; cout << arr[20]; }
<geordi>    -1812035296
<Brutus->    Hi, i have an array of const char c, and i want to create another array equals c but reversed. This array is constant, so how can i do? :P thank you
<ville>    don’t think you can.
<Nik05>    who know anything about g++ and archives?
<JordiGH>    I know about g++.
<SeySayux>    Nik05: someone does
<Nik05>    cause i have put all my object files in a .a
<JordiGH>    And I know about archives.
<SeySayux>    Nik05: man ar
<Nik05>    when i use g++ bla.a does it link all object files or just the one it needs?
<SeySayux>    Nik05: man ar
<Nik05>    SeySayux ar works fine with rsv ;)
<Nik05>    oh…
<Nik05>    does man ar talk about g++ SeySayux ?
<SeySayux>    man ar talks about ar
<SeySayux>    man g++ talks about gcc
<antto>    what is exactly the difference between a normal member function and a virtual member function? is there any performance difference?
<Nik05>    yes SecretAgent so my question was abouy g++ and linking with an archive…
<bwright>    man love returns: No manual entry for love
<ville>    antto: if you call it on an actual instance there’s no performance hit. If you call on a pointer or reference there’s a check or the actual dynamic type and finding the right function.
<SeySayux>    antto: A virtual member function of a derived class can be invoked through a reference or pointer to a base class. There is an obvious runtime performance and memory usage overhead (usually sizeof(void*) ), but this is usually negligble. For more info, use google.
<ville>    err “…check for the actual…”
<antto>    i mean, if i define a “default” function in the base class, and then override this function in the derived class, will it be slower in some way compared to just using a “normal” (non-virtual) function?
<SeySayux>    antto: Yes.
<ville>    no.
<SeySayux>    Well, that is, if you invoke through a base pointer or reference, else, no.
<antto>    i don’t like the “dynamic” part of that sentence there
<bwright>    the code will execute at the same speed, there is an overhead on the lookup if you use indirection.
<ville>    antto: pointers and references have static type and dynamic type.
<antto>    i just have a class base {}; and class derived: public base { … };
<bwright>    Such as Texture* tex = someFactory(SOME_TYPE);
<antto>    i won’t do anything else with the base or derived classes, i won’t cast any of them into something else
<ville>    re-read what I wrote.
<antto>    trying to keep it simple, yet abstract myself from some nasty code..
*    opcode0xCC is now known as opcode0x90
<ville>    base x; x.f() // no hit
<bwright>    http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.3
<SeySayux>    antto: virtual functions are only important if you intend to invoke a function from a derived class through a handle (pointer or reference) to a base class. In that case, you’ll get a lookup overhead, because the static (compile-time) type does not conform to the dynamic (run-ttime) code. The actual function executes at the same speed.
<ville>    base* x; /* x gets a value */ x.f() // hit
<mgaunard>    bwright: is your name wbright with a typo?
<SeySayux>    The base class will get an overhead of sizeof(void*) to store the vtable (virtual function table).
<bwright>    mgaunard: No.
<antto>    ville oh?!
<SeySayux>    Any further questions should be directed to the proper autority (that is, Google or your textbook)
<antto>    i’m using the derived object as a member variable in yet another object, my derived object isn’t allocated dynamically afaict
<ville>    doesn’t have to be dynamically allocated. It depends on what you use to call the function: actual instance or pointer/reference
<antto>    instance.. derived d; … d.f();
<antto>    ok, thank you guys ;]
<bwright>    on a typical compiler the cost of a virtual member function is only 2 loads and a call anyway.
<bwright>    It generally is not a big deal ^_^.
<antto>    you know, my case is never “general” ;P~
*    whaletechno_ is now known as whaletechno
<belak>    how can I use an ifstream to get a certain number of chars, without using a delimeter? It looks like istream::get uses a delimeter of \n which might be an issue when reading mp3 files in chunks…
<ville>    !give belak std::ifstream
<ville>    hmph
<ville>    std::ifstream is <reply> http://stdcxx.apache.org/doc/stdlibref/basic-ifstream.html
<bwright>    http://ideone.com/MMY8x wait I thought gcc stored its __vptr at the end of a class definition?
<bwright>    What is going on. -_-
<belak>    ville: I’ve read the docs… all the “get” methods use a delimiter…
<ville>    check the base classes
<belak>    Apart from the ones that read a single char, which seems horribly inefficient
<ville>    http://stdcxx.apache.org/doc/stdlibref/basic-istream.html#idx178
<belak>    I’m looking at basic_istream right now
<belak>    Ahhh
<belak>    Doh…
<belak>    Thanks…
<ville>    the mysteriously and elusive “read” function
<ville>    mysteriously named that is
<belak>    I was stuck on the get functions because they looked like they did what I needed…
<bwright>    Correct me if I am wrong.
<bwright>    But does this show that in gcc 4.5 they have the Vptr at the top of the class?
<bwright>    http://ideone.com/nMSHt
<bwright>    I thought it was defined at the bottom.
<bwright>    But there is a whole of 4 bytes.
<bwright>    wait
<bwright>    yes ok that was silly.
<ville>    hole?
<bwright>    yes it is at the bottom.
<bwright>    the 4 bytes are the int.
<SeySayux>    Hmm… I don’t think this is possible, but… I’m trying to define a macro to make specializing type traits for certain classes easier… But they need to be injected into my namespace (lets call it ‘foo’) for them to work… So I could do #define SET_TRAIT(Trait,Class) namespace foo { struct Trait<Class> : public ::std::true_type {}; } — but that wouldn’t work in another namespace. So I’d need to say, this namespace is relative to the main namesp
<SeySayux>    i.e. ::foo. Any ideas?
<genjix>    if i want to ensure that A is destroyed before B, do I simply make B a shared_ptr, and have A hold a reference to B?
<genjix>    is that the best way?
<SeySayux>    genjix: *cough* destructor *cough*
<SeySayux>    And in what you’re proposing, B is destroyed before A
<ville>    genjix: no need to complicate things if you can simply get away with order of declaration
<Raydiation>    why does this thing segfault? http://paste.pocoo.org/show/490547/ valgrind tells me Invalid read of size 1 by 0x56049FF: atoi (in /lib/libc-2.14.so)
<bwright>    atoi
<bwright>    your doing something bad to atoi
<Raydiation>    unsigned short port; port = atoi(optarg);
<SeySayux>    bwright: try outputting optarg to see what’s going wrong
<bwright>    huh?
<belak>    How can I convert (or cast) a char * to an unsigned char *?
*    Praise- is now known as Praise
<ville>    reinterpret_cast
<Raydiation>    SeySayux: hm, i tried to cout it before i set it, but still segfault
<Raydiation>    no ouptut
<bwright>    use gdb
<Raydiation>    Program received signal SIGSEGV, Segmentation fault.
<Raydiation>    0x00007ffff7313564 in ?? () from /lib/libc.so.6
<belak>    ville: thanks
<SeySayux>    no output, that means that something is going wrong
<ville>    always irks me that you need to use reinterpret_cast there and static_cast isn’t enough
<belak>    :q
<belak>    oops…
<Raydiation>    problem happens in after the first case ‘i’
<Raydiation>    before output
<Xarmydis>    Hey, I’m having a bit of trouble with understanding ifstream, if someone’s got a sec
<bwright>    {} int a[5]; cout << ETYPE(a+0);
<geordi>    error: ‘cout’ does not name a type
<bwright>    {} int a[5]; std::cout << ETYPE(a+0);
<geordi>    error: ‘cout’ in namespace ‘std’ does not name a type
<Xarmydis>    To be more specific, I’ve read the technical definition, but for the life of me cannot get ifstream to work. I’m unclear exactly how the syntax works
<bwright>    how do I work this thing.
<Xarmydis>    Is the argument a filename itself? or what? just a reference…hmm
<wilx>    What argument where?
<Xarmydis>    mmk
<wilx>    ifstream ctor does take file name.
<Raydiation>    i start the program with ./mailclient -p 60000 -i 127.0.0.1
<Xarmydis>    so like
<Raydiation>    60000 is fine for an usigned short right?
<genjix>    thanks ville
<bwright>    Raydiation: Check the limits yourself.
<Xarmydis>    ifstream file(something.txt);
<Xarmydis>    I don’t understand exactly what “file” is, or exactly how I should put something into the parenthesis
<SeySayux>    Raydiation: assignment truncates, it doesn’t segfault
<bwright>    it is a path.
<bwright>    ifstream fin(“C://Home//Stuff//blarg.txt”)
<TinoDidriksen>    Single /
<bwright>    actually it may be unix format
<bwright>    yes
<bwright>    good
<Raydiation>    SeySayux: the ip?
<TinoDidriksen>    bwright, either \\ or / … not //
<bwright>    yes
<bwright>    I don’t use windows
<SeySayux>    Raydiation: ip is a string
<Raydiation>    yes, std::string ip = optarg should be fine imio
<Raydiation>    its the usigned short port = atoi(optarg) that segfaults
<bwright>    {} char a[5] = “test”; printf(“%c”, (a)++);
<geordi>    error: expected constructor, destructor, or type conversion before ‘(‘ token
<SeySayux>    Raydiation: could you get a standalone, compiling testcase?
<bwright>    {} #include <cstdio>int main(){char a[5] = “test”; printf(“%c”, (a+0)++);}
<geordi>    error: extra tokens at end of #include directive
<bwright>    -_-
<bwright>    DO MY BIDDING
<Xarmydis>    mmk
<bwright>    Xarmydis: What exactly a file is is defined by your operating system.
<SeySayux>    Raydiation: never mind, I think I got one myself
<bwright>    Xarmydis: You could look up file systems if you were really keep.
<bwright>    keen*
<Xarmydis>    bwright, As keep as I am, here’s my issue. I’ve included iostream/fstream, and I have this line (without the quotes) “ifstream file(catmenu.dat)”
<Xarmydis>    I have the catmenu.dat file in the same folder as the cpp file
<SeySayux>    Raydiation: I can reproduce the segfault here
<Xarmydis>    I compile, and bam, it’s an undeclared identifier
<wilx>    std::ifstream
<wilx>    std::ifstream file(“catmenu.dat”);
<wilx>    Seriously…
<Xarmydis>    I’m using namespace std;
<Xarmydis>    wouldn’t that be extraneous?
<wilx>    I do not like that. It polutes name space.
<wilx>    The other part is important though, you need “catmenu.dat”, the quotes are important.
<Raydiation>    SeySayux: my friend messed up the syntax it was i:p: instead of :i:p
<SeySayux>    Raydiation: Yes, that seems to do it. I came to the conclusion it had to be an issue with the getopt call.
<silverrocker>    hi, I have a template class that can be constructed with primitive types and other objects, the question now is that I have a function which will add items to that class but on what and how should I init the things I add?
<SeySayux>    atoi usually doesn’t segfault
<Raydiation>    SeySayux: ty for your help
<SeySayux>    silverrocker: default constructor?
<silverrocker>    SeySSayux: hmm yes offcourse, -_- stupid me, thanks!
<SeySayux>    struct boa { boa() { /* boa constructor */ } }; // Programming humor :P
<BlastHardcheese>    http://instantrimshot.com/
<jgh->    i chortled
<SeySayux>    That’s not very on topic, now is it?
<Dinliani>    hi huys
<Dinliani>    guys*
<Dinliani>    i work with wxWidget and try to refresh a widget using Refresh() or Update(). It doesn’t work. Any idea or tips ?
<Dinliani>    my widget i want to refresh is a wxListBox
<SeySayux>    Dinliani: #wxwidgets
<antto>    in “aaa.h” i have: static const int bla = 23; #include “foo.h”
<antto>    then in “foo.h” i want to use the “bla” constant for array size: class C { float x[bla]; };
<antto>    i tryied adding: extern const int bla; in foo.h but it said: “error, array bound is not an integer constant”
<antto>    is there any way to make this work?
<Cecen>    antto: Is something else including foo,h
<Cecen>    foo.h*
<JordiGH>    antto: Don’t define static variables in more than one TU. That’s gonna confuse the linker.
<Cecen>    It’s const though, so it should be fine
<antto>    in “aaa.h” i include “bbb.h” which includes “ccc.h” and “foo.h”
<Cecen>    antto: Either way, what you’re doing doesn’t make sense. Restructure it so foo.h includes aaa.h
<MrSassyPants>    i’m confused about the syntax of references and pointers
<MrSassyPants>    dereferencing a pointer is *foo, but not foo*, correct?
<antto>    but “aaa.h” uses all of the classes in the bbb.h ccc.h and foo.h files
<Cecen>    MrSassyPants: If foo is a variable name, *foo dereferences. If foo is a class name, foo* is a pointer to a foo
<dli>    MrSassyPants, right *foo, the same as in C
<MrSassyPants>    but conversely, defining a pointer is int* foo, not *int foo or int *foo
<MrSassyPants>    correct?
<Cecen>    MrSassyPants: It can be int* foo or int *foo, doesn’t matter what the * attaches to
<MrSassyPants>    the * always looks to the right?
<Cecen>    Yes
<MrSassyPants>    so a * b…
<k0nichiwa>    altho the int* foo form gives you the impression int* foo, bar would define both foo and bar as pointer to int
<melba>    lol
<Cecen>    When the right of it is a type, it makes a pointer to that type
<variable>    MrSassyPants: yes, though typically C++ programmers will write it with the type
<k0nichiwa>    when actually bar is an int
<variable>    so A* b will make a pointer to A called “b”
<MrSassyPants>    k0nichiwa, so it’d be ‘int* foo, *bar’
<MrSassyPants>    correct?
<Cecen>    antto: Rewrite your code to use .cpp files for implementations
<Cecen>    If foo.h requires a const variable of aaa.h, it should include aaa.h
<ineb>    MrSassyPants: yes
<dli>    MrSassyPants, you can write: A a, *b;
<MrSassyPants>    dli, I want both to be pointers
<antto>    Cecen i can easily fix all this with a #define bla 23
<MrSassyPants>    and references work exactly the same?
<antto>    but i’ve been told to use static int instead of this
<variable>    MrSassyPants: Type *a, *b;
<variable>    MrSassyPants: references are different than pointers
<MrSassyPants>    int& foo = a, &bar = b;
<Oxyd>    typedef Type* TPtr; TPtr a, b;
<MrSassyPants>    variable, talking about the syntax here
<variable>    MrSassyPants:  stylistically  int &foo, &b;
<variable>    or better int& foo; int&bar;
<variable>    * int& bar;
<MrSassyPants>    variable, can you make references into the blue?
<variable>    MrSassyPants: you mean null references ?
<variable>    no
<Somelauw>    Hi, I am having a problem with svn. Are there any svn specialists here?
<MrSassyPants>    variable, I mean that’s what you just did there, no
<variable>    MrSassyPants: you need to have it equal something
<MrSassyPants>    not sure
<MrSassyPants>    as I said I’m confused
<MrSassyPants>    mildly
<variable>    MrSassyPants: yeah, I should have finished the declr. sorry
<variable>    Somelauw: #subversion ?
<Oxyd>    MrSassyPants: You can’t do int& ref;, you’re right if you’re asking about that. It has to be int& ref = some_int;.
<variable>    MrSassyPants: sorry, I sort of assumed you would do what Oxyd said. I should be more careful
<o]>    & & && & &
<MrSassyPants>    so int* &foo = bar; creates a reference to an int-pointer called bar.
<o]>    references always confuse the meek
<MrSassyPants>    or… doesn’t it
<Oxyd>    It does.
<Somelauw>    variable: How do I get invited?
<variable>    Somelauw: o.O
<Cecen>    I once killed a whale with a reference. Once.
<variable>    Somelauw: oh, maybe try #svn
<nova_hg>    hey, is there anyone who tell me why this code isnt printing the array?
<nova_hg>    #include<iostream>
<nova_hg>    using namespace std;
<nova_hg>    #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
<nova_hg>    int array[] = {23,34,12,17,204,99,16};
<nova_hg>    int main()
<nova_hg>    {
<nova_hg>        int d;
<nova_hg>        for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
<nova_hg>            cout<<array[d+1]<<endl;
<nova_hg>
<nova_hg>        return 0;
<nova_hg>    }
<Cecen>    Thanks for that
<bsod2>    eel
<MrSassyPants>    and {int& *foo = bar;} … a pointer to a reference? that doesn’t sound like it makes sense
<antto>    nova_hg don’t paste onto the channel!
<Oxyd>    MrSassyPants: You can’t make pointers to references.
<Oxyd>    You can make references to pointers, though.
<MrSassyPants>    is there a difference between {int& *foo = bar;} and {int* &foo =bar;} ?
<variable>    nova_hg: please use a pastebin!
<variable>    nova_hg: also please don’t use that macro!
<Oxyd>    MrSassyPants: Yes, the former will not compile.
<antto>    just hope Eelis doesn’t wake up now ;P~
<variable>    use a std::vector
<antto>    oops
<nova_hg>    variable: sorry! i didnt know!
<variable>    nova_hg: /topic
<bsod2>    that for loop looks like crap too
<nova_hg>    variable: why shoudnt i use that macro?
<bsod2>    go to #c++-basic
<variable>    nova_hg: because in C++ there are much better constructs
<variable>    nova_hg: http://en.cppreference.com/w/cpp/container/vector
<MrSassyPants>    Wait – I can’t make a pointer to a reference?
<V-ille>    correct
<nova_hg>    variable: i wanna know what is wrong with this? this is a question that some where i should answer!
<V-ille>    you can have a reference to a pointer, but not a pointr to a reference
<MrSassyPants>    then what happens if I … {int foo = 5; int &bar = foo; int* pfoo = &bar; cout << *pfoo;} <- so this wouldn’t compile?
<V-ille>    {int foo = 5; int &bar = foo; int* pfoo = &bar; cout << *pfoo;}
<geordi>    5
<V-ille>    there’s no pointer to reference in it
<MrSassyPants>    bar is a reference to foo
<V-ille>    int* pfoo = &bar make pfoo point to the object referred to by bar, aka foo
<V-ille>    *makes
<MrSassyPants>    so I can make a pointer to a reference!
<V-ille>    no
<joel_falcou>    &x takes the address of x
<joel_falcou>    no relation to reference
<MrSassyPants>    bar *is* a reference
<V-ille>    &bar is the address of the object referred to
<MrSassyPants>    it takes the address of a reference
<joel_falcou>    no
<V-ille>    not the address of the reference itself
<joel_falcou>    of the obect referenced
<MrSassyPants>    the reference itself is just a different name for foo
<MrSassyPants>    it’s still foo underneath
<MrSassyPants>    as far as I understand.
<joel_falcou>    that’s the principel of reference
<joel_falcou>    and foo is an int
<joel_falcou>    so it’s ftech foo address
<V-ille>    you’re not taking an address of a reference. References don’t have addresses.
<MrSassyPants>    V-ille, I can obtain the address, the resulting pointer works
<MrSassyPants>    V-ille, the reference isn’t a different object and logically has the same address as the original
<V-ille>    because it’s the address of the object referred to. I think I’ve said it enough times.
<Cecen>    MrSassyPants: This channel takes pedantry to a special level
<MrSassyPants>    Cecen, so do I :p
<V-ille>    there’s no type “pointer to reference”
<MrSassyPants>    V-ille, because that wouldn’t make sense
<MrSassyPants>    a pointer to a reference of X would be identical to a pointer to X!
<V-ille>    oh, good, then we agree
<V-ille>    !next
<MrSassyPants>    because a reference to X is X for all intents and purposes
<nolyc>    Another satisfied customer, next!
<V-ille>    except that it isn’t
<bsod2>    geordi << sizeof(int&)
<geordi>    4
<MrSassyPants>    V-ille, in which cases is it not?
<V-ille>    references are quite different from just object values in the sense that they allow polymorphism
<V-ille>    the type of X& vs. X is very different, for all intents and purposes
<yuriks>    geordi << sizeof(double&)
<geordi>    8
<bsod2>    nice :)
<MrSassyPants>    V-ille, that I get
<dan_w>    hi all. I am working on a basic state system. http://codepad.org/BIgSxq59 I am unsure what the most elegant way to change state is from inside a member function of a state. I wish to keep the machine simple and elegant. Thanks for any help!
<MrSassyPants>    say foo inherits from bar. I create a foo object and give its reference as a parameter to a function that handles bars. the function itself is going to operate on bars nonvirtual functions, not foos.
<reidgc>    Can anyone help me understand this error? “invalid conversion from ‘int’ to ‘PRUint32* {aka unsigned int*}’
<TinoDidriksen>    reidgc, it’s quite simple…you can’t assign an integer to a pointer.
<MrSassyPants>    but that’s not a matter of the reference being something other than the object itself (since virtual functions would still work properly, seeing as they’re basically function pointers stored in the object)
<MrSassyPants>    it’s just the function expecting ‘bar’ and using ‘bar’-operations on what it believes is a ‘bar’
<V-ille>    dan_w: the subject would fill books.. I once did it so that the state had an exit code, that was mapped through a transition table to a new state of the machine
<reidgc>    TinoDidriksen thank you
<dan_w>    V-ille : thanks for the response! that sounds like a fairly elegant solution.
<V-ille>    dan_w: the approach I described allows the machine to be quite simple, and states too, and then the state-specific transition tables map exit codes to next states
<V-ille>    the downside is that when you need a new exit code, you modify both a state and a transition table
<dan_w>    V-ille : still sounds simpler than getting uml involved or anything!
<V-ille>    but when you just modify the state logic without modifying its set of exit codes, it keeps modifications controlled
<V-ille>    most state machine libraries allow such things
<V-ille>    many of them make it hard to run-the-current-state
<V-ille>    some state machine libraries refuse to do anything anywhere else than transitions
<V-ille>    so run-the-state-and-stay-in-the-same-state requires icky transitions to the same state as they originated from
<bwright>    Oh a state machine. I wrote one for a game engine I built.
<dan_w>    V-ille : with your design, are all states enumerated, or is it the transition paths that are enumerated leaving the current state>?
<V-ille>    the latter
<V-ille>    the state machine doesn’t need to know the exact types of the states and doesn’t need to know about the transitions between states
<V-ille>    the state machine holds the states and can find a state by id
<V-ille>    the state machine doesn’t care which ids its states have, as long as they’re unique
<V-ille>    I also made that design nested, so that a state of a machine can be a machine itself
<V-ille>    with a twist – I ensured that the substates have globally unique ids
<V-ille>    this allows changing the state so that a given substate is directly transitioned to the state of the “main” machine without having to complete the submachine
*    MrSassyPants just now learned about the comma operator. Now I feel stupid
<V-ille>    dan_w: overall, I wrote such a state machine for tv playback, it waits for programme guide to download (which has several substates), selects channel, selects stream, and invokes a player
<V-ille>    then there are pause states and whatnot
<dan_w>    V-ille : thanks, this is very useful. So to clarify, you do use a graph object which holds the states and the transition paths between rather than return enumeration_state_play; at the end of a states function?
<V-ille>    the state function returns EXIT_CODE_PLAYING_SUCCESS (or some error, or whatever), which are state-specific, although the error cases always transition to a “fallback” state which models “stopped”
<V-ille>    then the transition table for that state has code,state_id pairs
<V-ille>    the code selects what the next state is to activate
<V-ille>    I didn’t use global enums for it
<V-ille>    the only portion that needs to know the exit code enums (in addition to the global ones) are the state and its transition table
<Codex_>    V-ille: I have a c++ feature request.
<V-ille>    I also made it so that if a code is not found in a transition table, that’s an error which leads to the stop state, automatically
<V-ille>    Codex_: yes?
<Codex_>    V-ille: it might be useful if some kind of equations could be solved directly with the language.
<V-ille>    dan_w: this has somewhat little to do with c++ :P
<V-ille>    “directly”?
<V-ille>    and, what kind of equations?
<dydt>    Hi, will a copy-constructor derived class call its base classes copy ctor by default, or must I explicity put the call in the derived class’ copy-ctor initialization list?
<Codex_>    v-ille: directly, i.e. by providing some functions. And you would get single element out from a root-finding algorithm
<dan_w>    V-ille : thanks so much, thats really thorough! a huge help, you are my hero
<Cecen>    V-ille is a hero to all of us
<Codex_>    v-ille: I have some ideas how the math required actually works.
<V-ille>    Codex_: and for multiple variables?
<V-ille>    or multiple roots, with multiple equations
<V-ille>    dydt: yes it will
<Codex_>    v-ille: I was thinking f(x)=g(y), pullback.
<dydt>    V-ille:  tyvm
<V-ille>    dydt: wait, no it won’t
<V-ille>    heh
<dydt>    lol ok ;)
<V-ille>    an implicit or defaulted one will
<V-ille>    an user-provided one won’t
<dydt>    right on
<V-ille>    so you have to initialize the base
<x0rs_w>    Is it the best practice to put an enum statement like this: “enum Directions{LEFT, RIGHT, UP, DOWN};” at the top of each of my cpp files under my includes?
<V-ille>    well… people often put enums after includes, yes
<V-ille>    namespacing helps
<V-ille>    with namespaces, it doesn’t much matter which order you use
<x0rs_w>    V-ille, oh I see, and should I just put it in one central file?
<dli>    x0rs_w, why not? a single header file
<V-ille>    is it the same enum everywhere? Why wouldn’t you put it into a central file then?
<x0rs_w>    V-ille, yes it is. I will do that
<bwright>    if I don’t specify say enum A { A1 = 0, A2}
<bwright>    can A2 be anything or must it be 1?
<bwright>    In the new standard clearly it makes sense when you specify the underlying type
<V-ille>    http://www.iso.org/iso/pressrelease.htm?refid=Ref1472
<V-ille>    I can’t see how A2 could be anything but 1
<x0rs_w>    Is it possible to use && or || in a switch case conditional?
<x0rs_w>    ie case A || B:
<melba>    try
<x0rs_w>    I did, it didnt work
<x0rs_w>    didnt know if my syntax was wrong
<x0rs_w>    also tried using ()
<x0rs_w>    but nada
<melba>    { switch (1) case 2 && 3: cout << “HI”; }
<geordi>    HI
<GrecKo>    You can do case a:case b: stuff; break;
<x0rs_w>    hmm, ok i will give those a shot
<GrecKo>    It’s like a or b
<x0rs_w>    GrecKo, that worked perfectly, thank you
<Oxyd>    geordi: replace (1) with (5)
<geordi>    <no output>
<GrecKo>    And I can’t seek how an “and” could make any sense in a switch
<GrecKo>    -k
<borisbn>    {int x = 2; int y = 3; switch( x && y )  { case 1: cout << “Hi 2 U 2″; } }
<geordi>    Hi 2 U 2
<V-ille>    it’s possible to do that and more by writing your own switch-case with lambdas :P
<GrecKo>    Do what?
<V-ille>    here’s a simple approach http://www.ideone.com/BKlf3
<melba>    woo
<V-ille>    it should be rather easy to extend that to allow lambdas for the case “labels” too
<V-ille>    so the labels can run anything that returns a bool, rather than just comparing the case value with operator== to the switch-value
<V-ille>    that approach merely allows switching on anything with an op==, including eg. strings
<bwright>    compilers can’t optimize ifs into switches, I know c++ won’t let you uses switches or gotos to cross an initialization… But that seems rather not relevant. Is there anything in the standard that would make this hard?
<V-ille>    who says compilers can’t optimize ifs into switches?
<bwright>    compilers don’t*
<Bigcheese_>    I’ve seen llvm do that.
<bwright>    sorry.
<roxfan>    compilers can also optimize switches into ifs
<bwright>    Oh ok cool. I noticed in an article I read GCC didn’t
<bsod2>    {[]{};}
<geordi>    <no output>
<Bigcheese_>    I doubt GCC doesn’t.
<bwright>    yes that is why I decided to ask here ^_^
<bsod2>    well a switch uses jumptables, while if’s can have different conditions in the chain
<bsod2>    so i doubt gcc ‘optimizes’ that
<bsod2>    << __GNUC__ << “.” << __GNUC_MINOR__ << “.” << __GNUC_PATCHLEVEL
<geordi>    error: ‘__GNUC_PATCHLEVEL’ was not declared in this scope
<bsod2>    << __GNUC__ << “.” << __GNUC_MINOR__ << “.” << __GNUC_PATCHLEVEL__
<geordi>    4.7.0
<bsod2>    yay the latest
<Bigcheese_>    geordi -v
<geordi>    g++ (GCC) 4.7.0 20110929 (experimental)
<Griwes>    well, –version :D
<bsod2>    oh it has -v :P
<Griwes>    xD
<Bigcheese_>    Yeah, it calls –version on gcc.
<Bigcheese_>    g++*
<bwright>    I enjoyed bsod2′s way better.
<Griwes>    I wish someone has grabbed him when his way worked
<bsod2>    i use those defines a lot these days
<bsod2>    to find out what version supports what features of c++11
<V-ille>    so not quite the latest
<bsod2>    4.5 had uniform initialization, 4.6 the ranged for, 4.7 std::thread
<V-ille>    that’s a moving target on 4.7
<V-ille>    because it’s still getting features in
<bsod2>    yea :)
<bsod2>    but with uniform init, auto vars, and ranged for, i’m already happy
<bsod2>    those things really change the way you write most simple vector<string> kinda programs
<V-ille>    4.7 has correct range-for
*    whaletechno_ is now known as whaletechno
<V-ille>    4.6 is draft-compatible
<bsod2>    oh, i see
<V-ille>    but not quite c++11-compatible
<V-ille>    with vector<string> it doesn’t matter
<kalven>    what changed?
<V-ille>    the way it invokes member .begin()/end() before trying ADL begin()/end()
<V-ille>    the older spec didn’t have the member calls
<V-ille>    the ADL may be ambiguous
<bsod2>    ah, ok, that is indeed better the new way
<bsod2>    i’ve been trying to get a decent check for c++11 in my configure.ac scripts
<bsod2>    but its not really … clean
<bsod2>    i know it’s off-topic :) but if anyone is interested i can put it on pastebin
<bsod2>    http://ideone.com/fBpDh
<BurnZeZ>    http://codepad.org/QnkSyCmS
<BurnZeZ>    wat
<melba>    nice
<x0rs_w>    Any guesses at why I might be getting this error for trying to pass a reference on line 16? http://ideone.com/9eoh2
<jgh->    holy cow
<Billiard>    BurnZeZ: this is a c++ channel
<BurnZeZ>    That’s not C++?
<Billiard>    correct
<BurnZeZ>    wat
<BurnZeZ>    Oh.
<PlasmaHH>    x0rs_w: you are doing it wrong
<BurnZeZ>    Derp.
<x0rs_w>    PlasmaHH, that would make sense. =)
<mgaunard_>    is it Java or C#?
<Billiard>    doesn’t matta
<Billiard>    !give x0rs_w testcase
<nolyc>    x0rs_w: Paste your test case (tick the compile checkbox!) to http://ideone.com/ or http://codepad.org. Using a recommended paste site increases the chances someone will take a look at it. Do _not_ paste to the channel. See the testcase checklist at http://www.eelis.net/iso-c++/testcase.xhtml .
<mgaunard_>    x0rs_w: Game is not declared.
<Billiard>    x0rs_w: you did not close the body of your SnakeHead class :3
<x0rs_w>    mgaunard_: I am including its header…?
<Billiard>    Error: … is not a valid c++ statement
<mgaunard_>    x0rs_w: that’s what the error says
<Billiard>    x0rs_w: just don’t bother talking about it until you provide a testcase pls
<x0rs_w>    Billiard, did not post entire class… still learning what to post in such a large program.
<x0rs_w>    Billiard, okay, have never done that, will figure it out
<Billiard>    x0rs_w: read the testcase checklist
<Billiard>    smallest amount of code which gives you the same error
<PlasmaHH>    x0rs_w: not much to learn. post a testcase
<x0rs_w>    PlasmaHH, paste 11 files of code including headers?
<x0rs_w>    PlasmaHH, how could it run the code without all the files?
<x0rs_w>    the paste site that is
<Billiard>    you don’t, you make a testcase
<melba>    x0rs_w, make something shot that gives the same error
<melba>    short
<x0rs_w>    This: http://ideone.com/cB1OL ?
<x0rs_w>    melba: oh I see

© 2011 Techdot IRC Resources Suffusion theme by Sayontan Sinha