VCTR
Loading...
Searching...
No Matches
BitCast.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23namespace vctr
24{
25
26#if __cpp_lib_bit_cast >= 201806L
27
28template <class To, class From>
29constexpr To bitCast (const From& from) noexcept { return std::bit_cast<To> (from); }
30
31#elif VCTR_CLANG && __has_builtin (__builtin_bit_cast)
32
33template <class To, class From>
34constexpr To bitCast (const From& from) noexcept { return __builtin_bit_cast (To, from); }
35
36#else
37
38#error "Your compiler has no bit_cast support"
39
40#endif
41}
The main namespace of the VCTR project.
Definition: Array.h:24