-using IsSplitTargetType = std::integral_constant<bool,
- std::is_arithmetic<T>::value ||
- std::is_same<T, StringPiece>::value>;
-
-template<bool exact = true,
- class Delim,
- class OutputType,
- class... OutputTypes>
-typename std::enable_if<IsSplitTargetType<OutputType>::value, bool>::type
-split(const Delim& delimiter,
- StringPiece input,
- OutputType& outHead,
- OutputTypes&... outTail);
+struct IsConvertible<
+ T,
+ decltype(static_cast<void>(
+ parseTo(std::declval<folly::StringPiece>(), std::declval<T&>())))> {
+ enum { value = true };
+};
+
+template <class... Types>
+struct AllConvertible;
+
+template <class Head, class... Tail>
+struct AllConvertible<Head, Tail...> {
+ enum { value = IsConvertible<Head>::value && AllConvertible<Tail...>::value };
+};
+
+template <>
+struct AllConvertible<> {
+ enum { value = true };
+};
+
+static_assert(AllConvertible<float>::value, "");
+static_assert(AllConvertible<int>::value, "");
+static_assert(AllConvertible<bool>::value, "");
+static_assert(AllConvertible<int>::value, "");
+static_assert(!AllConvertible<std::vector<int>>::value, "");
+
+template <bool exact = true, class Delim, class... OutputTypes>
+typename std::enable_if<
+ AllConvertible<OutputTypes...>::value && sizeof...(OutputTypes) >= 1,
+ bool>::type
+split(const Delim& delimiter, StringPiece input, OutputTypes&... outputs);