Класс является целым числом, если вы переносите переменную в as.character as.date можете ее прочитать.
sapply(data, class)
data$date.of.review <- as.Date(as.character(data$Date_String), "%Y%m%d")
data
Просто используйте два пакета параметров:
template<typename Bar, typename... Bars, typename Input, typename... Inputs>
std::string foo(const Input &input, const Inputs &... inputs)
{
std::string result(Bar::get_name());
result.append(input);
if constexpr (sizeof...(inputs) > 0)
result.append(foo<Bars...>(inputs...));
return result;
}
Не знаете, что вы хотите ...
Если Result
и Input
являются типами, а не параметрами шаблона, и вы хотите, чтобы шаблон foo()
получал столько Input
объекты шаблона, вы можете начать с настраиваемого параметра шаблона GetFirst
, чтобы выбрать первый параметр шаблона в вариационном списке
template <typename T0, typename ...>
struct GetFirst
{ using type = T0; };
и записать foo()
следующим образом
template <typename ... Bars>
Result foo (typename GetFirst<Input, Bars>::type const & ... is)
{
// something with is...
return {};
}
Итак, у вас есть
//foo<long, long long>(Input{}, Input{}, Input{}); // compilation error
foo<int, long, long long>(Input{}, Input{}, Input{}); // compiles
//foo<int, long, long long>(Input{}, Input{}); // compilation error
Если вы хотите рекурсивно управлять одиночным is...
, вы можете записать foo()
следующим образом
template <typename, typename ... Bars>
Result foo (Input const & i0,
typename GetFirst<Input, Bars>::type const & ... is)
{
// do something with i0
return foo<Bars...>(is...);
}
, но вам также нужно шаблон основного фрейма foo()
для прекращения рекурсии; Я предлагаю foo()
, которые получают параметр нестандартного шаблона со значением по умолчанию (для перехвата Bars...
, когда список пуст)
template <int = 0>
Result foo ()
{ return {}; }
Ниже приведен полный, возможно, глупый, но компилирующий пример
struct Input { };
struct Result { };
template <typename T0, typename ...>
struct GetFirst
{ using type = T0; };
// ground case
template <int = 0>
Result foo ()
{ return {}; }
// recursive case
template <typename, typename ... Bars>
Result foo (Input const & i0,
typename GetFirst<Input, Bars>::type const & ... is)
{
// do something with i0
return foo<Bars...>(is...);
}
int main()
{
//foo<long, long long>(Input{}, Input{}, Input{}); // compilation error
foo<int, long, long long>(Input{}, Input{}, Input{}); // compiles
//foo<int, long, long long>(Input{}, Input{}); // compilation error
}
if constexpr
. Можете ли вы использовать C ++ 17, или вы можете использовать только C ++ 11? – r3mus n0x 13 July 2018 в 20:36