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. Other Discussions
  3. Site Bugs / Suggestions
  4. C++ Code formatting for templates auto-adds weird default value

C++ Code formatting for templates auto-adds weird default value

Scheduled Pinned Locked Moved Site Bugs / Suggestions
c++wpfcomarchitectureannouncement
14 Posts 4 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 Chris Maunder

    If you post just "template <class T>" then yes, the message process will consider is s HTML and will attempt to "fix" it. If you wrap it in <PRE> tags then it won't. If you want to be able to post stuff that has <'s in it without the message system thinking it's HTML then check the "Treat my content as plain text, not as HTML" checkbox in the Options section just above the "Post Message" button at the bottom.

    cheers Chris Maunder

    B Offline
    B Offline
    Brisingr Aerowing
    wrote on last edited by
    #5

    I have seen this happen even if it is in pre tags. There is also the auto-tag-close thing that also happens in pre tags. Neither of these always happens, but the do happen.

    What do you get when you cross a joke with a rhetorical question?

    S 1 Reply Last reply
    0
    • B Brisingr Aerowing

      I have seen this happen even if it is in pre tags. There is also the auto-tag-close thing that also happens in pre tags. Neither of these always happens, but the do happen.

      What do you get when you cross a joke with a rhetorical question?

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

      Brisingr Aerowing wrote:

      I have seen this happen even if it is in pre tags.

      Which is exactly what I was complaining about - if I enclose something with <pre lang="c++">...</pre>, then I want it formatted as code, not HTML. Enclosing it in text tags instead defeats the purpose.

      Brisingr Aerowing wrote:

      There is also the auto-tag-close thing that also happens in pre tags.

      Yup. When HTML finds anything that it thinks are tags - even though the text is enclosed in pre tags! - then it will swallow those presumed tags, and also auto-add closing tags at the end. This is rather annoying when you try to format code containing #include directives or template arguments! I've written many solutions and answers containing such code and now am used to use the > and < HTML tags within the code rather than using < and >, but the problem is that even a small typo can break code, and due to the HTML eating bits of code it's often impossible to just copy & paste the actual code - you have to modify it!

      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

      C 1 Reply Last reply
      0
      • S Stefan_Lang

        Brisingr Aerowing wrote:

        I have seen this happen even if it is in pre tags.

        Which is exactly what I was complaining about - if I enclose something with <pre lang="c++">...</pre>, then I want it formatted as code, not HTML. Enclosing it in text tags instead defeats the purpose.

        Brisingr Aerowing wrote:

        There is also the auto-tag-close thing that also happens in pre tags.

        Yup. When HTML finds anything that it thinks are tags - even though the text is enclosed in pre tags! - then it will swallow those presumed tags, and also auto-add closing tags at the end. This is rather annoying when you try to format code containing #include directives or template arguments! I've written many solutions and answers containing such code and now am used to use the > and < HTML tags within the code rather than using < and >, but the problem is that even a small typo can break code, and due to the HTML eating bits of code it's often impossible to just copy & paste the actual code - you have to modify it!

        GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

        C Offline
        C Offline
        Chris Maunder
        wrote on last edited by
        #7

        Stefan_Lang wrote:

        When HTML finds anything that it thinks are tags - even though the text is enclosed in pre tags!

        What's meant to happen is that all HTML tags within PRE blocks except for I,U and B get auto-encoded so the processor doesn't see them as HTML anymore. Clearly Possibly a bug. I'll dig in and see what's happening. [Edit] However, I can't replicate the issue at this point Test:

        #include

        cheers Chris Maunder

        S B 2 Replies Last reply
        0
        • C Chris Maunder

          Stefan_Lang wrote:

          When HTML finds anything that it thinks are tags - even though the text is enclosed in pre tags!

          What's meant to happen is that all HTML tags within PRE blocks except for I,U and B get auto-encoded so the processor doesn't see them as HTML anymore. Clearly Possibly a bug. I'll dig in and see what's happening. [Edit] However, I can't replicate the issue at this point Test:

          #include

          cheers Chris Maunder

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

          trying to reproduce... Test: copy paste from text editor, click elsewhere (auto-closes 'Paste-as' dialog), then select and enclose in <pre>

          #include
          template
          class myT {
          T var;
          };

          Test 2: copy from within unsent post, including pre tags

          #include
          template
          class myT {
          T var;
          };

          Test 3: copy from within unsent post, excluding pre tags, use paste as code

          #include <string>
          template <class T>
          class myT {
          T var;
          };

          Edit: ok, all seems to work, except pasting as codeblock uses C# formatting by default. Also the C# formatting automatically replaced the < and > tokens with the corresponding HTML tags automatically. Another test: typing (not copying) same code, then enclose in pre

          #include
          template
          class myT {
          var T;
          };

          At this point I'm running out of ideas - maybe it's only in some forums ? I've noticed it in Q&A, will go test there... Edit 2: Tried 'improving' a solution of mine in Q&A, but couldn't reproduce the issue. I'll bookmark this thread and come back when i find an example that can be reproduced. Edit 3: Another test, trying to reproduce the problem i just faced in Q&A:

          template
          class myT {
          T var;
          public:
          void hello();
          };
          void foo() {
          myT x;
          x.hello();
          }

          The function myT::hello().

          GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

          1 Reply Last reply
          0
          • C Chris Maunder

            Stefan_Lang wrote:

            When HTML finds anything that it thinks are tags - even though the text is enclosed in pre tags!

            What's meant to happen is that all HTML tags within PRE blocks except for I,U and B get auto-encoded so the processor doesn't see them as HTML anymore. Clearly Possibly a bug. I'll dig in and see what's happening. [Edit] However, I can't replicate the issue at this point Test:

            #include

            cheers Chris Maunder

            B Offline
            B Offline
            Brisingr Aerowing
            wrote on last edited by
            #9

            It seems to happen randomly. I never know when it will hit.

            /// /// Adds all to .
            ///
            public static void AddRange(this ICollection list, IEnumerable elements)
            {
            foreach (T o in elements)
            list.Add(o);
            }

            template function_declaration;
            template function_declaration;

            //This example throws the following error : call of overloaded 'max(double, double)' is ambiguous
            template
            Type max(Type a, Type b) {
            return a > b ? a : b;
            }

            What do you get when you cross a joke with a rhetorical question?

            C 1 Reply Last reply
            0
            • B Brisingr Aerowing

              It seems to happen randomly. I never know when it will hit.

              /// /// Adds all to .
              ///
              public static void AddRange(this ICollection list, IEnumerable elements)
              {
              foreach (T o in elements)
              list.Add(o);
              }

              template function_declaration;
              template function_declaration;

              //This example throws the following error : call of overloaded 'max(double, double)' is ambiguous
              template
              Type max(Type a, Type b) {
              return a > b ? a : b;
              }

              What do you get when you cross a joke with a rhetorical question?

              C Offline
              C Offline
              Chris Maunder
              wrote on last edited by
              #10

              Let me know when you can replicate it.

              cheers Chris Maunder

              S 4 Replies Last reply
              0
              • C Chris Maunder

                Let me know when you can replicate it.

                cheers Chris Maunder

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

                Can't exactly replicate, but in my last attempt got different errors, trying to post this:

                template
                class myT {
                T var;
                public:
                void hello();
                };
                void foo() {
                myT x;
                x.hello();
                }

                The function myT::hello().

                GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

                1 Reply Last reply
                0
                • C Chris Maunder

                  Let me know when you can replicate it.

                  cheers Chris Maunder

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

                  In my recent reply (I deliberately did not edit it), the last case of <int> has been eaten by HTML - although it's actually still in the original text!

                  GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

                  1 Reply Last reply
                  0
                  • C Chris Maunder

                    Let me know when you can replicate it.

                    cheers Chris Maunder

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

                    Here's another formatting issue for C++ code: a triple slash followed by anything containing either a 'less' sign or the associated html tag, leads to the remainder of the code being greyed out! Not even sure why any parts of C++ code should be greyed out!? Interestingly, the part before the less sign is correctly formatted in green, as a comment, although the leading triple slash is still grey :confused: Here's an example:

                    void foo() {
                    /// some < meaningful code
                    some = more + code;
                    }

                    GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      Let me know when you can replicate it.

                      cheers Chris Maunder

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

                      And another occurence, this time concerning dynamic_cast template arguments. In the solution I posted here[^], I tried to post code containing

                      dynamic_cast<some_type*>(some_pointer);

                      but what I got - even after an attempt to correct it - was

                      dynamic_cast(some_pointer);

                      I needed to replace the < and > tokens by the corresponding HTML tags to fix it! Test to replicate:

                      dynamic_cast(some_pointer)

                      P.S.: Test failed - couldn't replicate :(

                      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                      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