New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsigned long Maxcode = 0x10ffff #6050
Comments
That depends on the size of |
But whatever the type, it can convert to |
I understand, but if the suffix "UL" is added, then there is no question about what the type of the constant is, and there is no question that it can safely be used to initialize a template parameter formal of type unsigned long.
Thanks,
Robert
On Jan 18, 2023, at 9:33 AM, Jonathan Wakely ***@***.***> wrote:
The constant 0x10ffff is of type int.
That depends on the size of int. For an implementation where int is 16 bits, that constant will have type long.
—
Reply to this email directly, view it on GitHub<#6050 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A5KLPJZVL2ELBSKZG36VUA3WS75LZANCNFSM6AAAAAAT7ETXRQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I didn't mean to imply anything was incorrect. I was only trying to see if it could be made completely type-safe, with no need for any questions about conversion.
Thanks,
Robert
On Jan 18, 2023, at 9:37 AM, Jonathan Wakely ***@***.***> wrote:
But whatever the type, it can convert to unsigned long without changing the value. I'm not really persuaded that adding a suffix is more clear, and there's nothing incorrect about it.
—
Reply to this email directly, view it on GitHub<#6050 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A5KLPJ7YVHE777ZROULJ4TLWS75ZZANCNFSM6AAAAAAT7ETXRQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I appreciate the concern, but I don't think it is currently either incompletely type-safe of completely type-unsafe. I don't think this code raises any meaningful questions, as @jwakely pointed out. Yes, one could change it, but one could also just leave it as is. |
OK. I understand. Thanks!
Robert
On Jan 18, 2023, at 9:53 AM, Thomas Köppe ***@***.***> wrote:
I didn't mean to imply anything was incorrect. I was only trying to see if it could be made completely type-safe, with no need for any questions about conversion.
I appreciate the concern, but I don't think it is currently either incompletely type-safe of completely type-unsafe. I don't think this code raises any meaningful questions, as @jwakely<https://github.com/jwakely> pointed out. Yes, one could change it, but one could also just leave it as is.
—
Reply to this email directly, view it on GitHub<#6050 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A5KLPJ7CG7DJ4PY3OQYAZ33WS77VZANCNFSM6AAAAAAT7ETXRQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
The standard library specification assumes a conforming compiler; there is nothing wrong with "unsigned long Maxcode = 0x10ffff" beyond opinion-laden consideration of code aesthetics. |
Hello,
Today I am making my first posts to this group. Please forgive me if I make mistakes. Thank you.
Here is the context:
D.21.2 Header synopsis [depr.codecvt.syn]
namespace std {
enum codecvt_mode {
consume_header = 4,
generate_header = 2,
little_endian = 1
};
template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf8(size_t refs = 0);
~codecvt_utf8();
};
template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf16 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf16(size_t refs = 0);
~codecvt_utf16();
};
template<class Elem, unsigned long Maxcode = 0x10ffff, codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8_utf16 : public codecvt<Elem, char, mbstate_t> {
public:
explicit codecvt_utf8_utf16(size_t refs = 0);
~codecvt_utf8_utf16();
};
}
Yes, I know it is deprecated, but perhaps this is a more general question.
The constant 0x10ffff is of type int.
The template parameter formal Maxcode is of type unsigned long.
Would it be more clear and type-correct if the constant were 0x10ffffUL?
Thank you,
Robert Schwartz
The text was updated successfully, but these errors were encountered: