On running the code given below which uses int for variant variable but uses 
__int128 for the variable d having value 12... I get the following output = 
#include <boost/variant.hpp>
#include <string>
#include <iostream>
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'); }
int main()
{
boost::variant<int, char, std::string> v;
v = 56;
v = 'Y';
__int128 d=12;
std::cout <<d << '\n';
std::cout << v << '\n'; 
v = "Yashaswi raj";
std::cout << v << '\n';
}







> On 08-Apr-2021, at 1:08 AM, Anil Muthigi <anilmuthigi...@gmail.com> wrote:
> 
> I said that I am not sure if boost::variant supports __int128 because I had 
> difficulties in compiling this code :
> #include <boost/variant.hpp>
> #include <string>
> #include <iostream>
> 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'); }
> int main()
> {
> boost::variant<__int128, char, std::string> v;
> v = 56;
> v = 'Y';
> __int128 d=12;
> std::cout <<d << '\n';
> std::cout << v << '\n'; 
> v = "Yashaswi raj";
> std::cout << v << '\n';
> }
> If u replace __int128 with int in the variant variable, it seems to work just 
> fine...
> 
> On Thu, 8 Apr 2021, 00:10 Edward Diener via Boost-users, 
> <boost-users@lists.boost.org <mailto:boost-users@lists.boost.org>> 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@lists.boost.org <mailto:boost-users@lists.boost.org> 
> > <mailto:boost-users@lists.boost.org <mailto:boost-users@lists.boost.org>>> 
> > wrote:
> > 
> >     especially the gnu __int128?
> 
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org <mailto:Boost-users@lists.boost.org>
> https://lists.boost.org/mailman/listinfo.cgi/boost-users 
> <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

Reply via email to