I am implementing a library in C/C++11 and I have chosen to follow Google C++ Style Guide as I also use this style guide in my code.
As such all classes and types (including typedefs
and using
) start with a capital letter.
However I have reached a conflict when implementing some traits.
For instance I have a RemoveOptional
trait:
template <class T>
struct RemoveOptional {
using Type = T;
};
template <class T>
struct RemoveOptional<utils::Optional<T>> {
using Type = T;
};
that I can use like this:
utils::RemoveOptional<utils::Optinal<int>>::Type
But for the traits like IsXXX I have chosen to inherit std::true_type
or std::false_type
in order to be used like the std
traits:
template <class T>
struct IsOptional : std::false_type {
};
template <class T>
struct IsOptional<Optional<T>> : std::true_type {
};
so this trait is used like this:
utils::IsOptional<utils::Optional<int>>::value
utils::IsOptional<utils::Optional<int>>::value_type
And value_type
conflicts with my naming conventions as it should be ValueType
.
As far as I see I have 3 options:
Modify all of my traits to follow the
std
convention.- Advantages: my traits can be checked against the
std::true_type
andstd::false_type
. - Disadvantages: my library is inconsistent.
- Advantages: my traits can be checked against the
Discard the
std::true_type
andstd::false_type
and make all my traits following my convention.- Advantages: my library is consistent.
- Disadvantages: my traits can't be checked against
std::true_type
andstd::false_type
.
Leave as it is now.
- Advantages: my traits can be checked against
std::true_type
andstd::false_type
. - Disadvantages: my library is inconsistent (even my traits are inconsistent between each other).
- Advantages: my traits can be checked against
What should I do?