Skip to content

Create new type from existing type without changing the interface.

License

Notifications You must be signed in to change notification settings

Enhex/strong_type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

strong_type

Create new type from existing type without changing the interface.

You only need to include strong_type.h.

Example

#include <strong_type.h>
#include <iostream>

STRONG_TYPE(StrongInt, int);

void print(StrongInt& x) {
	std::cout << x << std::endl;
}

int main()
{
	int i = -1;
	StrongInt si(1);

	print(si);
	print(i);	// Compilation error, StrongInt and int are different types
}

For more examples see this.

License

MIT

About

Create new type from existing type without changing the interface.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published