configuration: support multiple configuration files

This commit is contained in:
Andrzej Rybczak
2014-11-15 15:07:49 +01:00
parent 8745523170
commit 38d9f811de
8 changed files with 61 additions and 18 deletions

View File

@@ -106,8 +106,18 @@ struct option_parser
m_defined = true;
}
bool defined() const { return m_defined; }
void run_default() const { m_default(); }
bool defined() const
{
return m_defined;
}
void run_default()
{
if (m_defined)
throw std::runtime_error("option already defined");
m_default();
m_defined = true;
}
private:
bool m_defined;

View File

@@ -32,8 +32,8 @@ template <size_t N> size_t const_strlen(const char (&)[N]) {
}
// it's present in boost for std::string, but we want more general version.
template <typename CollectionT, typename StringT>
StringT join(CollectionT &&collection, StringT &&separator)
template <typename StringT, typename CollectionT>
StringT join(const CollectionT &collection, const StringT &separator)
{
StringT result;
auto first = std::begin(collection), last = std::end(collection);