
Hi is their anyway for boost to allow only explicit conversion... like class MyInt { // some code inside.... operator int() {} }; myIntCalc(int, int); MyInt a, b; f = myInt(a, b); // compile error no implicit conversion. int x = boost::numeric_cast<int>(a); // k allow int y = static_cast<int>(b); // k allow.

On Sat, Jan 26, 2008 at 08:50:42AM -0800, chun ping wang wrote:
Hi is their anyway for boost to allow only explicit conversion...
Why not just use a method?
like class MyInt { // some code inside.... int to_int() const; };
myIntCalc(int, int);
MyInt a, b; f = myInt(a, b); // compile error no implicit conversion.
int x = boost::numeric_cast<int>(a); // k allow
int x = a.to_int();

cause i want to use it in a generic function and other numeric type your_int may or not have to_int... On Jan 26, 2008 8:59 AM, Zeljko Vrba <zvrba@ifi.uio.no> wrote:
On Sat, Jan 26, 2008 at 08:50:42AM -0800, chun ping wang wrote:
Hi is their anyway for boost to allow only explicit conversion...
Why not just use a method?
like class MyInt { // some code inside.... int to_int() const; };
myIntCalc(int, int);
MyInt a, b; f = myInt(a, b); // compile error no implicit conversion.
int x = boost::numeric_cast<int>(a); // k allow
int x = a.to_int();
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

class MyInt { // some code inside.... operator int() { BOOST_STATIC_ASSERT(0 == sizeof(MyInt)); // or some mpl thing } }; "chun ping wang" <cablepuff@gmail.com> wrote in message news:7253f6b30801260850y6bdc052dq4fa01ff64542f93b@mail.gmail.com... Hi is their anyway for boost to allow only explicit conversion... like class MyInt { // some code inside.... operator int() {} }; myIntCalc(int, int); MyInt a, b; f = myInt(a, b); // compile error no implicit conversion. int x = boost::numeric_cast<int>(a); // k allow int y = static_cast<int>(b); // k allow. ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
chun ping wang
-
Robert Ramey
-
Zeljko Vrba