Issue 10127 - TypeEnum in std.variant
Summary: TypeEnum in std.variant
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-21 01:24 UTC by Diggory
Modified: 2024-12-01 16:17 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Diggory 2013-05-21 01:24:15 UTC
It would be useful to use the tag part of a tagged union on its own, and it would fit in well with the rest of std.variant.

It's not always the case that you want to store actual data, sometimes you just need to store the type. Also sometimes you need to store the data somewhere else or store it in such a way that you can specify the type first and fill in the data later.

eg.
	alias TypeEnum!(
		void,
		byte,
		short,
		string,
		Object
	) TestTypeEnum;
	
	TestTypeEnum test;
	
	assert(test == TestTypeEnum.from!void);
	assert(test != TestTypeEnum.from!byte);
	
	test = TestTypeEnum.from!string;
	
	assert(test == TestTypeEnum.from!string);
	assert(test != TestTypeEnum.from!Object);
	
	static assert(!__traits(compiles, TestTypeEnum.from!float));

(pull request shortly)
Comment 2 dlangBugzillaToGithub 2024-12-01 16:17:37 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9975

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB