Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Obscure C++ Features [from the newsletter]

Obscure C++ Features [from the newsletter]

Scheduled Pinned Locked Moved The Lounge
c++comquestion
19 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C CPallini

    Code reviews are for sissies. :-\

    Veni, vidi, vici.

    N Offline
    N Offline
    Nagy Vilmos
    wrote on last edited by
    #6

    I don't know, it take some balls to tell someone their code sucks. Except for Griff, that's a given.

    Reality is an illusion caused by a lack of alcohol

    OriginalGriffO 1 Reply Last reply
    0
    • N Nagy Vilmos

      I don't know, it take some balls to tell someone their code sucks. Except for Griff, that's a given.

      Reality is an illusion caused by a lack of alcohol

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #7

      OI! I don't suck balls!

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      N 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        OI! I don't suck balls!

        The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

        N Offline
        N Offline
        Nagy Vilmos
        wrote on last edited by
        #8

        Your code however...

        Reality is an illusion caused by a lack of alcohol

        OriginalGriffO 1 Reply Last reply
        0
        • N Nagy Vilmos

          Your code however...

          Reality is an illusion caused by a lack of alcohol

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #9

          Oh, that? It suckzorz donkey balls. :laugh:

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Thank elephant for that! Use most of those, and you deserve to be shot...

            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

            K Offline
            K Offline
            Kenneth Haugland
            wrote on last edited by
            #10

            That might be so, but I think their program still would execute, and not the person :sigh:

            1 Reply Last reply
            0
            • L Lost User

              Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

              G Offline
              G Offline
              Gary Wheeler
              wrote on last edited by
              #11

              I will confess to having used two of those practices, but I washed my hands afterwards.

              Software Zen: delete this;

              1 Reply Last reply
              0
              • L Lost User

                Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

                G Offline
                G Offline
                Gregory Gadow
                wrote on last edited by
                #12

                I remember the redefinition of keywords: a friend of mine has some headers that let him compile and run simple Pascal programs using C.

                A 1 Reply Last reply
                0
                • L Lost User

                  Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

                  S Offline
                  S Offline
                  Single Step Debugger
                  wrote on last edited by
                  #13

                  Most of these(except templates tricks etc.) has nothing to do with C++, but are inherited C constructions. And some of them are quite useful in system programing.

                  There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.

                  1 Reply Last reply
                  0
                  • L Lost User

                    Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

                    Y Offline
                    Y Offline
                    YDaoust
                    wrote on last edited by
                    #14

                    I was quite delighted to discover among the alternate operator tokens keywords for &&, || and !. I never really liked these "rude" logical operators and this gave me a sufficient incentive to switch to the nicer litteral representation. Isn't that beautiful ?

                    if (i < N and not Odd(A[i]))

                    I will not embrace the tokens for &, | and ~, as these correspond to bitwise operators which are more arithmetic in essence and compare to the usual +, -, *, /. Even less the _eq forms, which in my opinion are misnomers: f.i. or_eq should read bitor_eq.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

                      S Offline
                      S Offline
                      SeattleC
                      wrote on last edited by
                      #15

                      Obscure, you say? How about ... The comma operator; result = a , b; computes a, discards it, computes b, and assigns b to result. C++ (and C)'s hidden operator language; Conditional operator result = a ? b : c; evaluates a, then evaluates b if a is nonzero, or else evaluates c. The comma operator above as a way to do sequences as an expression. All C++ is missing is a value-returning loop. I do second the motion for method pointers as the most obscure and underused (but useful) aspect of C++. Or maybe virtual multiple inheritance, which can get mind-bendingly complex in examples I've seen in the wild.

                      1 Reply Last reply
                      0
                      • G Gregory Gadow

                        I remember the redefinition of keywords: a friend of mine has some headers that let him compile and run simple Pascal programs using C.

                        A Offline
                        A Offline
                        all_in_flames
                        wrote on last edited by
                        #16

                        I remember this one from a C++ course I took:

                        #define ;; ever;

                        Which of course allowed infinite for loops to be coded as

                        for(ever) {...}

                        W 1 Reply Last reply
                        0
                        • A all_in_flames

                          I remember this one from a C++ course I took:

                          #define ;; ever;

                          Which of course allowed infinite for loops to be coded as

                          for(ever) {...}

                          W Offline
                          W Offline
                          w peuker
                          wrote on last edited by
                          #17

                          You mean

                          #define ever ;;

                          1 Reply Last reply
                          0
                          • L Lost User

                            Link[^] Can't we find some things that are more obscure? I had heard of most of those (11 out of 14), and I'm not even really a C++ programmer.

                            S Offline
                            S Offline
                            Stefan_Lang
                            wrote on last edited by
                            #18

                            I've tried my hand at redefining the comma operator[^] after I've seen it in Blitz++ and Boost::Spirit (!). But I eventually discarded the idea due to various problems. I tried metaprogramming (the factorial implementation), but only for instructional purposes, not for real use. What I actually use in real code: 1. I do overload ++ and -- (pre and postfix both) a lot. 2. I did use in-place new and explicit call of destructor for the implementation of a memory pool. I don't see anything wrong with that as there really is no other good way to allocate memory for C++ objects and ensure proper initialization. (and cleaning up after release, without freeing the memory) 3. I do use static methods occasionally. But I wonder why they are on the "obscure features list" to start with. Of the remaining features listed in that article, I would indeed consider them obscure as I either wasn't aware them, or never found a useful application. ;) Passing a function as a template parameter is the only feature of these that I would consider useful, although I haven't actually used it myself. If you want an equally or more obscure feature, the only thing I can think of from the top of my head are trigraphs. (see http://www.gotw.ca/gotw/086.htm[^] - it also contains examples for some items already on the list)

                            G 1 Reply Last reply
                            0
                            • S Stefan_Lang

                              I've tried my hand at redefining the comma operator[^] after I've seen it in Blitz++ and Boost::Spirit (!). But I eventually discarded the idea due to various problems. I tried metaprogramming (the factorial implementation), but only for instructional purposes, not for real use. What I actually use in real code: 1. I do overload ++ and -- (pre and postfix both) a lot. 2. I did use in-place new and explicit call of destructor for the implementation of a memory pool. I don't see anything wrong with that as there really is no other good way to allocate memory for C++ objects and ensure proper initialization. (and cleaning up after release, without freeing the memory) 3. I do use static methods occasionally. But I wonder why they are on the "obscure features list" to start with. Of the remaining features listed in that article, I would indeed consider them obscure as I either wasn't aware them, or never found a useful application. ;) Passing a function as a template parameter is the only feature of these that I would consider useful, although I haven't actually used it myself. If you want an equally or more obscure feature, the only thing I can think of from the top of my head are trigraphs. (see http://www.gotw.ca/gotw/086.htm[^] - it also contains examples for some items already on the list)

                              G Offline
                              G Offline
                              Gorpik
                              wrote on last edited by
                              #19

                              It is not static methods, but the fact that static methods can be called through an instance of a class, instead of just the class itself, that is considered obscure in the list.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups