But I am not even doing any kind of input or output using __int128 FOR THE VARIANT VARIABLE….

As you can see… if you choose to use int instead of __int128 for the VARIANT VARIABLE and rerun the code…. it is actually printing the value of the __int128 variable d which I have used in the code..
 So, I guess it is actually picking up my std::ostream& operator<<(std::ostream& o, const __int128& x) functionality.

On 08-Apr-2021, at 7:52 AM, Edward Diener via Boost-users <boost-users@lists.boost.org> wrote:

On 4/7/2021 9:58 PM, Edward Diener via Boost-users wrote:
On 4/7/2021 7:10 PM, Anil Muthigi via Boost-users wrote:
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.
The reason your code is failing is because your stream operator uses streaming and __int128 has no stream support. If you use an __int128 in a variant, but never use streaming, your code is fine. I do not know the reason why gcc and clang support __int128 but do not support the the type in streaming. Maybe you should try asking gcc about it or investigate it as a stackoverflow question.
Please do not topmost.

Apologies ! It looks as if the variant i/o is simply not picking up your std::ostream& operator<<(std::ostream& o, const __int128& x) functionality. I tried putting your functionality in namespace boost but it still did not pick it up.


On Thu, 8 Apr 2021, 04:30 Edward Diener via Boost-users, <boost-users@lists.boost.org <mailto:boost-users@lists.boost.org>> 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.

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users