|
Boost Users : |
From: Anil Muthigi (anilmuthigi123_at_[hidden])
Date: 2021-04-07 23:10:21
If u see my code, I have used __int128 separately for the variable d as
well. If u change the variant variable' s data type from __int128 to int ,
it will run just fine.
On Thu, 8 Apr 2021, 04:30 Edward Diener via Boost-users, <
boost-users_at_[hidden]> wrote:
> On 4/7/2021 3:38 PM, Anil Muthigi via Boost-users wrote:
> > I said that I am not sure if boost::variant supports __int128 because I
> > had difficulties in compiling this code :
> >
> > 1.
> > #include <boost/variant.hpp>
> > 2.
> > #include <string>
> > 3.
> > #include <iostream>
> > 4.
> > std::ostream& operator<<(std::ostream& o, const __int128& x) { if (x
> > == std::numeric_limits<__int128>::min()) return o <<
> > "-170141183460469231731687303715884105728"; if (x < 0) return o <<
> > "-" << -x; if (x < 10) return o << (char)(x + '0'); return o << x /
> > 10 << (char)(x % 10 + '0'); }
> > 5.
> > int main()
> > 6.
> > {
> > 7.
> > boost::variant<__int128, char, std::string> v;
> > 8.
> > v = 56;
> > 9.
> > v = 'Y';
> > 10.
> > __int128 d=12;
> > 11.
> > std::cout <<d << '\n';
> > 12.
> > std::cout << v << '\n';
> > 13.
> > v = "Yashaswi raj";
> > 14.
> > std::cout << v << '\n';
> > 15.
> > }
> >
> > If u replace __int128 with int in the variant variable, it seems to work
> > just fine...
>
> My test with gcc-10.2 and clang-linux-11.0 shows that it does not
> support __int128 in iostreams.
>
> >
> > On Thu, 8 Apr 2021, 00:10 Edward Diener via Boost-users,
> > <boost-users_at_[hidden] <mailto:boost-users_at_[hidden]>>
> wrote:
> >
> > On 4/7/2021 2:15 PM, Anil Muthigi via Boost-users wrote:
> > > I dont think so...
> >
> > If it is available why do you think variant would not support it ?
> >
> > > I guess int128_t under boost/multiprecision/cpp_int is the only
> > viable
> > > option.
> > >
> > > On Wed, 7 Apr 2021, 11:39 pm David Frank via Boost-users,
> > > <boost-users_at_[hidden] <mailto:boost-users_at_[hidden]>
> > <mailto:boost-users_at_[hidden]
> > <mailto:boost-users_at_[hidden]>>> wrote:
> > >
> > > especially the gnu __int128?
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden] <mailto:Boost-users_at_[hidden]>
> > https://lists.boost.org/mailman/listinfo.cgi/boost-users
> > <https://lists.boost.org/mailman/listinfo.cgi/boost-users>
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > https://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net