Hey,

thanks for looking into this. I guess the reason this hasn't come up before
is that our styleguide explicitly disallows function overloading (
https://google.github.io/styleguide/cppguide.html#Function_Overloading)

However, I think it's reasonable to support other styles here as well. Have
you considered contributing a patch?

best
-jochen

On Thu, Jan 28, 2016 at 2:28 AM <xax...@gmail.com> wrote:

> or perhaps the template on the constructor isn't even necessary?
>
> http://ideone.com/MXwvp9
>
> shows the same behavior.
>
> V8_INLINE Local(T* that)
>  : val_(that) {}
> V8_INLINE static Local<T> New(Isolate* isolate, T* that);
> T* val_;
>
> On Wednesday, January 27, 2016 at 5:16:54 PM UTC-8, xax...@gmail.com
> wrote:
>>
>> I think I simply had the parameters to is_convertible backwards in my
>> first post:
>>
>> template <class S, typename = std::enable_if_t<std::is_convertible<S*,T*>
>> ::value>>
>> V8_INLINE Local(S* that)
>>  : val_(that) {}
>> V8_INLINE static Local<T> New(Isolate* isolate, T* that);
>> T* val_;
>>
>>
>> This link http://ideone.com/RVL4rD shows overloaded functions being
>> selected appropriately as well as pointer assignment working between
>> compatible types.
>>
>> On Wednesday, January 27, 2016 at 5:03:49 PM UTC-8, xax...@gmail.com
>> wrote:
>>>
>>> is_convertible doesn't seem to be the right test.   I'm trying to figure
>>> out if I can find a better one.
>>>
>>> On Wednesday, January 27, 2016 at 4:48:56 PM UTC-8, xax...@gmail.com
>>> wrote:
>>>>
>>>> I have an overloaded function that can take either a std::string or a
>>>> Local<Value>, however, when I pass in a const char *, expecting to have the
>>>> std::string version selected, I instead get an ambiguity error.  I added
>>>> another version that takes a Local<Script> and that was added to the list
>>>> of compatible overloaded functions for my call.
>>>>
>>>> The constructor at
>>>> http://v8.paulfryzel.com/docs/master/include_2v8_8h_source.html line
>>>> 332:
>>>>
>>>> template <class S>
>>>> 333  V8_INLINE Local(S* that)
>>>> 334  : val_(that) {}
>>>>
>>>> 336  T* val_;
>>>>
>>>> is what's causing me headaches.
>>>>
>>>> As far as I can tell, it doesn't matter if T* and S* are convertible,
>>>> because when the compiler is looking for implicit conversions, it doesn't
>>>> care if the compiler could actually succeed, just that the types match up.
>>>>
>>>> This means that any function that takes a Local<ANYTHING> will be a
>>>> viable implicit conversion overload match for any pointer type. Is this a
>>>> desirable behavior?
>>>>
>>>>
>>>> I believe this code shows a way to use SFINAE to stop this from
>>>> happening: http://ideone.com/cvZOHt
>>>>
>>>> basically:
>>>>
>>>> template <class S, typename = std::enable_if_t<std::is_convertible<T*,S
>>>> *>::value>>
>>>> V8_INLINE Local(S* that)
>>>>  : val_(that) {}
>>>> V8_INLINE static Local<T> New(Isolate* isolate, T* that);
>>>> T* val_;
>>>>
>>>> I believe std::is_convertible is the exact test as to whether :
>>>> val_(that) will create a compilation error, but I don't know for sure.
>>>>
>>>> If this doesn't change any intended behavior, I'd love to see it merged
>>>> in.
>>>> Thank you.
>>>>
>>>> --Zac
>>>>
>>> --
> --
> v8-dev mailing list
> v8-dev@googlegroups.com
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to