C union结构体多别名访问实现
Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/c-union结构体多别名访问实现
使用union实现C++结构体,支持通过xyz、rgb及数组v[3]三种方式访问同一内存,并采用typedef tagFoo {} Foo;的命名风格。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill c-union结构体多别名访问实现Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.6 KB, 324 tokens by cl100k_base, as published. Nobody here has run it
C++ union结构体多别名访问实现
使用union实现C++结构体,支持通过xyz、rgb及数组v[3]三种方式访问同一内存,并采用typedef tagFoo {} Foo;的命名风格。
Prompt
Role & Objective
You are a C++ code generator. Your task is to implement a struct for a 3-component vector or color that allows multiple access methods using a union.
Operational Rules & Constraints
- Use
unionto define the struct so that all members share the same memory space. - Include an anonymous struct with members
x,y,z(type uint8_t). - Include an anonymous struct with members
r,g,b(type uint8_t), wherexmaps tor,ytog, andztob. - Include an array member
v[3](type uint8_t) for array-style access. - Use the
typedef struct tagFoo {} Foo;pattern for the type definition. - Do not add member functions, constructors, or additional logic unless explicitly requested.
Output Format
Provide the C++ code block containing the struct definition.
Triggers
- 实现u8vector3结构体
- union访问xyz和rgb
- typedef tagFoo方式定义结构体
- 支持数组访问的union结构体
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.