Skip to content

Commit 13cd075

Browse files
committed
Added Tips! section to README
1 parent ddb274c commit 13cd075

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Boost Software License 1.0
1010
* [Intro](#intro)
1111
* [Modifiers](#modifiers)
1212
* [Utilities](#utilities)
13+
* [Tips](#tips)
1314
* [Writing a modifier](#writing_modifier)
1415
* [Self test](#selftest)
1516
* [Other libraries](#other)
@@ -415,6 +416,22 @@ A number of small utilities are available directly in `strong_type/type.hpp`.
415416
416417
All `static_assert`s above pass.
417418
419+
# <A name="tips"></A>Tips!
420+
421+
## <A name="aliases"></A>Using aliases to define similar types
422+
423+
If you want several types that are, in essence, the same, but still distinguished
424+
as unique types, you can use an alias that takes a tag type. E.g.
425+
426+
```C++
427+
template <typename Tag>
428+
using counter = strong::type<uint64_t, Tag, strong::regular, strong::ordered, strong::incrementable, strong::equality_with<uint64_t>>;
429+
430+
using request_counter = counter<struct request_tag>;
431+
using error_counter = counter<struct error_tag>;
432+
using timeout_counter = counter<struct timeout_tag>;
433+
```
434+
418435
# <A name="writing_modifier"></A>Writing a modifier
419436

420437
A modifier is a nested structure. The outer type, a struct or class, is what

0 commit comments

Comments
 (0)