Skip to content

Instantly share code, notes, and snippets.

@xaxxon
Last active February 28, 2016 03:51
Show Gist options
  • Save xaxxon/41811ad412f778ffe5af to your computer and use it in GitHub Desktop.
Save xaxxon/41811ad412f778ffe5af to your computer and use it in GitHub Desktop.
template<typename T, class Enable=void>
struct CastToNative;
// This line causes the compiler error below
CastToNative<std::vector<std::string>>()(...);
modules.cpp:55:25: error: ambiguous partial specializations of 'CastToNative<std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >, void>'
/users/xaxxon/v8-class-wrapper/casts.hpp:90:8: note: partial specialization matches [with ElementType = std::__1::basic_string<char>, Rest = <std::__1::allocator<std::__1::basic_string<char> >>]
struct CastToNative<std::vector<ElementType, Rest...>> {
(CODE)
template<class ElementType, class... Rest>
struct CastToNative<std::vector<ElementType, Rest...>> {
^
/users/xaxxon/v8-class-wrapper/v8_class_wrapper.h:739:8: note: partial specialization matches [with T = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >]
struct CastToNative<T, std::enable_if_t<!std::is_pointer<T>::value>>
(CODE)
template<typename T>
struct CastToNative<T, std::enable_if_t<!std::is_pointer<T>::value>>
BUT if I change the last one to this (enable_if => void), it's no longer ambiguous:
template<typename T>
struct CastToNative<T, void>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment