Date: Mon, 4 Nov 2013 07:54:16 -0800
template<typename To, typename From>
To bit_cast(const From& from) {
static_assert(sizeof(To) == sizeof(from));
To result;
memcpy(result, from, sizeof(from));
return result;
}
On Mon, Nov 4, 2013 at 7:51 AM, J. Daniel Garcia
<josedaniel.garcia_at_[hidden]> wrote:
> Can you elaborate what such a thing would be?
>
>
>
> On Mon, Nov 4, 2013 at 5:11 AM, Lawrence Crowl <Lawrence_at_[hidden]> wrote:
>>
>> Did we standardize bit_cast at all?
>>
>> It would help avoid the almost overwhelming temptation
>> for programmers to do the wrong thing.
>>
>> --
>> Lawrence Crowl
>> _______________________________________________
>> ub mailing list
>> ub_at_[hidden]
>> http://www.open-std.org/mailman/listinfo/ub
>
>
>
> _______________________________________________
> ub mailing list
> ub_at_[hidden]
> http://www.open-std.org/mailman/listinfo/ub
>
To bit_cast(const From& from) {
static_assert(sizeof(To) == sizeof(from));
To result;
memcpy(result, from, sizeof(from));
return result;
}
On Mon, Nov 4, 2013 at 7:51 AM, J. Daniel Garcia
<josedaniel.garcia_at_[hidden]> wrote:
> Can you elaborate what such a thing would be?
>
>
>
> On Mon, Nov 4, 2013 at 5:11 AM, Lawrence Crowl <Lawrence_at_[hidden]> wrote:
>>
>> Did we standardize bit_cast at all?
>>
>> It would help avoid the almost overwhelming temptation
>> for programmers to do the wrong thing.
>>
>> --
>> Lawrence Crowl
>> _______________________________________________
>> ub mailing list
>> ub_at_[hidden]
>> http://www.open-std.org/mailman/listinfo/ub
>
>
>
> _______________________________________________
> ub mailing list
> ub_at_[hidden]
> http://www.open-std.org/mailman/listinfo/ub
>
Received on 2013-11-04 16:54:37