[Feature] Default template arguments
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
The issue defines the requested default-template syntax through the Array and Optional examples, but names no source files, tests, or parser entry points. Start by locating the template parsing and type-resolution code, then identify existing tests for template arguments. Done means omitted arguments use their declared defaults while explicitly supplied arguments still override them.
Written by the indexing model from the issue text.
Description
What feature would you like to see?
Overrideable default values for template arguments like in C++.
struct Array<T = u32, auto Size = 10> {
T data[Size];
};
How will this feature be useful to you and others?
I have a large number of "optional" structs in my patterns
struct Optional<T, U> {
U isSome;
if (isSome != 0) {
T data;
}
};
99% of the time U is a u8, but sometimes it is a u32. It would be nice to only have to specify U in the rare case rather than every time.
struct Optional<T, U = u8> {
U isSome;
if (isSome != 0) {
T data;
}
};
Optional<SomeOtherStruct> common_optional @ 0x00;
Optional<SomeOtherStruct, u32> uncommon_optional @ 0x10;
Request Type
- I can provide a PoC for this feature or am willing to work on it myself and submit a PR
Additional context?
No response
- Dominant language
- C++
- Stars
- 275
- Forks
- 75
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WerWolv/PatternLanguage
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
WerWolv/PatternLanguage#236 · 12 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WerWolv/PatternLanguage#226 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
WerWolv/PatternLanguage#221 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
WerWolv/PatternLanguage#219 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
WerWolv/PatternLanguage#218 ·
All issues in WerWolv/PatternLanguage
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·