What is the exact meaning in C++ of these escape sequences (\n, \t, \v) in comments?

Eldinur

I was reading through the Working Draft of C++ and was surprised when I came across the seemingly simplest feature of programming: Comments! (and even more surprised that I didn't find anything about the behavior of escape sequences in comments!)

Quote from the C++ draft:

If there is a form-feed or a vertical-tab character in such a comment, only whitespace characters shall appear between it and the new-line that terminates the comment; no diagnostic is required.

I struggle in what exactly is meant by this quote.

I came up with this:

// This is a comment\f \tThis is still part of the comment\nThis is not part of the comment

As it seems, escape sequences have influences on comments, so I played around with it for a while but didn't come to a major conclusion.

// This is a comment\nThis is not part of the comment

As they say in the draft:

which terminates immediately before the next new-line character

So I figured, if I just put a newline character in the comment myself, the rest of the comment doesn't get treated as a 'comment'? But it kind of does..? What is the deal with that?

Ted Lyngmo

"If there is a form-feed or a vertical-tab character in such a comment, only whitespace characters shall appear between it and the new-line that terminates the comment; no diagnostic is required."

This talks about literal form-feed and vertical-tab characters, not escape sequences (which are not interpreted in comments).

A valid comment:

// comment<a literal vertical-tab><whitespaces...><newline>

Also valid:

// hello\f\f\f\fworld<newline>

Here's an invalid comment, because the vertical-tab is followed by something else than only whitespace characters before the newline:

// comment<a literal vertical-tab><whitespaces...>FOO<newline>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the exact meaning of the QuickSFV comments at the end of an SFV file?

Using the '\n' and '\t' escape sequences in Decimal Format?

What is the exact meaning of delegate() method in C#?

what is the exact meaning of ping -A

What is the exact meaning of instantiate in JAVA

What's the exact meaning of iota?

What is the exact meaning of Git Bash?

What is the exact meaning of the perpendicularLinks attribute?

What is the Exact Use and Meaning of "IFS=!"

Datatype of escape sequences in c++

What's the meaning of zsh's default IFS=$' \t\n\C-@' , the "\C-@" part

What is difference between escape sequences and string operator?

Terminal escape sequences: why don't terminals report what features they support, instead of relying on terminfo?

What is the exact meaning of the JPA @Entity annotation?

What is the exact meaning of this example using delegate()?

What is the exact meaning of %%BoundingBox and %ImageData in an EPS file

What is the exact meaning of static fields in Java?

What is the exact meaning of 'emit' in Android Jetpack Compose?

What is exact meaning of "kitchen sink" in programming?

What's the exact meaning of "session" in haproxy?

What is the exact meaning of {xor} in this specific situation?

What is the exact meaning of this Apple Diagnostics code?

What is the exact meaning of NumConflicts in CP-Sat?

What is the exact meaning of localhost on the operating system?

What is the exact meaning of the equal sign in Elixir?

I wonder what is exact meaning of "return"

Why don't escape sequences work in tuples

How can I instruct BSD sed to interpret escape sequences like \n and \t?

C: Writing a macro to build string escape sequences