[Rcpp-devel] Conversion operator for Rcpp::internal::generic_proxy (Previously Efficient DataFrame access by row & column)

Yan Zhou zhouyan at me.com
Wed Feb 20 19:41:44 CET 2013


I have posted a question on stack about the issue, a long with some more details on the problem

http://stackoverflow.com/questions/14987326/overloading-conversion-operator-template

Also I saw in the source of Rcpp, there is a comment says that the operator int and operator bool are provided to help compilers. I am curious in what situations that a single operator 
template is not enough. Since the operator actually simply call Rcpp::as

I have some thoughts on this issue. At the heart of the problem is that the compilers do not consider the operator template as a perfect match. The only reason I can think of is that if the operator template is chosen, then some conversion of its argument is required, therefore it is no better than the operator int and operator bool. However, according to C++ rule, in the case of conversion operator, template argument deduction use the return type and the input argument is the *this, which is not converted.

Best,

Yan Zhou 

On Feb 20, 2013, at 2:11 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

> 
> On 20 February 2013 at 01:48, Yan Zhou wrote:
> | 
> | On Feb 20, 2013, at 1:46 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
> | 
> | > 
> | > On 20 February 2013 at 01:15, Yan Zhou wrote:
> | > | Hi Dirk,
> | > 
> | > I see nothing Rcpp-specific here.  It's more about how to avoid ambiguity
> | > within C++.  Might make a good question for the C++ tag on StackOverflow.
> | Yes, exactly. The problem itself is nothing Rcpp specific but the operator implementation was copied directly from Rcpp's proxy header. I will ask it on Stack later.
> 
> Great, drop a pointer here when it is up. I try to keep up with R or at least
> Rcpp questions there and don't regularly poke into the C++ tag anymore.
> 
> Dirk
> 
> -- 
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  



More information about the Rcpp-devel mailing list