Remove initializer_list conversion due to the issues mentioned here:

http://stackoverflow.com/questions/18895583/convert-a-vectort-to-initializer-listt
This commit is contained in:
Jason Turner
2016-01-29 16:04:06 -07:00
parent 140a90f72a
commit b33f0a08bc
2 changed files with 0 additions and 84 deletions

View File

@@ -310,48 +310,6 @@ namespace chaiscript
private:
Callable m_func;
};
#ifndef CHAISCRIPT_MSVC_12
//http://stackoverflow.com/questions/18895583/convert-a-vectort-to-initializer-listt
constexpr size_t DEFAULT_MAX_LENGTH = 128;
template <typename V> struct backingValue { static V value; };
template <typename V> V backingValue<V>::value;
template <typename V, typename... Vcount> struct backingList { static std::initializer_list<V> list; };
template <typename V, typename... Vcount>
std::initializer_list<V> backingList<V, Vcount...>::list = { static_cast<Vcount>(backingValue<V>::value)... };
template <size_t maxLength, typename It, typename V = typename It::value_type, typename... Vcount>
static typename std::enable_if< sizeof...(Vcount) >= maxLength,
std::initializer_list<V> >::type generate_n(It begin, It end, It current)
{
throw std::length_error("More than maxLength elements in range.");
}
template <size_t maxLength = DEFAULT_MAX_LENGTH, typename It, typename V = typename It::value_type, typename... Vcount>
static typename std::enable_if< sizeof...(Vcount) < maxLength,
std::initializer_list<V> >::type generate_n(It begin, It end, It current)
{
if (current != end)
{
return generate_n<maxLength, It, V, V, Vcount...>(begin, end, ++current);
}
current = begin;
for (auto it = backingList<V, Vcount...>::list.begin();
it != backingList<V, Vcount...>::list.end();
++current, ++it)
*const_cast<V*>(&*it) = *current;
return backingList<V, Vcount...>::list;
}
template <typename It>
std::initializer_list<typename It::value_type> range_to_initializer_list(It begin, It end)
{
return detail::generate_n(begin, end, begin);
}
#endif
}
class Type_Conversions