Mercurial > code
changeset 660:913c8ef054d3
options: templatize initializer_list overload
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 16 Jul 2019 20:01:00 +0200 |
parents | e40d082f9161 |
children | a7ef5d868275 |
files | cpp/options/options.hpp |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/cpp/options/options.hpp Mon Jul 15 21:05:00 2019 +0200 +++ b/cpp/options/options.hpp Tue Jul 16 20:01:00 2019 +0200 @@ -1,5 +1,5 @@ /* - * options.hpp -- getopt(3) similar interface for C++ + * options.hpp -- C++ similar interface to getopt(3) * * Copyright (c) 2019 David Demelier <markand@malikania.fr> * @@ -21,9 +21,10 @@ /** * \file options.hpp - * \brief C++ alternative to getopt(3). + * \brief C++ similar interface to getopt(3). */ +#include <initializer_list> #include <stdexcept> #include <string> #include <string_view> @@ -32,7 +33,7 @@ #include <vector> /** - * \brief C++ alternative to getopt(3). + * \brief C++ similar interface to getopt(3). */ namespace options { @@ -127,7 +128,8 @@ * \param fmt the format string * \return the result */ -inline auto parse(std::initializer_list<std::string_view> args, std::string_view fmt) -> pack +template <typename String> +inline auto parse(std::initializer_list<String> args, std::string_view fmt) -> pack { return parse(args.begin(), args.end(), fmt); }