Introduction
The c++ (cpp) infix_configuration example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: C++ (Cpp)
Class/type: infix_configuration
Example#1File:
infix_configuration_hash.cppProject:
memsharded/dogen
std::size_t infix_configuration_hasher::hash(const infix_configuration& v) {
std::size_t seed(0);
combine(seed, v.first());
combine(seed, v.not_first());
combine(seed, v.not_last());
combine(seed, v.last());
return seed;
}
Example#2File:
sequence_formatter.cppProject:
pgannon/dogen
std::string sequence_formatter::
value_for_position(const infix_configuration& ic) const {
if (is_single()) {
if (!ic.first().empty()) {
// when we are single, first takes priority if supplied.
return ic.first();
}
return ic.last();
} else if (is_first() && !ic.first().empty()) {
// if is first and first has been supplied, it takes precedence.
return ic.first();
} else if (!is_last() && !ic.not_last().empty()) {
// if we are not last (including first) and not last has been
// supplied.
return ic.not_last();
} else if (!is_first() && (!is_last() || !ic.not_first().empty())) {
// when we are last, not first takes precedence if supplied.
return ic.not_first();
} else if (is_last())
return ic.last();
return empty;
}