Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have a library implementation of is_trivially_constructible without relying on compiler builtins?

I'm using gcc-4.9 which does not have the is_trivially_constructible type trait. Looking into the libstdc++ source code (type_traits), this depends on __is_trivially_constructible which is implemented in the compiler itself.

I was wondering if it was possible to implement this trait as a library rather than relying on compiler such that I can use this in my project which is stuck using gcc-4.9.

like image 502
A. K. Avatar asked Apr 18 '18 13:04

A. K.


1 Answers

No, it's not possible (otherwise we probably would have already done it in libstdc++!)

We had to wait for the new compiler builtin to be implemented.

Using is_scalar is a conservative approximation, but is obviously wrong for trivially constructible class types.

like image 114
Jonathan Wakely Avatar answered Oct 11 '22 09:10

Jonathan Wakely