Quantcast

Making explicit the conversion between unless types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Making explicit the conversion between unless types

Riccardo Rossi

Dear all,

Right now the following code

#include <iostream>
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>

void f(
    const boost::numeric::ublas::bounded_matrix<double,10,1>& should_be_10by1
     )

}

int main() {
    boost::numeric::ublas::bounded_matrix<double,10,1> correct;
    boost::numeric::ublas::bounded_matrix<double,1,10> wrong;
    f(correct);
    f(wrong); //how can this be compiled??? - i expect the type of wrong to be ...wrong for f!!
}

Does compile, effectively bypassing type safety.

Essentially if I use a reference in defining a function it is because I don t want to pass by value.
In this case a copy is being done...allowed by the fact that the reference I pass is constant.

Couldn't t the conversion be made explicit? That would potentially uncover many bugs...

Regards
Riccardo


_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making explicit the conversion between unless types

Riccardo Rossi

This is just to be sure my previous email was received

Can anyone acknowledge receipt?

Riccardo

On 24 Jun 2016 3:49 p.m., "Riccardo Rossi" <[hidden email]> wrote:

Dear all,

Right now the following code

#include <iostream>
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>

void f(
    const boost::numeric::ublas::bounded_matrix<double,10,1>& should_be_10by1
     )

}

int main() {
    boost::numeric::ublas::bounded_matrix<double,10,1> correct;
    boost::numeric::ublas::bounded_matrix<double,1,10> wrong;
    f(correct);
    f(wrong); //how can this be compiled??? - i expect the type of wrong to be ...wrong for f!!
}

Does compile, effectively bypassing type safety.

Essentially if I use a reference in defining a function it is because I don t want to pass by value.
In this case a copy is being done...allowed by the fact that the reference I pass is constant.

Couldn't t the conversion be made explicit? That would potentially uncover many bugs...

Regards
Riccardo


_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making explicit the conversion between unless types

Caio Souza

Received


Em ter, 28 de jun de 2016 14:04, Riccardo Rossi <[hidden email]> escreveu:

This is just to be sure my previous email was received

Can anyone acknowledge receipt?

Riccardo

On 24 Jun 2016 3:49 p.m., "Riccardo Rossi" <[hidden email]> wrote:

Dear all,

Right now the following code

#include <iostream>
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>

void f(
    const boost::numeric::ublas::bounded_matrix<double,10,1>& should_be_10by1
     )

}

int main() {
    boost::numeric::ublas::bounded_matrix<double,10,1> correct;
    boost::numeric::ublas::bounded_matrix<double,1,10> wrong;
    f(correct);
    f(wrong); //how can this be compiled??? - i expect the type of wrong to be ...wrong for f!!
}

Does compile, effectively bypassing type safety.

Essentially if I use a reference in defining a function it is because I don t want to pass by value.
In this case a copy is being done...allowed by the fact that the reference I pass is constant.

Couldn't t the conversion be made explicit? That would potentially uncover many bugs...

Regards
Riccardo

_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]

_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Making explicit the conversion between unless types

Nasos Iliopoulos
In reply to this post by Riccardo Rossi
Confirming

On 06/28/2016 01:04 PM, Riccardo Rossi wrote:

This is just to be sure my previous email was received

Can anyone acknowledge receipt?

Riccardo

On 24 Jun 2016 3:49 p.m., "Riccardo Rossi" <[hidden email]> wrote:

Dear all,

Right now the following code

#include <iostream>
#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>

void f(
    const boost::numeric::ublas::bounded_matrix<double,10,1>& should_be_10by1
     )

}

int main() {
    boost::numeric::ublas::bounded_matrix<double,10,1> correct;
    boost::numeric::ublas::bounded_matrix<double,1,10> wrong;
    f(correct);
    f(wrong); //how can this be compiled??? - i expect the type of wrong to be ...wrong for f!!
}

Does compile, effectively bypassing type safety.

Essentially if I use a reference in defining a function it is because I don t want to pass by value.
In this case a copy is being done...allowed by the fact that the reference I pass is constant.

Couldn't t the conversion be made explicit? That would potentially uncover many bugs...

Regards
Riccardo



_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]


_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Loading...