language-lawyer

Is it a defect about deducing template arguments for function parameter pack

时光毁灭记忆、已成空白 提交于 2020-08-07 21:28:47
问题 template<typename...T> void func(T...args){ } int main(){ func(1,2.0,'c'); } Consider the above code, there's a rule that applied to it to deduce these template arguments for this function template (call). It is: temp.deduct.call#1 For a function parameter pack that occurs at the end of the parameter-declaration-list, deduction is performed for each remaining argument of the call, taking the type P of the declarator-id of the function parameter pack as the corresponding function template

Can std::byte replace std::aligned_storage?

自古美人都是妖i 提交于 2020-08-07 20:03:36
问题 C++17 introduced a new type, std::byte , so now we finally have a first-class citizen type to represent bytes in memory. Besides being a novelty in the standard, the C++ rules for object creation, start and end of life, aliasing etc. are fairly complicated an unintuitive most of the times, so whenever I feel std::byte is the right tool I also get nervous and reluctant to use it, for fear of unintentionally summoning the Undefined Behavior Balrogs. One such case is a buffer to be used with

Can std::byte replace std::aligned_storage?

浪尽此生 提交于 2020-08-07 20:01:33
问题 C++17 introduced a new type, std::byte , so now we finally have a first-class citizen type to represent bytes in memory. Besides being a novelty in the standard, the C++ rules for object creation, start and end of life, aliasing etc. are fairly complicated an unintuitive most of the times, so whenever I feel std::byte is the right tool I also get nervous and reluctant to use it, for fear of unintentionally summoning the Undefined Behavior Balrogs. One such case is a buffer to be used with

Is the array to pointer decay changed to a pointer object?

a 夏天 提交于 2020-08-06 07:33:40
问题 int a[] = {1, 2 ,3}; I understand that array names are converted to pointers. A term often used is that they decay to pointers. However to me, a pointer is a region of memory that holds the address to another region of memory, so: int *p = a; can be drawn like this: ----- ----- p ---------> a[0]. ..... ----- ----- 0x1 0x9 But a itself is not pointing to another region of memory, it IS the region of memory itself. So when the compiler converts it to a pointer, does it save it (like p )

Is an int variable an object, according to the C++ Standard?

时光怂恿深爱的人放手 提交于 2020-08-04 18:47:10
问题 Below you'll find the definition of object in C++ Standard. [intro.object]/1: The constructs in a C++ program create, destroy, refer to, access, and manipulate objects. An object is created by a definition (6.1), by a new-expression (8.3.4), when implicitly changing the active member of a union (12.3), or when a temporary object is created (7.4, 15.2). An object occupies a region of storage in its period of construction (15.7), throughout its lifetime (6.8), and in its period of destruction

On the practical advantage to C99's array size “guarantee” feature in function parameters?

谁说胖子不能爱 提交于 2020-08-04 14:34:21
问题 C99 introduced a new function argument notation where the static keyword can be used to specify that the argument has at least N elements. 6.7.6.3 Function declarators, p7 A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function,

On the practical advantage to C99's array size “guarantee” feature in function parameters?

匆匆过客 提交于 2020-08-04 14:32:31
问题 C99 introduced a new function argument notation where the static keyword can be used to specify that the argument has at least N elements. 6.7.6.3 Function declarators, p7 A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function,

On the practical advantage to C99's array size “guarantee” feature in function parameters?

≡放荡痞女 提交于 2020-08-04 14:32:28
问题 C99 introduced a new function argument notation where the static keyword can be used to specify that the argument has at least N elements. 6.7.6.3 Function declarators, p7 A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function,

How to use Intel TSX with C++ memory model?

*爱你&永不变心* 提交于 2020-08-04 05:30:07
问题 I think C++ does not cover any sort of transaction memory yet, but still TSX can somehow fit using " as if rule" into something that is governed by C++ memory model. So, what happens on successful HLE operation, or successful RTM transaction? Saying "there is data race, but it is ok" is not much helpful, as it does not clarify what "ok" means. With HLE probably it can be seen as "previous operation happens before subsequent operation. As if the section was still guarded by the lock that was

Is it legal to declare a type as part of the template-argument for a type template-parameter?

半城伤御伤魂 提交于 2020-08-04 04:29:21
问题 All standard references below refers to N4659: March 2017 post-Kona working draft/C++17 DIS. The following snippet successfully compiles for all standard versions (1) for both Clang and GCC. template<typename Tag> struct Tagged {}; Tagged<struct Tag1> t1; Tagged<struct Tag2> t2; [temp.arg.type]/1 requires that A template-argument for a template-parameter which is a type shall be a type-id . and [temp.arg.type]/2 contains the note [  Note: A template type argument may be an incomplete type (