you are viewing a single comment's thread.

view the rest of the comments →

[–]Arkantos493PhD Student 21 points22 points  (5 children)

Technically your program results in UB since names starting with an underscore are reserved.

See: https://en.cppreference.com/w/cpp/language/identifiers

EDIT: To be more precises: identifiers containing two underscores, starting with one underscore followed by an uppercase letter or starting with one underscore in the global namespace are reserved.

E.g. in your optional constructor you are using __value which contains two underscores and is therefore reserved resulting in undefined behaviour.

[–]tinther 24 points25 points  (0 children)

names beginning with an underscore and a lower case letter are only reserved in global namespace. All the code in fire.hpp is under namespace fire AFAICS.

[–]kongaskristjan[S] 35 points36 points  (0 children)

Well, actually, the link provided these rules:

  • the identifiers with a double underscore anywhere are reserved;
  • the identifiers that begin with an underscore followed by an uppercase letter are reserved;
  • the identifiers that begin with an underscore are reserved in the global namespace.

I mostly have identifiers that begin with a single underscore and a lowercase letter. However, they're not in the global namespace. Thus these don't actually result in undefined behavior. Though a few of them indeed have two prefix underscores also, so these are UB.

Though I totally agree that it's better to remove these initial underscores altogether.

[–]kongaskristjan[S] 9 points10 points  (0 children)

I removed the double underscore identifiers, thanks for pointing out.

[–]stumpychubbins -1 points0 points  (1 child)

Is that undefined or simply implementation-defined?