forked from boostorg/endian
Compare commits
20 Commits
develop
...
boost-1.84
Author | SHA1 | Date | |
---|---|---|---|
c9b436e5df | |||
484068bdc9 | |||
699cb133e8 | |||
927c598c84 | |||
7b06daf290 | |||
47bf1f05ea | |||
0a0d6b8bac | |||
90a8527bbf | |||
1d0e955950 | |||
34436358f5 | |||
0f6c704e8c | |||
53e2379637 | |||
bf4a4c6eca | |||
ccc8c3df3f | |||
0e0a4fe51d | |||
a3cc06aab5 | |||
56bd7c23ae | |||
9d071a3c40 | |||
b84ac7969b | |||
9ca75077ce |
@ -96,18 +96,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
};
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.4",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
|
||||
"g++-4.4",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.6 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '0x', ADDRMD: '32,64' },
|
||||
"g++-4.6-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
@ -115,7 +107,7 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.7 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '0x', ADDRMD: '32,64' },
|
||||
"g++-4.7-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
@ -123,13 +115,13 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.8* 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.9 32/64",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11', ADDRMD: '32,64' },
|
||||
"g++-4.9-multilib",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
@ -137,53 +129,79 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9 ARM64 32/64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' },
|
||||
arch="arm64",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9 S390x 32/64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32,64' },
|
||||
arch="s390x",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20', ADDRMD: '32' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 64 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20', ADDRMD: '64' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 UBSAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
|
||||
"clang-14",
|
||||
"Linux 23.04 GCC 13 32/64",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' },
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 ASAN",
|
||||
"Linux 22.04 Clang 15 UBSAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
|
||||
"clang-14",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"clang-15",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 15 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-15",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 Clang 16",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
|
@ -5,6 +5,7 @@
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
|
313
.github/workflows/ci.yml
vendored
313
.github/workflows/ci.yml
vendored
@ -18,122 +18,152 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-4.8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-5-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-6-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: g++-7-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-9-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-10-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12-multilib
|
||||
address-model: 32,64
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-15
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: macos-11
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-12
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python git g++
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -186,18 +216,18 @@ jobs:
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@ -232,19 +262,20 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -279,19 +310,20 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -336,19 +368,20 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: macos-13
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -385,3 +418,183 @@ jobs:
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
windows-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Use library with add_subdirectory (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use library with add_subdirectory (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
|
||||
- name: Install (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Debug
|
||||
|
||||
- name: Install (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install --config Release
|
||||
|
||||
- name: Use the installed library (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
cmake --build . --config Debug
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Use the installed library (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
|
||||
cmake --build . --config Release
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
||||
windows-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Debug
|
||||
|
||||
- name: Run tests (Debug)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Debug
|
||||
|
||||
- name: Build tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests --config Release
|
||||
|
||||
- name: Run tests (Release)
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error -C Release
|
||||
|
@ -1,8 +1,9 @@
|
||||
# Copyright 2019 Peter Dimov
|
||||
# Generated by `boostdep --cmake endian`
|
||||
# Copyright 2020, 2021 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
cmake_minimum_required(VERSION 3.8...3.20)
|
||||
|
||||
project(boost_endian VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@ -14,12 +15,11 @@ target_include_directories(boost_endian INTERFACE include)
|
||||
target_link_libraries(boost_endian
|
||||
INTERFACE
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::static_assert
|
||||
Boost::type_traits
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
target_compile_features(boost_endian INTERFACE cxx_std_11)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
|
12
README.md
12
README.md
@ -7,12 +7,14 @@ It's part of Boost since release 1.58.0. See
|
||||
|
||||
## Supported compilers
|
||||
|
||||
* g++ 4.4 or later
|
||||
* clang++ 3.3 or later
|
||||
* Visual Studio 2008 or later
|
||||
* g++ 4.6 or later
|
||||
* clang++ 3.9 or later
|
||||
* Visual Studio 2012 or later
|
||||
|
||||
Tested on [Travis](https://travis-ci.org/boostorg/endian/) and
|
||||
[Appveyor](https://ci.appveyor.com/project/pdimov/endian/).
|
||||
C++11 is required since release 1.84.
|
||||
|
||||
Tested on [Github Actions](https://github.com/boostorg/endian/actions)
|
||||
and [Appveyor](https://ci.appveyor.com/project/pdimov/endian/).
|
||||
|
||||
## License
|
||||
|
||||
|
11
appveyor.yml
11
appveyor.yml
@ -14,9 +14,6 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
@ -31,19 +28,19 @@ environment:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
CXXSTD: 11,14,1z
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
|
@ -130,16 +130,6 @@ design, implementation, testing, and documentation has only considered issues
|
||||
related to 8-bit bytes, and there have been no real-world use cases presented
|
||||
for other sizes.
|
||||
|
||||
In {cpp}03, `endian_arithmetic` does not meet the requirements for POD types
|
||||
because it has constructors, private data members, and a base class. This means
|
||||
that common use cases are relying on unspecified behavior in that the {cpp}
|
||||
Standard does not guarantee memory layout for non-POD types. This has not been a
|
||||
problem in practice since all known {cpp} compilers lay out memory as if
|
||||
`endian` were a POD type. In {cpp}11, it is possible to specify the default
|
||||
constructor as trivial, and private data members and base classes no longer
|
||||
disqualify a type from being a POD type. Thus under {cpp}11, `endian_arithmetic`
|
||||
will no longer be relying on unspecified behavior.
|
||||
|
||||
## Feature set
|
||||
|
||||
* Big endian| little endian | native endian byte ordering.
|
||||
@ -224,8 +214,6 @@ namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
// C++11 features emulated if not available
|
||||
|
||||
enum class align { no, yes };
|
||||
|
||||
template <order Order, class T, std::size_t n_bits,
|
||||
@ -236,8 +224,9 @@ namespace boost
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
// if BOOST_ENDIAN_FORCE_PODNESS is defined && C++11 PODs are not
|
||||
// available then these two constructors will not be present
|
||||
// if BOOST_ENDIAN_NO_CTORS is defined, these two
|
||||
// constructors will not be present
|
||||
|
||||
endian_arithmetic() noexcept = default;
|
||||
endian_arithmetic(T v) noexcept;
|
||||
|
||||
@ -408,7 +397,7 @@ When `Nbits` is less than `sizeof(T)*8`, `T` must be a standard integral type
|
||||
### Members
|
||||
|
||||
```
|
||||
endian_arithmetic() noexcept = default; // C++03: endian(){}
|
||||
endian_arithmetic() noexcept = default;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
@ -508,13 +497,10 @@ integers require no conversion or copying. They are already in the desired
|
||||
format for binary I/O. Thus they can be read or written in bulk.
|
||||
|
||||
Are endian types PODs?::
|
||||
Yes for {cpp}11. No for {cpp}03, although several
|
||||
<<arithmetic_compilation,macros>> are available to force PODness in all cases.
|
||||
|
||||
What are the implications of endian integer types not being PODs with {cpp}03 compilers?::
|
||||
They can't be used in unions. Also, compilers aren't required to align or lay
|
||||
out storage in portable ways, although this potential problem hasn't prevented
|
||||
use of Boost.Endian with real compilers.
|
||||
Yes for the {cpp}11 definition of POD. No for the {cpp}03 definition of POD,
|
||||
although the <<arithmetic_compilation,macro>> `BOOST_ENDIAN_NO_CTORS` can be
|
||||
used to disable the constructors and to force {cpp}03 PODness (which is
|
||||
required, for example, by the GCC `++__attribute__((packed))++` extension.)
|
||||
|
||||
What good is native endianness?::
|
||||
It provides alignment and size guarantees not available from the built-in
|
||||
@ -579,32 +565,15 @@ library: reading TrueType font files from disk and processing the contents. The
|
||||
data format has fixed endianness (big) and has unaligned values in various
|
||||
places. Using Boost.Endian simplifies and cleans the code wonderfully."
|
||||
|
||||
## {cpp}11
|
||||
|
||||
The availability of the {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions] feature is detected automatically, and will be used if present to
|
||||
ensure that objects of `class endian_arithmetic` are trivial, and thus PODs.
|
||||
|
||||
## Compilation
|
||||
|
||||
Boost.Endian is implemented entirely within headers, with no need to link to any
|
||||
Boost object libraries.
|
||||
|
||||
Several macros allow user control over features:
|
||||
|
||||
* BOOST_ENDIAN_NO_CTORS causes `class endian_arithmetic` to have no
|
||||
constructors. The intended use is for compiling user code that must be portable
|
||||
between compilers regardless of {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions] support. Use of constructors will always fail,
|
||||
* BOOST_ENDIAN_FORCE_PODNESS causes BOOST_ENDIAN_NO_CTORS to be defined if
|
||||
the compiler does not support {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions]. This is ensures that objects of `class endian_arithmetic` are PODs,
|
||||
and so can be used in {cpp}03 unions. In {cpp}11, `class endian_arithmetic`
|
||||
objects are PODs, even though they have constructors, so can always be used in
|
||||
unions.
|
||||
The macro `BOOST_ENDIAN_NO_CTORS`, when defined, causes `class endian_buffer`
|
||||
to have no constructors. The intended use is to guarantee that `endian_buffer`
|
||||
is a {cpp}03 POD. This is required, for example, by the GCC
|
||||
`++__attribute__((packed))++` extension.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
|
@ -124,16 +124,6 @@ design, implementation, testing, and documentation has only considered issues
|
||||
related to 8-bit bytes, and there have been no real-world use cases presented
|
||||
for other sizes.
|
||||
|
||||
In {cpp}03, `endian_buffer` does not meet the requirements for POD types because
|
||||
it has constructors and a private data member. This means that
|
||||
common use cases are relying on unspecified behavior in that the {cpp} Standard
|
||||
does not guarantee memory layout for non-POD types. This has not been a problem
|
||||
in practice since all known {cpp} compilers lay out memory as if `endian` were
|
||||
a POD type. In {cpp}11, it is possible to specify the default constructor as
|
||||
trivial, and private data members and base classes no longer disqualify a type
|
||||
from being a POD type. Thus under {cpp}11, `endian_buffer` will no longer be
|
||||
relying on unspecified behavior.
|
||||
|
||||
## Feature set
|
||||
|
||||
* Big endian| little endian | native endian byte ordering.
|
||||
@ -215,8 +205,6 @@ namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
// C++11 features emulated if not available
|
||||
|
||||
enum class align { no, yes };
|
||||
|
||||
template <order Order, class T, std::size_t Nbits,
|
||||
@ -227,6 +215,9 @@ namespace boost
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
// if BOOST_ENDIAN_NO_CTORS is defined, these two
|
||||
// constructors will not be present
|
||||
|
||||
endian_buffer() noexcept = default;
|
||||
explicit endian_buffer(T v) noexcept;
|
||||
|
||||
@ -475,13 +466,10 @@ integers require no conversion or copying. They are already in the desired
|
||||
format for binary I/O. Thus they can be read or written in bulk.
|
||||
|
||||
Are endian types PODs?::
|
||||
Yes for {cpp}11. No for {cpp}03, although several
|
||||
<<buffers_compilation,macros>> are available to force PODness in all cases.
|
||||
|
||||
What are the implications of endian integer types not being PODs with {cpp}03 compilers?::
|
||||
They can't be used in unions. Also, compilers aren't required to align or lay
|
||||
out storage in portable ways, although this potential problem hasn't prevented
|
||||
use of Boost.Endian with real compilers.
|
||||
Yes for the {cpp}11 definition of POD. No for the {cpp}03 definition of POD,
|
||||
although the <<buffers_compilation,macro>> `BOOST_ENDIAN_NO_CTORS` can be
|
||||
used to disable the constructors and to force {cpp}03 PODness (which is
|
||||
required, for example, by the GCC `++__attribute__((packed))++` extension.)
|
||||
|
||||
What good is native endianness?::
|
||||
It provides alignment and size guarantees not available from the built-in
|
||||
@ -513,29 +501,12 @@ when changing machines or compilers. Pessimizations can also happen when
|
||||
changing compiler switches, compiler versions, or CPU models of the same
|
||||
architecture.
|
||||
|
||||
## {cpp}11
|
||||
|
||||
The availability of the {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions] feature is detected automatically, and will be used if present to
|
||||
ensure that objects of `class endian_buffer` are trivial, and thus
|
||||
PODs.
|
||||
|
||||
## Compilation
|
||||
|
||||
Boost.Endian is implemented entirely within headers, with no need to link to
|
||||
any Boost object libraries.
|
||||
|
||||
Several macros allow user control over features:
|
||||
|
||||
* `BOOST_ENDIAN_NO_CTORS` causes `class endian_buffer` to have no
|
||||
constructors. The intended use is for compiling user code that must be
|
||||
portable between compilers regardless of {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions] support. Use of constructors will always fail,
|
||||
* `BOOST_ENDIAN_FORCE_PODNESS` causes `BOOST_ENDIAN_NO_CTORS` to be defined if
|
||||
the compiler does not support {cpp}11
|
||||
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
|
||||
Functions]. This is ensures that objects of `class endian_buffer` are PODs, and
|
||||
so can be used in {cpp}03 unions. In {cpp}11, `class endian_buffer` objects are
|
||||
PODs, even though they have constructors, so can always be used in unions.
|
||||
The macro `BOOST_ENDIAN_NO_CTORS`, when defined, causes `class endian_buffer`
|
||||
to have no constructors. The intended use is to guarantee that `endian_buffer`
|
||||
is a {cpp}03 POD. This is required, for example, by the GCC
|
||||
`++__attribute__((packed))++` extension.
|
||||
|
@ -10,32 +10,36 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
[#changelog]
|
||||
# Revision History
|
||||
|
||||
## Changes in 1.84.0
|
||||
|
||||
* {cpp}03 is no longer supported.
|
||||
|
||||
## Changes in 1.75.0
|
||||
|
||||
* `endian_arithmetic` no longer inherits from `endian_buffer`
|
||||
* `endian_arithmetic` no longer inherits from `endian_buffer`.
|
||||
* When `BOOST_ENDIAN_NO_CTORS` is defined, the unaligned `endian_buffer` and
|
||||
`endian_arithmetic` are {cpp}03 PODs, to enable use of `++__attribute__((packed))++`
|
||||
`endian_arithmetic` are {cpp}03 PODs, to enable use of `++__attribute__((packed))++`.
|
||||
|
||||
## Changes in 1.74.0
|
||||
|
||||
* Enabled scoped enumeration types in `endian_reverse`
|
||||
* Enabled `bool`, `enum`, `float`, `double` in `endian_reverse_inplace`
|
||||
* Added an overload of `endian_reverse_inplace` for arrays
|
||||
* Enabled scoped enumeration types in `endian_reverse`.
|
||||
* Enabled `bool`, `enum`, `float`, `double` in `endian_reverse_inplace`.
|
||||
* Added an overload of `endian_reverse_inplace` for arrays.
|
||||
|
||||
## Changes in 1.72.0
|
||||
|
||||
* Made `endian_reverse`, `conditional_reverse` and `\*\_to_*` `constexpr`
|
||||
on GCC and Clang
|
||||
* Added convenience load and store functions
|
||||
* Added floating point convenience typedefs
|
||||
* Added a non-const overload of `data()`; changed its return type to `unsigned char*`
|
||||
* Added `__int128` support to `endian_reverse` when available
|
||||
* Added a convenience header `boost/endian.hpp`
|
||||
on GCC and Clang.
|
||||
* Added convenience load and store functions.
|
||||
* Added floating point convenience typedefs.
|
||||
* Added a non-const overload of `data()`; changed its return type to `unsigned char*`.
|
||||
* Added `__int128` support to `endian_reverse` when available.
|
||||
* Added a convenience header `boost/endian.hpp`.
|
||||
|
||||
## Changes in 1.71.0
|
||||
|
||||
* Clarified requirements on the value type template parameter
|
||||
* Added support for `float` and `double` to `endian_buffer` and `endian_arithmetic`
|
||||
* Added `endian_load`, `endian_store`
|
||||
* Updated `endian_reverse` to correctly support all non-`bool` integral types
|
||||
* Moved deprecated names to the deprecated header `endian.hpp`
|
||||
* Clarified requirements on the value type template parameter.
|
||||
* Added support for `float` and `double` to `endian_buffer` and `endian_arithmetic`.
|
||||
* Added `endian_load`, `endian_store`.
|
||||
* Updated `endian_reverse` to correctly support all non-`bool` integral types.
|
||||
* Moved deprecated names to the deprecated header `endian.hpp`.
|
||||
|
@ -17,9 +17,7 @@ big, or little endian byte ordering. User defined types are also supported.
|
||||
|
||||
## Reference
|
||||
|
||||
Functions are implemented `inline` if appropriate. For {cpp}03 compilers,
|
||||
`noexcept` is elided. Boost scoped enum emulation is used so that the library
|
||||
still works for compilers that do not support scoped enums.
|
||||
Functions are implemented `inline` if appropriate.
|
||||
|
||||
### Definitions
|
||||
|
||||
@ -52,10 +50,9 @@ its value is never read, there would be no undefined behavior.
|
||||
|
||||
### Header `<boost/endian/conversion.hpp>` Synopsis
|
||||
|
||||
[subs=+quotes]
|
||||
```
|
||||
#define BOOST_ENDIAN_INTRINSIC_MSG \
|
||||
"`message describing presence or absence of intrinsics`"
|
||||
"message describing presence or absence of intrinsics"
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -63,9 +60,9 @@ namespace endian
|
||||
{
|
||||
enum class order
|
||||
{
|
||||
native = `see below`,
|
||||
big = `see below`,
|
||||
little = `see below`,
|
||||
native = /* see below */,
|
||||
big = /* see below */,
|
||||
little = /* see below */,
|
||||
};
|
||||
|
||||
// Byte reversal functions
|
||||
|
@ -110,9 +110,7 @@ sizes and aligned arithmetic types are provided for 16, 32, and 64-bit sizes.
|
||||
The provided specific types are typedefs for a generic class template that may
|
||||
be used directly in generic code of for less common use cases.
|
||||
|
||||
Boost Endian is a header-only library. {cpp}11 features affecting interfaces,
|
||||
such as `noexcept`, are used only if available. See
|
||||
<<overview_cpp03_support,{cpp}03 support for {cpp}11 features>> for details.
|
||||
Boost Endian is a header-only library and requires {cpp}11.
|
||||
|
||||
[#overview_intrinsics]
|
||||
## Built-in support for Intrinsics
|
||||
@ -257,28 +255,6 @@ Iterations: 10'000'000'000, Intrinsics: `<cstdlib>` `_byteswap_ushort`, etc.
|
||||
|64-bit aligned little endian |3.35 s |2.73 s
|
||||
|===
|
||||
|
||||
[#overview_cpp03_support]
|
||||
## {cpp}03 support for {cpp}11 features
|
||||
|
||||
[%header,cols=2*]
|
||||
|===
|
||||
|{cpp}11 Feature
|
||||
|Action with {cpp}03 Compilers
|
||||
|Scoped enums
|
||||
|Uses header
|
||||
http://www.boost.org/libs/core/doc/html/core/scoped_enum.html[boost/core/scoped_enum.hpp]
|
||||
to emulate {cpp}11 scoped enums.
|
||||
|`noexcept`
|
||||
|Uses `BOOST_NOEXCEPT` macro, which is defined as null for compilers not
|
||||
supporting this {cpp}11 feature.
|
||||
|{cpp}11 PODs
|
||||
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm[N2342])
|
||||
|Takes advantage of {cpp}03 compilers that relax {cpp}03 POD rules, but see
|
||||
Limitations <<buffers_limitations,here>> and <<arithmetic_limitations,here>>.
|
||||
Also see macros for explicit POD control <<buffers_compilation,here>> and
|
||||
<<arithmetic_compilation,here>>
|
||||
|===
|
||||
|
||||
[#overview_faq]
|
||||
## Overall FAQ
|
||||
|
||||
@ -286,7 +262,7 @@ Is the implementation header only?::
|
||||
Yes.
|
||||
|
||||
Are {cpp}03 compilers supported?::
|
||||
Yes.
|
||||
No. {cpp}11 is required since release 1.84.
|
||||
|
||||
Does the implementation use compiler intrinsic built-in byte swapping?::
|
||||
Yes, if available. See <<overview_intrinsics,Intrinsic built-in support>>.
|
||||
|
@ -28,11 +28,9 @@
|
||||
#endif
|
||||
|
||||
#include <boost/endian/buffers.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <climits>
|
||||
|
||||
@ -44,17 +42,6 @@
|
||||
# error Platforms with CHAR_BIT != 8 are not supported
|
||||
# endif
|
||||
|
||||
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
|
||||
# else
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
|
||||
# endif
|
||||
|
||||
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
|
||||
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
# define BOOST_ENDIAN_NO_CTORS
|
||||
# endif
|
||||
|
||||
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
|
||||
# define BOOST_ENDIAN_EXPLICIT_OPT
|
||||
# else
|
||||
@ -68,33 +55,33 @@ namespace boost
|
||||
namespace endian
|
||||
{
|
||||
|
||||
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
|
||||
BOOST_SCOPED_ENUM(align) Align = align::no>
|
||||
template <order Order, class T, std::size_t n_bits,
|
||||
align Align = align::no>
|
||||
class endian_arithmetic;
|
||||
|
||||
// big endian signed integer aligned types
|
||||
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_at;
|
||||
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_at;
|
||||
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_at;
|
||||
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_at;
|
||||
typedef endian_arithmetic<order::big, std::int8_t, 8, align::yes> big_int8_at;
|
||||
typedef endian_arithmetic<order::big, std::int16_t, 16, align::yes> big_int16_at;
|
||||
typedef endian_arithmetic<order::big, std::int32_t, 32, align::yes> big_int32_at;
|
||||
typedef endian_arithmetic<order::big, std::int64_t, 64, align::yes> big_int64_at;
|
||||
|
||||
// big endian unsigned integer aligned types
|
||||
typedef endian_arithmetic<order::big, uint8_t, 8, align::yes> big_uint8_at;
|
||||
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_at;
|
||||
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_at;
|
||||
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_at;
|
||||
typedef endian_arithmetic<order::big, std::uint8_t, 8, align::yes> big_uint8_at;
|
||||
typedef endian_arithmetic<order::big, std::uint16_t, 16, align::yes> big_uint16_at;
|
||||
typedef endian_arithmetic<order::big, std::uint32_t, 32, align::yes> big_uint32_at;
|
||||
typedef endian_arithmetic<order::big, std::uint64_t, 64, align::yes> big_uint64_at;
|
||||
|
||||
// little endian signed integer aligned types
|
||||
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_at;
|
||||
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_at;
|
||||
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_at;
|
||||
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_at;
|
||||
typedef endian_arithmetic<order::little, std::int8_t, 8, align::yes> little_int8_at;
|
||||
typedef endian_arithmetic<order::little, std::int16_t, 16, align::yes> little_int16_at;
|
||||
typedef endian_arithmetic<order::little, std::int32_t, 32, align::yes> little_int32_at;
|
||||
typedef endian_arithmetic<order::little, std::int64_t, 64, align::yes> little_int64_at;
|
||||
|
||||
// little endian unsigned integer aligned types
|
||||
typedef endian_arithmetic<order::little, uint8_t, 8, align::yes> little_uint8_at;
|
||||
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_at;
|
||||
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_at;
|
||||
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_at;
|
||||
typedef endian_arithmetic<order::little, std::uint8_t, 8, align::yes> little_uint8_at;
|
||||
typedef endian_arithmetic<order::little, std::uint16_t, 16, align::yes> little_uint16_at;
|
||||
typedef endian_arithmetic<order::little, std::uint32_t, 32, align::yes> little_uint32_at;
|
||||
typedef endian_arithmetic<order::little, std::uint64_t, 64, align::yes> little_uint64_at;
|
||||
|
||||
// aligned floating point types
|
||||
typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_at;
|
||||
@ -106,64 +93,64 @@ namespace endian
|
||||
// <cstdint> types are superior for this use case
|
||||
|
||||
// big endian signed integer unaligned types
|
||||
typedef endian_arithmetic<order::big, int_least8_t, 8> big_int8_t;
|
||||
typedef endian_arithmetic<order::big, int_least16_t, 16> big_int16_t;
|
||||
typedef endian_arithmetic<order::big, int_least32_t, 24> big_int24_t;
|
||||
typedef endian_arithmetic<order::big, int_least32_t, 32> big_int32_t;
|
||||
typedef endian_arithmetic<order::big, int_least64_t, 40> big_int40_t;
|
||||
typedef endian_arithmetic<order::big, int_least64_t, 48> big_int48_t;
|
||||
typedef endian_arithmetic<order::big, int_least64_t, 56> big_int56_t;
|
||||
typedef endian_arithmetic<order::big, int_least64_t, 64> big_int64_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least8_t, 8> big_int8_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least16_t, 16> big_int16_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least32_t, 24> big_int24_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least32_t, 32> big_int32_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least64_t, 40> big_int40_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least64_t, 48> big_int48_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least64_t, 56> big_int56_t;
|
||||
typedef endian_arithmetic<order::big, std::int_least64_t, 64> big_int64_t;
|
||||
|
||||
// big endian unsigned integer unaligned types
|
||||
typedef endian_arithmetic<order::big, uint_least8_t, 8> big_uint8_t;
|
||||
typedef endian_arithmetic<order::big, uint_least16_t, 16> big_uint16_t;
|
||||
typedef endian_arithmetic<order::big, uint_least32_t, 24> big_uint24_t;
|
||||
typedef endian_arithmetic<order::big, uint_least32_t, 32> big_uint32_t;
|
||||
typedef endian_arithmetic<order::big, uint_least64_t, 40> big_uint40_t;
|
||||
typedef endian_arithmetic<order::big, uint_least64_t, 48> big_uint48_t;
|
||||
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_t;
|
||||
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least8_t, 8> big_uint8_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least16_t, 16> big_uint16_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least32_t, 24> big_uint24_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least32_t, 32> big_uint32_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least64_t, 40> big_uint40_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least64_t, 48> big_uint48_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least64_t, 56> big_uint56_t;
|
||||
typedef endian_arithmetic<order::big, std::uint_least64_t, 64> big_uint64_t;
|
||||
|
||||
// little endian signed integer unaligned types
|
||||
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_t;
|
||||
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_t;
|
||||
typedef endian_arithmetic<order::little, int_least32_t, 24> little_int24_t;
|
||||
typedef endian_arithmetic<order::little, int_least32_t, 32> little_int32_t;
|
||||
typedef endian_arithmetic<order::little, int_least64_t, 40> little_int40_t;
|
||||
typedef endian_arithmetic<order::little, int_least64_t, 48> little_int48_t;
|
||||
typedef endian_arithmetic<order::little, int_least64_t, 56> little_int56_t;
|
||||
typedef endian_arithmetic<order::little, int_least64_t, 64> little_int64_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least8_t, 8> little_int8_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least16_t, 16> little_int16_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least32_t, 24> little_int24_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least32_t, 32> little_int32_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least64_t, 40> little_int40_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least64_t, 48> little_int48_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least64_t, 56> little_int56_t;
|
||||
typedef endian_arithmetic<order::little, std::int_least64_t, 64> little_int64_t;
|
||||
|
||||
// little endian unsigned integer unaligned types
|
||||
typedef endian_arithmetic<order::little, uint_least8_t, 8> little_uint8_t;
|
||||
typedef endian_arithmetic<order::little, uint_least16_t, 16> little_uint16_t;
|
||||
typedef endian_arithmetic<order::little, uint_least32_t, 24> little_uint24_t;
|
||||
typedef endian_arithmetic<order::little, uint_least32_t, 32> little_uint32_t;
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 40> little_uint40_t;
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 48> little_uint48_t;
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least8_t, 8> little_uint8_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least16_t, 16> little_uint16_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least32_t, 24> little_uint24_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least32_t, 32> little_uint32_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least64_t, 40> little_uint40_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least64_t, 48> little_uint48_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least64_t, 56> little_uint56_t;
|
||||
typedef endian_arithmetic<order::little, std::uint_least64_t, 64> little_uint64_t;
|
||||
|
||||
// native endian signed integer unaligned types
|
||||
typedef endian_arithmetic<order::native, int_least8_t, 8> native_int8_t;
|
||||
typedef endian_arithmetic<order::native, int_least16_t, 16> native_int16_t;
|
||||
typedef endian_arithmetic<order::native, int_least32_t, 24> native_int24_t;
|
||||
typedef endian_arithmetic<order::native, int_least32_t, 32> native_int32_t;
|
||||
typedef endian_arithmetic<order::native, int_least64_t, 40> native_int40_t;
|
||||
typedef endian_arithmetic<order::native, int_least64_t, 48> native_int48_t;
|
||||
typedef endian_arithmetic<order::native, int_least64_t, 56> native_int56_t;
|
||||
typedef endian_arithmetic<order::native, int_least64_t, 64> native_int64_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least8_t, 8> native_int8_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least16_t, 16> native_int16_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least32_t, 24> native_int24_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least32_t, 32> native_int32_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least64_t, 40> native_int40_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least64_t, 48> native_int48_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least64_t, 56> native_int56_t;
|
||||
typedef endian_arithmetic<order::native, std::int_least64_t, 64> native_int64_t;
|
||||
|
||||
// native endian unsigned integer unaligned types
|
||||
typedef endian_arithmetic<order::native, uint_least8_t, 8> native_uint8_t;
|
||||
typedef endian_arithmetic<order::native, uint_least16_t, 16> native_uint16_t;
|
||||
typedef endian_arithmetic<order::native, uint_least32_t, 24> native_uint24_t;
|
||||
typedef endian_arithmetic<order::native, uint_least32_t, 32> native_uint32_t;
|
||||
typedef endian_arithmetic<order::native, uint_least64_t, 40> native_uint40_t;
|
||||
typedef endian_arithmetic<order::native, uint_least64_t, 48> native_uint48_t;
|
||||
typedef endian_arithmetic<order::native, uint_least64_t, 56> native_uint56_t;
|
||||
typedef endian_arithmetic<order::native, uint_least64_t, 64> native_uint64_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least8_t, 8> native_uint8_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least16_t, 16> native_uint16_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least32_t, 24> native_uint24_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least32_t, 32> native_uint32_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least64_t, 40> native_uint40_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least64_t, 48> native_uint48_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least64_t, 56> native_uint56_t;
|
||||
typedef endian_arithmetic<order::native, std::uint_least64_t, 64> native_uint64_t;
|
||||
|
||||
// unaligned floating point types
|
||||
typedef endian_arithmetic<order::big, float, 32, align::no> big_float32_t;
|
||||
@ -175,8 +162,8 @@ namespace endian
|
||||
|
||||
//---------------------------------- end synopsis ------------------------------------//
|
||||
|
||||
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
|
||||
BOOST_SCOPED_ENUM(align) Align>
|
||||
template <order Order, class T, std::size_t n_bits,
|
||||
align Align>
|
||||
class endian_arithmetic
|
||||
{
|
||||
private:
|
||||
@ -197,7 +184,7 @@ public:
|
||||
|
||||
#ifndef BOOST_ENDIAN_NO_CTORS
|
||||
|
||||
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
endian_arithmetic() = default;
|
||||
|
||||
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic( T val ) BOOST_NOEXCEPT: buf_( val )
|
||||
{
|
||||
|
@ -29,11 +29,9 @@
|
||||
|
||||
#include <boost/endian/detail/endian_store.hpp>
|
||||
#include <boost/endian/detail/endian_load.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
@ -46,17 +44,6 @@
|
||||
# error Platforms with CHAR_BIT != 8 are not supported
|
||||
# endif
|
||||
|
||||
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
|
||||
# else
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
|
||||
# endif
|
||||
|
||||
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
|
||||
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
# define BOOST_ENDIAN_NO_CTORS
|
||||
# endif
|
||||
|
||||
//---------------------------------- synopsis ----------------------------------------//
|
||||
|
||||
namespace boost
|
||||
@ -64,40 +51,40 @@ namespace boost
|
||||
namespace endian
|
||||
{
|
||||
|
||||
BOOST_SCOPED_ENUM_START(align)
|
||||
enum class align
|
||||
{no, yes
|
||||
# ifdef BOOST_ENDIAN_DEPRECATED_NAMES
|
||||
, unaligned = no, aligned = yes
|
||||
# endif
|
||||
}; BOOST_SCOPED_ENUM_END
|
||||
};
|
||||
|
||||
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
|
||||
BOOST_SCOPED_ENUM(align) A = align::no>
|
||||
template <order Order, class T, std::size_t n_bits,
|
||||
align A = align::no>
|
||||
class endian_buffer;
|
||||
|
||||
// aligned big endian signed integer buffers
|
||||
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at;
|
||||
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at;
|
||||
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_at;
|
||||
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_at;
|
||||
typedef endian_buffer<order::big, std::int8_t, 8, align::yes> big_int8_buf_at;
|
||||
typedef endian_buffer<order::big, std::int16_t, 16, align::yes> big_int16_buf_at;
|
||||
typedef endian_buffer<order::big, std::int32_t, 32, align::yes> big_int32_buf_at;
|
||||
typedef endian_buffer<order::big, std::int64_t, 64, align::yes> big_int64_buf_at;
|
||||
|
||||
// aligned big endian unsigned integer buffers
|
||||
typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_at;
|
||||
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_at;
|
||||
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at;
|
||||
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at;
|
||||
typedef endian_buffer<order::big, std::uint8_t, 8, align::yes> big_uint8_buf_at;
|
||||
typedef endian_buffer<order::big, std::uint16_t, 16, align::yes> big_uint16_buf_at;
|
||||
typedef endian_buffer<order::big, std::uint32_t, 32, align::yes> big_uint32_buf_at;
|
||||
typedef endian_buffer<order::big, std::uint64_t, 64, align::yes> big_uint64_buf_at;
|
||||
|
||||
// aligned little endian signed integer buffers
|
||||
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at;
|
||||
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at;
|
||||
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_at;
|
||||
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_at;
|
||||
typedef endian_buffer<order::little, std::int8_t, 8, align::yes> little_int8_buf_at;
|
||||
typedef endian_buffer<order::little, std::int16_t, 16, align::yes> little_int16_buf_at;
|
||||
typedef endian_buffer<order::little, std::int32_t, 32, align::yes> little_int32_buf_at;
|
||||
typedef endian_buffer<order::little, std::int64_t, 64, align::yes> little_int64_buf_at;
|
||||
|
||||
// aligned little endian unsigned integer buffers
|
||||
typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_at;
|
||||
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_at;
|
||||
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at;
|
||||
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at;
|
||||
typedef endian_buffer<order::little, std::uint8_t, 8, align::yes> little_uint8_buf_at;
|
||||
typedef endian_buffer<order::little, std::uint16_t, 16, align::yes> little_uint16_buf_at;
|
||||
typedef endian_buffer<order::little, std::uint32_t, 32, align::yes> little_uint32_buf_at;
|
||||
typedef endian_buffer<order::little, std::uint64_t, 64, align::yes> little_uint64_buf_at;
|
||||
|
||||
// aligned floating point buffers
|
||||
typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at;
|
||||
@ -109,64 +96,64 @@ namespace endian
|
||||
// <cstdint> types are superior for this use case
|
||||
|
||||
// unaligned big endian signed integer buffers
|
||||
typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_t;
|
||||
typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_t;
|
||||
typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_t;
|
||||
typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_t;
|
||||
typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_t;
|
||||
typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_t;
|
||||
typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_t;
|
||||
typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least8_t, 8> big_int8_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least16_t, 16> big_int16_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least32_t, 24> big_int24_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least32_t, 32> big_int32_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least64_t, 40> big_int40_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least64_t, 48> big_int48_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least64_t, 56> big_int56_buf_t;
|
||||
typedef endian_buffer<order::big, std::int_least64_t, 64> big_int64_buf_t;
|
||||
|
||||
// unaligned big endian unsigned integer buffers
|
||||
typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t;
|
||||
typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least8_t, 8> big_uint8_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least16_t, 16> big_uint16_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least32_t, 24> big_uint24_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least32_t, 32> big_uint32_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least64_t, 40> big_uint40_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least64_t, 48> big_uint48_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least64_t, 56> big_uint56_buf_t;
|
||||
typedef endian_buffer<order::big, std::uint_least64_t, 64> big_uint64_buf_t;
|
||||
|
||||
// unaligned little endian signed integer buffers
|
||||
typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t;
|
||||
typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t;
|
||||
typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_t;
|
||||
typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_t;
|
||||
typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_t;
|
||||
typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_t;
|
||||
typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_t;
|
||||
typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least8_t, 8> little_int8_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least16_t, 16> little_int16_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least32_t, 24> little_int24_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least32_t, 32> little_int32_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least64_t, 40> little_int40_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least64_t, 48> little_int48_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least64_t, 56> little_int56_buf_t;
|
||||
typedef endian_buffer<order::little, std::int_least64_t, 64> little_int64_buf_t;
|
||||
|
||||
// unaligned little endian unsigned integer buffers
|
||||
typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least8_t, 8> little_uint8_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least16_t, 16> little_uint16_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least32_t, 24> little_uint24_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least32_t, 32> little_uint32_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least64_t, 40> little_uint40_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least64_t, 48> little_uint48_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least64_t, 56> little_uint56_buf_t;
|
||||
typedef endian_buffer<order::little, std::uint_least64_t, 64> little_uint64_buf_t;
|
||||
|
||||
// unaligned native endian signed integer buffers
|
||||
typedef endian_buffer<order::native, int_least8_t, 8> native_int8_buf_t;
|
||||
typedef endian_buffer<order::native, int_least16_t, 16> native_int16_buf_t;
|
||||
typedef endian_buffer<order::native, int_least32_t, 24> native_int24_buf_t;
|
||||
typedef endian_buffer<order::native, int_least32_t, 32> native_int32_buf_t;
|
||||
typedef endian_buffer<order::native, int_least64_t, 40> native_int40_buf_t;
|
||||
typedef endian_buffer<order::native, int_least64_t, 48> native_int48_buf_t;
|
||||
typedef endian_buffer<order::native, int_least64_t, 56> native_int56_buf_t;
|
||||
typedef endian_buffer<order::native, int_least64_t, 64> native_int64_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least8_t, 8> native_int8_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least16_t, 16> native_int16_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least32_t, 24> native_int24_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least32_t, 32> native_int32_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least64_t, 40> native_int40_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least64_t, 48> native_int48_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least64_t, 56> native_int56_buf_t;
|
||||
typedef endian_buffer<order::native, std::int_least64_t, 64> native_int64_buf_t;
|
||||
|
||||
// unaligned native endian unsigned integer buffers
|
||||
typedef endian_buffer<order::native, uint_least8_t, 8> native_uint8_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least16_t, 16> native_uint16_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least32_t, 24> native_uint24_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least32_t, 32> native_uint32_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least64_t, 40> native_uint40_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least64_t, 48> native_uint48_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least64_t, 56> native_uint56_buf_t;
|
||||
typedef endian_buffer<order::native, uint_least64_t, 64> native_uint64_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least8_t, 8> native_uint8_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least16_t, 16> native_uint16_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least32_t, 24> native_uint24_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least32_t, 32> native_uint32_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least64_t, 40> native_uint40_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least64_t, 48> native_uint48_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least64_t, 56> native_uint56_buf_t;
|
||||
typedef endian_buffer<order::native, std::uint_least64_t, 64> native_uint64_buf_t;
|
||||
|
||||
// unaligned floating point buffers
|
||||
typedef endian_buffer<order::big, float, 32, align::no> big_float32_buf_t;
|
||||
@ -177,8 +164,8 @@ namespace endian
|
||||
typedef endian_buffer<order::native, double, 64, align::no> native_float64_buf_t;
|
||||
|
||||
// Stream inserter
|
||||
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
|
||||
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
|
||||
template <class charT, class traits, order Order, class T,
|
||||
std::size_t n_bits, align A>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os,
|
||||
const endian_buffer<Order, T, n_bits, A>& x)
|
||||
@ -187,8 +174,8 @@ namespace endian
|
||||
}
|
||||
|
||||
// Stream extractor
|
||||
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
|
||||
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
|
||||
template <class charT, class traits, order Order, class T,
|
||||
std::size_t n_bits, align A>
|
||||
std::basic_istream<charT, traits>&
|
||||
operator>>(std::basic_istream<charT, traits>& is,
|
||||
endian_buffer<Order, T, n_bits, A>& x)
|
||||
@ -215,14 +202,14 @@ namespace endian
|
||||
|
||||
// unaligned endian_buffer specialization
|
||||
|
||||
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
|
||||
template< order Order, class T, std::size_t n_bits >
|
||||
class endian_buffer<Order, T, n_bits, align::no>
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_CTORS
|
||||
public:
|
||||
#endif
|
||||
|
||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
|
||||
unsigned char value_[ n_bits / 8 ];
|
||||
|
||||
@ -232,7 +219,7 @@ public:
|
||||
|
||||
#ifndef BOOST_ENDIAN_NO_CTORS
|
||||
|
||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
endian_buffer() = default;
|
||||
|
||||
explicit endian_buffer( T val ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -267,13 +254,13 @@ public:
|
||||
|
||||
// aligned endian_buffer specialization
|
||||
|
||||
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
|
||||
template< order Order, class T, std::size_t n_bits >
|
||||
class endian_buffer<Order, T, n_bits, align::yes>
|
||||
{
|
||||
private:
|
||||
|
||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||
|
||||
union
|
||||
{
|
||||
@ -287,7 +274,7 @@ public:
|
||||
|
||||
#ifndef BOOST_ENDIAN_NO_CTORS
|
||||
|
||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
endian_buffer() = default;
|
||||
|
||||
explicit endian_buffer( T val ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -325,8 +312,8 @@ class endian_buffer<order::native, T, n_bits, align::yes>
|
||||
{
|
||||
private:
|
||||
|
||||
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 );
|
||||
|
||||
T value_;
|
||||
|
||||
@ -336,7 +323,7 @@ public:
|
||||
|
||||
#ifndef BOOST_ENDIAN_NO_CTORS
|
||||
|
||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
endian_buffer() = default;
|
||||
|
||||
explicit endian_buffer( T val ) BOOST_NOEXCEPT: value_( val )
|
||||
{
|
||||
|
@ -12,12 +12,10 @@
|
||||
#include <boost/endian/detail/endian_load.hpp>
|
||||
#include <boost/endian/detail/endian_store.hpp>
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
|
||||
//------------------------------------- synopsis ---------------------------------------//
|
||||
|
||||
@ -65,7 +63,7 @@ namespace endian
|
||||
// Returns: x if native endian order is little, otherwise endian_reverse(x)
|
||||
|
||||
// generic conditional reverse byte order
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||
template <order From, order To,
|
||||
class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
|
||||
// Returns: If From == To have different values, from.
|
||||
@ -76,7 +74,7 @@ namespace endian
|
||||
// runtime conditional reverse byte order
|
||||
template <class EndianReversible >
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
|
||||
order from_order, order to_order)
|
||||
BOOST_NOEXCEPT;
|
||||
// Returns: from_order == to_order ? from : endian_reverse(from).
|
||||
|
||||
@ -132,14 +130,14 @@ namespace endian
|
||||
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
|
||||
|
||||
// generic conditional reverse in place
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||
template <order From, order To,
|
||||
class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
|
||||
// runtime reverse in place
|
||||
template <class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
|
||||
order from_order, order to_order)
|
||||
BOOST_NOEXCEPT;
|
||||
|
||||
//----------------------------------- end synopsis -------------------------------------//
|
||||
@ -172,13 +170,13 @@ namespace detail
|
||||
{
|
||||
|
||||
template<class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::true_type ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template<class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::false_type ) BOOST_NOEXCEPT
|
||||
{
|
||||
return endian_reverse( x );
|
||||
}
|
||||
@ -186,19 +184,19 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversib
|
||||
} // namespace detail
|
||||
|
||||
// generic conditional reverse
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
|
||||
template <order From, order To, class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
|
||||
return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
|
||||
return detail::conditional_reverse_impl( x, std::integral_constant<bool, From == To>() );
|
||||
}
|
||||
|
||||
// runtime conditional reverse
|
||||
template <class EndianReversible>
|
||||
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
|
||||
order from_order, order to_order ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
|
||||
return from_order == to_order? x: endian_reverse( x );
|
||||
}
|
||||
|
||||
@ -234,12 +232,12 @@ namespace detail
|
||||
{
|
||||
|
||||
template<class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
|
||||
inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, std::true_type ) BOOST_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
template<class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
|
||||
inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, std::false_type ) BOOST_NOEXCEPT
|
||||
{
|
||||
endian_reverse_inplace( x );
|
||||
}
|
||||
@ -247,25 +245,25 @@ inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost:
|
||||
} // namespace detail
|
||||
|
||||
// generic conditional reverse in place
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
|
||||
template <order From, order To, class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::is_class<EndianReversibleInplace>::value ||
|
||||
boost::is_array<EndianReversibleInplace>::value ||
|
||||
BOOST_ENDIAN_STATIC_ASSERT(
|
||||
std::is_class<EndianReversibleInplace>::value ||
|
||||
std::is_array<EndianReversibleInplace>::value ||
|
||||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
|
||||
|
||||
detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
|
||||
detail::conditional_reverse_inplace_impl( x, std::integral_constant<bool, From == To>() );
|
||||
}
|
||||
|
||||
// runtime reverse in place
|
||||
template <class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace( EndianReversibleInplace& x,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
|
||||
order from_order, order to_order ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT(
|
||||
boost::is_class<EndianReversibleInplace>::value ||
|
||||
boost::is_array<EndianReversibleInplace>::value ||
|
||||
BOOST_ENDIAN_STATIC_ASSERT(
|
||||
std::is_class<EndianReversibleInplace>::value ||
|
||||
std::is_array<EndianReversibleInplace>::value ||
|
||||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
|
||||
|
||||
if( from_order != to_order )
|
||||
@ -278,310 +276,310 @@ inline void conditional_reverse_inplace( EndianReversibleInplace& x,
|
||||
|
||||
// load 16
|
||||
|
||||
inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
|
||||
return boost::endian::endian_load<std::int16_t, 2, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint16_t, 2, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
|
||||
return boost::endian::endian_load<std::int16_t, 2, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint16_t, 2, order::big>( p );
|
||||
}
|
||||
|
||||
// load 24
|
||||
|
||||
inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
|
||||
return boost::endian::endian_load<std::int32_t, 3, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint32_t, 3, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
|
||||
return boost::endian::endian_load<std::int32_t, 3, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint32_t, 3, order::big>( p );
|
||||
}
|
||||
|
||||
// load 32
|
||||
|
||||
inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
|
||||
return boost::endian::endian_load<std::int32_t, 4, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint32_t, 4, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
|
||||
return boost::endian::endian_load<std::int32_t, 4, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint32_t, 4, order::big>( p );
|
||||
}
|
||||
|
||||
// load 40
|
||||
|
||||
inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 5, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 5, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 5, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 5, order::big>( p );
|
||||
}
|
||||
|
||||
// load 48
|
||||
|
||||
inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 6, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 6, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 6, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 6, order::big>( p );
|
||||
}
|
||||
|
||||
// load 56
|
||||
|
||||
inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 7, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 7, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 7, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 7, order::big>( p );
|
||||
}
|
||||
|
||||
// load 64
|
||||
|
||||
inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 8, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 8, order::little>( p );
|
||||
}
|
||||
|
||||
inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
|
||||
return boost::endian::endian_load<std::int64_t, 8, order::big>( p );
|
||||
}
|
||||
|
||||
inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
|
||||
return boost::endian::endian_load<std::uint64_t, 8, order::big>( p );
|
||||
}
|
||||
|
||||
// store 16
|
||||
|
||||
inline void store_little_s16( unsigned char * p, boost::int16_t v )
|
||||
inline void store_little_s16( unsigned char * p, std::int16_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int16_t, 2, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u16( unsigned char * p, boost::uint16_t v )
|
||||
inline void store_little_u16( unsigned char * p, std::uint16_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint16_t, 2, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s16( unsigned char * p, boost::int16_t v )
|
||||
inline void store_big_s16( unsigned char * p, std::int16_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int16_t, 2, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u16( unsigned char * p, boost::uint16_t v )
|
||||
inline void store_big_u16( unsigned char * p, std::uint16_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint16_t, 2, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 24
|
||||
|
||||
inline void store_little_s24( unsigned char * p, boost::int32_t v )
|
||||
inline void store_little_s24( unsigned char * p, std::int32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int32_t, 3, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u24( unsigned char * p, boost::uint32_t v )
|
||||
inline void store_little_u24( unsigned char * p, std::uint32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint32_t, 3, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s24( unsigned char * p, boost::int32_t v )
|
||||
inline void store_big_s24( unsigned char * p, std::int32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int32_t, 3, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u24( unsigned char * p, boost::uint32_t v )
|
||||
inline void store_big_u24( unsigned char * p, std::uint32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint32_t, 3, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 32
|
||||
|
||||
inline void store_little_s32( unsigned char * p, boost::int32_t v )
|
||||
inline void store_little_s32( unsigned char * p, std::int32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int32_t, 4, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u32( unsigned char * p, boost::uint32_t v )
|
||||
inline void store_little_u32( unsigned char * p, std::uint32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint32_t, 4, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s32( unsigned char * p, boost::int32_t v )
|
||||
inline void store_big_s32( unsigned char * p, std::int32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int32_t, 4, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u32( unsigned char * p, boost::uint32_t v )
|
||||
inline void store_big_u32( unsigned char * p, std::uint32_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint32_t, 4, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 40
|
||||
|
||||
inline void store_little_s40( unsigned char * p, boost::int64_t v )
|
||||
inline void store_little_s40( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 5, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u40( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_little_u40( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 5, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s40( unsigned char * p, boost::int64_t v )
|
||||
inline void store_big_s40( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 5, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u40( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_big_u40( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 5, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 48
|
||||
|
||||
inline void store_little_s48( unsigned char * p, boost::int64_t v )
|
||||
inline void store_little_s48( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 6, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u48( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_little_u48( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 6, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s48( unsigned char * p, boost::int64_t v )
|
||||
inline void store_big_s48( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 6, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u48( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_big_u48( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 6, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 56
|
||||
|
||||
inline void store_little_s56( unsigned char * p, boost::int64_t v )
|
||||
inline void store_little_s56( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 7, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u56( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_little_u56( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 7, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s56( unsigned char * p, boost::int64_t v )
|
||||
inline void store_big_s56( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 7, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u56( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_big_u56( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 7, order::big>( p, v );
|
||||
}
|
||||
|
||||
// store 64
|
||||
|
||||
inline void store_little_s64( unsigned char * p, boost::int64_t v )
|
||||
inline void store_little_s64( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 8, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_little_u64( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_little_u64( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 8, order::little>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_s64( unsigned char * p, boost::int64_t v )
|
||||
inline void store_big_s64( unsigned char * p, std::int64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
|
||||
boost::endian::endian_store<std::int64_t, 8, order::big>( p, v );
|
||||
}
|
||||
|
||||
inline void store_big_u64( unsigned char * p, boost::uint64_t v )
|
||||
inline void store_big_u64( unsigned char * p, std::uint64_t v )
|
||||
{
|
||||
boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
|
||||
boost::endian::endian_store<std::uint64_t, 8, order::big>( p, v );
|
||||
}
|
||||
|
||||
} // namespace endian
|
||||
|
@ -10,10 +10,8 @@
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/is_trivially_copyable.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
@ -25,7 +23,7 @@ namespace endian
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl
|
||||
template<class T, std::size_t N1, order O1, std::size_t N2, order O2> struct endian_load_impl
|
||||
{
|
||||
};
|
||||
|
||||
@ -38,11 +36,11 @@ template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, B
|
||||
// T is TriviallyCopyable
|
||||
// if N < sizeof(T), T is integral or enum
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
|
||||
template<class T, std::size_t N, order Order>
|
||||
inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
|
||||
return detail::endian_load_impl<T, sizeof(T), order::native, N, Order>()( p );
|
||||
}
|
||||
@ -52,11 +50,11 @@ namespace detail
|
||||
|
||||
// same endianness, same size
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_impl<T, N, O, N, O>
|
||||
template<class T, std::size_t N, order O> struct endian_load_impl<T, N, O, N, O>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
T t;
|
||||
std::memcpy( &t, p, N );
|
||||
@ -66,11 +64,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_
|
||||
|
||||
// same size, reverse endianness
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl<T, N, O1, N, O2>
|
||||
template<class T, std::size_t N, order O1, order O2> struct endian_load_impl<T, N, O1, N, O2>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
typename integral_by_size<N>::type tmp;
|
||||
std::memcpy( &tmp, p, N );
|
||||
@ -85,30 +83,30 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(
|
||||
|
||||
// expanding load 1 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 2, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[1] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
return boost::endian::endian_load<T, 2, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 2, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
|
||||
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[0] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[1] = p[0];
|
||||
|
||||
return boost::endian::endian_load<T, 2, order::big>( tmp );
|
||||
@ -117,15 +115,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2,
|
||||
|
||||
// expanding load 1 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = fill;
|
||||
@ -136,15 +134,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -157,15 +155,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
|
||||
|
||||
// expanding load 2 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 2, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -176,15 +174,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 2, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -197,32 +195,32 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
|
||||
|
||||
// expanding load 3 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 3, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[3] = std::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 4, Order, 3, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[0] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[1] = p[0];
|
||||
tmp[2] = p[1];
|
||||
tmp[3] = p[2];
|
||||
@ -233,15 +231,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
|
||||
|
||||
// expanding load 1 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
|
||||
@ -257,15 +255,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -283,15 +281,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 2 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 2, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -307,15 +305,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 2, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -333,15 +331,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 3 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 3, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -357,15 +355,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 3, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -383,15 +381,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 4 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 4, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -407,15 +405,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 4, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -433,15 +431,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 5 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 5, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -457,15 +455,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 5, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -483,15 +481,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 6 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 6, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -507,15 +505,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 6, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
@ -533,15 +531,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
|
||||
// expanding load 7 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::little>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 7, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
@ -557,15 +555,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::big>
|
||||
template<class T, order Order> struct endian_load_impl<T, 8, Order, 7, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
|
||||
|
@ -8,14 +8,11 @@
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/intrinsic.hpp>
|
||||
#include <boost/endian/detail/is_scoped_enum.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/enable_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/endian/detail/is_integral.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
@ -47,12 +44,12 @@ namespace detail
|
||||
// -- intrinsic approach suggested by reviewers, and by David Stone, who provided
|
||||
// his Boost licensed macro implementation (detail/intrinsic.hpp)
|
||||
|
||||
inline uint8_t BOOST_CONSTEXPR endian_reverse_impl( uint8_t x ) BOOST_NOEXCEPT
|
||||
inline std::uint8_t BOOST_CONSTEXPR endian_reverse_impl( std::uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_NOEXCEPT
|
||||
inline std::uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
@ -65,11 +62,11 @@ inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_N
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_NOEXCEPT
|
||||
inline std::uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
uint32_t step16 = x << 16 | x >> 16;
|
||||
std::uint32_t step16 = x << 16 | x >> 16;
|
||||
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
|
||||
|
||||
#else
|
||||
@ -79,12 +76,12 @@ inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_N
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_NOEXCEPT
|
||||
inline std::uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
uint64_t step32 = x << 32 | x >> 32;
|
||||
uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
|
||||
std::uint64_t step32 = x << 32 | x >> 32;
|
||||
std::uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
|
||||
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
|
||||
|
||||
#else
|
||||
@ -94,27 +91,27 @@ inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_N
|
||||
# endif
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
|
||||
inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) BOOST_NOEXCEPT
|
||||
inline __uint128_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( __uint128_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return endian_reverse_impl( static_cast<uint64_t>( x >> 64 ) ) |
|
||||
static_cast<uint128_type>( endian_reverse_impl( static_cast<uint64_t>( x ) ) ) << 64;
|
||||
return endian_reverse_impl( static_cast<std::uint64_t>( x >> 64 ) ) |
|
||||
static_cast<__uint128_t>( endian_reverse_impl( static_cast<std::uint64_t>( x ) ) ) << 64;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// is_endian_reversible
|
||||
|
||||
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
|
||||
(boost::is_integral<T>::value && !boost::is_same<T, bool>::value) || is_scoped_enum<T>::value>
|
||||
template<class T> struct is_endian_reversible: std::integral_constant<bool,
|
||||
(is_integral<T>::value && !std::is_same<T, bool>::value) || is_scoped_enum<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
// is_endian_reversible_inplace
|
||||
|
||||
template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
|
||||
boost::is_integral<T>::value || boost::is_enum<T>::value || boost::is_same<T, float>::value || boost::is_same<T, double>::value>
|
||||
template<class T> struct is_endian_reversible_inplace: std::integral_constant<bool,
|
||||
is_integral<T>::value || std::is_enum<T>::value || std::is_same<T, float>::value || std::is_same<T, double>::value>
|
||||
{
|
||||
};
|
||||
|
||||
@ -124,10 +121,10 @@ template<class T> struct is_endian_reversible_inplace: boost::integral_constant<
|
||||
// T is non-bool integral or scoped enumeration type
|
||||
|
||||
template<class T> inline BOOST_CONSTEXPR
|
||||
typename enable_if_< !is_class<T>::value, T >::type
|
||||
typename std::enable_if< !std::is_class<T>::value, T >::type
|
||||
endian_reverse( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
|
||||
|
||||
typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t;
|
||||
|
||||
@ -138,10 +135,10 @@ template<class T> inline BOOST_CONSTEXPR
|
||||
// T is integral, enumeration, float or double
|
||||
|
||||
template<class T> inline
|
||||
typename enable_if_< !is_class<T>::value >::type
|
||||
typename std::enable_if< !std::is_class<T>::value >::type
|
||||
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
|
||||
|
||||
typename detail::integral_by_size< sizeof(T) >::type x2;
|
||||
|
||||
@ -155,7 +152,7 @@ template<class T> inline
|
||||
// Default implementation for user-defined types
|
||||
|
||||
template<class T> inline
|
||||
typename enable_if_< is_class<T>::value >::type
|
||||
typename std::enable_if< std::is_class<T>::value >::type
|
||||
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
|
||||
{
|
||||
x = endian_reverse( x );
|
||||
|
@ -10,9 +10,8 @@
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/is_trivially_copyable.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/endian/detail/static_assert.hpp>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
@ -24,7 +23,7 @@ namespace endian
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl
|
||||
template<class T, std::size_t N1, order O1, std::size_t N2, order O2> struct endian_store_impl
|
||||
{
|
||||
};
|
||||
|
||||
@ -37,11 +36,11 @@ template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, B
|
||||
// T is TriviallyCopyable
|
||||
// if N < sizeof(T), T is integral or enum
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
|
||||
template<class T, std::size_t N, order Order>
|
||||
inline void endian_store( unsigned char * p, T const & v ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
|
||||
return detail::endian_store_impl<T, sizeof(T), order::native, N, Order>()( p, v );
|
||||
}
|
||||
@ -51,11 +50,11 @@ namespace detail
|
||||
|
||||
// same endianness, same size
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store_impl<T, N, O, N, O>
|
||||
template<class T, std::size_t N, order O> struct endian_store_impl<T, N, O, N, O>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
std::memcpy( p, &v, N );
|
||||
}
|
||||
@ -63,11 +62,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store
|
||||
|
||||
// same size, reverse endianness
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl<T, N, O1, N, O2>
|
||||
template<class T, std::size_t N, order O1, order O2> struct endian_store_impl<T, N, O1, N, O2>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
typename integral_by_size<N>::type tmp;
|
||||
std::memcpy( &tmp, &v, N );
|
||||
@ -80,11 +79,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(
|
||||
|
||||
// truncating store 2 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 2, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
boost::endian::endian_store<T, 2, order::little>( tmp, v );
|
||||
@ -93,11 +92,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 2, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
boost::endian::endian_store<T, 2, order::big>( tmp, v );
|
||||
@ -108,11 +107,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2,
|
||||
|
||||
// truncating store 4 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
@ -121,11 +120,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
@ -136,11 +135,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
|
||||
// truncating store 4 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 2, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
@ -150,11 +149,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 2, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
@ -166,11 +165,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
|
||||
// truncating store 4 -> 3
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 3, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
@ -181,11 +180,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 4, Order, 3, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
@ -198,11 +197,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
|
||||
|
||||
// truncating store 8 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -211,11 +210,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -226,11 +225,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 2, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -240,11 +239,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 2, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -256,11 +255,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 3
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 3, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -271,11 +270,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 3, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -288,11 +287,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 4, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -304,11 +303,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 4, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -322,11 +321,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 5
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 5, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -339,11 +338,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 5, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -358,11 +357,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 6
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 6, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -376,11 +375,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 6, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
@ -396,11 +395,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
|
||||
// truncating store 8 -> 7
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::little>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 7, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
@ -415,11 +414,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::big>
|
||||
template<class T, order Order> struct endian_store_impl<T, 8, Order, 7, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
@ -6,8 +6,7 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost
|
||||
@ -23,29 +22,29 @@ template<std::size_t N> struct integral_by_size
|
||||
|
||||
template<> struct integral_by_size<1>
|
||||
{
|
||||
typedef uint8_t type;
|
||||
typedef std::uint8_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<2>
|
||||
{
|
||||
typedef uint16_t type;
|
||||
typedef std::uint16_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<4>
|
||||
{
|
||||
typedef uint32_t type;
|
||||
typedef std::uint32_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<8>
|
||||
{
|
||||
typedef uint64_t type;
|
||||
typedef std::uint64_t type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
|
||||
template<> struct integral_by_size<16>
|
||||
{
|
||||
typedef uint128_type type;
|
||||
typedef __uint128_t type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
37
include/boost/endian/detail/is_integral.hpp
Normal file
37
include/boost/endian/detail/is_integral.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_IS_INTEGRAL_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_IS_INTEGRAL_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct is_integral: std::is_integral<T>
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(__SIZEOF_INT128__)
|
||||
|
||||
template<> struct is_integral<__int128_t>: std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct is_integral<__uint128_t>: std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_IS_INTEGRAL_HPP_INCLUDED
|
@ -6,9 +6,7 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -17,13 +15,13 @@ namespace endian
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct negation: boost::integral_constant<bool, !T::value> {};
|
||||
template<class T> struct negation: std::integral_constant<bool, !T::value> {};
|
||||
|
||||
template<class T> struct is_scoped_enum:
|
||||
boost::conditional<
|
||||
boost::is_enum<T>::value,
|
||||
negation< boost::is_convertible<T, int> >,
|
||||
boost::false_type
|
||||
std::conditional<
|
||||
std::is_enum<T>::value,
|
||||
negation< std::is_convertible<T, int> >,
|
||||
std::false_type
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
@ -1,19 +1,12 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Copyright 2019, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#include <boost/type_traits/has_trivial_assign.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
# include <type_traits>
|
||||
#endif
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -22,14 +15,14 @@ namespace endian
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#if defined( BOOST_LIBSTDCXX_VERSION ) && BOOST_LIBSTDCXX_VERSION < 50000
|
||||
|
||||
using std::is_trivially_copyable;
|
||||
template<class T> struct is_trivially_copyable: std::integral_constant<bool,
|
||||
__has_trivial_copy(T) && __has_trivial_assign(T) && __has_trivial_destructor(T)> {};
|
||||
|
||||
#else
|
||||
|
||||
template<class T> struct is_trivially_copyable: boost::integral_constant<bool,
|
||||
boost::has_trivial_copy<T>::value && boost::has_trivial_assign<T>::value && boost::has_trivial_destructor<T>::value> {};
|
||||
using std::is_trivially_copyable;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
|
||||
@ -43,13 +41,12 @@ namespace boost
|
||||
namespace endian
|
||||
{
|
||||
|
||||
BOOST_SCOPED_ENUM_START(order)
|
||||
enum class order
|
||||
{
|
||||
big,
|
||||
little,
|
||||
native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
|
||||
|
||||
}; BOOST_SCOPED_ENUM_END
|
||||
};
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
10
include/boost/endian/detail/static_assert.hpp
Normal file
10
include/boost/endian/detail/static_assert.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_ENDIAN_STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED
|
@ -29,8 +29,8 @@ namespace endian
|
||||
typedef align alignment;
|
||||
|
||||
# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES
|
||||
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
|
||||
BOOST_SCOPED_ENUM(align) Align = align::no>
|
||||
template <order Order, class T, std::size_t n_bits,
|
||||
align Align = align::no>
|
||||
using endian = endian_arithmetic<Order, T, n_bits, Align>;
|
||||
# endif
|
||||
|
||||
|
@ -13,5 +13,5 @@
|
||||
"Math",
|
||||
"Miscellaneous"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::endian Boost::core)
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::endian Boost::core Boost::type_traits)
|
||||
|
||||
endif()
|
||||
|
@ -7,12 +7,11 @@ cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_endian REQUIRED)
|
||||
find_package(boost_core REQUIRED)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::endian Boost::core)
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::endian)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
31
test/cmake_install_test/main.cpp
Normal file
31
test/cmake_install_test/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/arithmetic.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#define BOOST_TEST_EQ(x, y) assert((x)==(y))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::endian;
|
||||
|
||||
{
|
||||
little_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
|
||||
}
|
||||
|
||||
{
|
||||
big_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
|
||||
}
|
||||
}
|
@ -7,33 +7,12 @@ cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../.. boostorg/endian)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
|
||||
# boost_add_subdir
|
||||
|
||||
function(boost_add_subdir name)
|
||||
|
||||
add_subdirectory(../../../${name} boostorg/${name})
|
||||
|
||||
endfunction()
|
||||
|
||||
# primary dependencies
|
||||
|
||||
boost_add_subdir(config)
|
||||
boost_add_subdir(core)
|
||||
boost_add_subdir(static_assert)
|
||||
boost_add_subdir(type_traits)
|
||||
|
||||
# secondary dependencies
|
||||
|
||||
boost_add_subdir(assert)
|
||||
boost_add_subdir(throw_exception)
|
||||
|
||||
# --target check
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::endian Boost::core)
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::endian)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
31
test/cmake_subdir_test/main.cpp
Normal file
31
test/cmake_subdir_test/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/arithmetic.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#define BOOST_TEST_EQ(x, y) assert((x)==(y))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::endian;
|
||||
|
||||
{
|
||||
little_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
|
||||
}
|
||||
|
||||
{
|
||||
big_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
|
||||
}
|
||||
}
|
@ -29,14 +29,14 @@
|
||||
namespace be = boost::endian;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using boost::int8_t;
|
||||
using boost::uint8_t;
|
||||
using boost::int16_t;
|
||||
using boost::uint16_t;
|
||||
using boost::int32_t;
|
||||
using boost::uint32_t;
|
||||
using boost::int64_t;
|
||||
using boost::uint64_t;
|
||||
using std::int8_t;
|
||||
using std::uint8_t;
|
||||
using std::int16_t;
|
||||
using std::uint16_t;
|
||||
using std::int32_t;
|
||||
using std::uint32_t;
|
||||
using std::int64_t;
|
||||
using std::uint64_t;
|
||||
|
||||
template <class T> inline T std_endian_reverse(T x) BOOST_NOEXCEPT
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_arithmetic_( T const& x )
|
||||
template<boost::endian::order Order, boost::endian::align Align, class T> void test_arithmetic_( T const& x )
|
||||
{
|
||||
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );
|
||||
|
||||
@ -78,7 +78,7 @@ template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost:
|
||||
}
|
||||
}
|
||||
|
||||
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_integral_( T const& x )
|
||||
template<boost::endian::order Order, boost::endian::align Align, class T> void test_integral_( T const& x )
|
||||
{
|
||||
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );
|
||||
|
||||
|
@ -176,17 +176,17 @@ template<class T> void test_np()
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::int8_t>();
|
||||
test<boost::uint8_t>();
|
||||
test<std::int8_t>();
|
||||
test<std::uint8_t>();
|
||||
|
||||
test<boost::int16_t>();
|
||||
test<boost::uint16_t>();
|
||||
test<std::int16_t>();
|
||||
test<std::uint16_t>();
|
||||
|
||||
test<boost::int32_t>();
|
||||
test<boost::uint32_t>();
|
||||
test<std::int32_t>();
|
||||
test<std::uint32_t>();
|
||||
|
||||
test<boost::int64_t>();
|
||||
test<boost::uint64_t>();
|
||||
test<std::int64_t>();
|
||||
test<std::uint64_t>();
|
||||
|
||||
test<char>();
|
||||
test<unsigned char>();
|
||||
|
Reference in New Issue
Block a user