I have a class template similar to the one that follows below that is designed to contain some configuration settings used when parsing CSV files:
template <typename InputIterator = default_all>
class icsv_params
{
// Iterator to a data structure containing the columns
// that should be read.
typedef InputIterator iterator;
// This is a bitmask type.
typedef detail::icsv_op icsv_op;
static const icsv_op noqt = icsv_op(detail::csv_flags::noqt);
static const icsv_op quot = icsv_op(detail::csv_flags::quot);
static const icsv_op mmap = icsv_op(detail::csv_flags::mmap);
// The rest of the class definition isn't relevant.
};
Now, the template parameter is important when the user wishes to supply start and end iterators to a data structure containing the numbers of the columns that should be parsed; however, should the user fail to provide the iterators as parameters, the class should automatically assume that all of the columns should be parsed.
In the second case, the code to declare an instance of the class looks unwieldy:
icsv_params<> params(...);
Additionally, the bitmask types noqt
, quot
, and mmap
are used by this class only, so it makes sense to put them inside the class definition; however, should the user wish to use these bitmask types, the code to do so is also unwieldy:
icsv_params<> params(icsv_params<>::noqt);
How can I make it so that the user does not need to provide the angle brackets to indicate the absence of a template parameter? If there is no way to do so, what alternative would you suggest?