Prevent IsOneOf unused template specialization instantiation
authorstryku <stryku2393@gmail.com>
Fri, 28 Jul 2017 20:05:08 +0000 (13:05 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 28 Jul 2017 20:05:40 +0000 (13:05 -0700)
commit160f868c3f824c2abcb11a80d6c3b27a162f3710
tree6ba20ba6b9102caefcd0379ada183deca31ee190
parent45245cb293e3c61deb8b952956507b62e88b0cf9
Prevent IsOneOf unused template specialization instantiation

Summary:
Current `IsOneOf` implementation does unnecessary work because it instantiates all of the possible template specializations, even if type is same as the first of the tested ones. E.g.
`IsOneOf<char, char, int, float>` will instantiate:
```
IsOneOf<char, char, int, float>
IsOneOf<char, char, int>
IsOneOf<char, char>
IsOneOf<char>
```

With the proposed inheritance, compiler will stop initializing at the first match.
Closes https://github.com/facebook/folly/pull/643

Reviewed By: ericniebler

Differential Revision: D5482783

Pulled By: yfeldblum

fbshipit-source-id: 3d04c750ce72fa9b19b4d0588cccfb396a9e0715
folly/Traits.h