mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
refs #311 added initializer_list constructors in containers
This commit is contained in:
@@ -15,9 +15,20 @@
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
#include <iterator>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Private
|
||||
{
|
||||
// Trait to exclude std::initializer_list from the overload set of CRange conversion operators using SFINAE.
|
||||
// Needed to workaround a bug in MSVC whereby it considers the copy constructor and initializer list constructor
|
||||
// of a container to be ambiguous when converting from a CRange.
|
||||
//! \private
|
||||
template <class T> struct is_initializer_list : public std::false_type {};
|
||||
//! \private
|
||||
template <class T> struct is_initializer_list<std::initializer_list<T>> : public std::true_type {};
|
||||
}
|
||||
|
||||
template <class> class CRange;
|
||||
|
||||
@@ -135,7 +146,8 @@ namespace BlackMisc
|
||||
//! @}
|
||||
|
||||
//! Implicit conversion to any container of value_type which supports push_back. This will copy elements.
|
||||
template <class T, class = typename std::enable_if<std::is_convertible<value_type, typename T::value_type>::value>::type>
|
||||
template <class T, class = typename std::enable_if<! Private::is_initializer_list<T>::value &&
|
||||
std::is_convertible<value_type, typename T::value_type>::value>::type>
|
||||
operator T() const
|
||||
{
|
||||
T container;
|
||||
|
||||
Reference in New Issue
Block a user