Remove `get_type_index` in favour of more standard `which()`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 384
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
`get_type_index` returns index in reversed order which is confusing.
`which` method is complaint with `boost::variant`.
In order to remove `get_type_index` we need to address last remaining issue - `invalid_type` value.
Proposed solution:
``` c++
invalid_type == sizeof(Types...) + 1
```
``` c++
// relevant test that needs upgrading
REQUIRE(variant_type{mapbox::util::no_init()}.get_type_index() == mapbox::util::detail::invalid_value);
```
Contributor guide
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.
Research direction
Start by locating get_type_index, which(), invalid_type/invalid_value, and the cited variant_type no_init test. Update the relevant test and behavior so invalid_type follows the proposed sizeof(Types...) + 1 value and get_type_index can be removed in favor of which(); done when the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100