2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-20 04:42:22 +00:00

Compare commits

...

17 Commits
2.0.2 ... 2.0.3

Author SHA1 Message Date
Antony Polukhin
10848f71ae add missing include 2021-10-01 14:59:18 +03:00
Antony Polukhin
7d925660bb fix -Wzero-length-array warning 2021-09-29 11:38:07 +03:00
Antony Polukhin
87e77b9b43 do not use depth 1 for checkouts in CI 2021-09-20 21:47:01 +03:00
Antony Polukhin
b331ef58f5 docs cleanup 2021-09-11 19:25:18 +03:00
Antony Polukhin
5579d11588 minor update of the docs 2021-09-11 18:00:46 +03:00
Antony Polukhin
51f6422c07 update CI setup 2021-09-11 14:16:53 +03:00
Antony Polukhin
87c9c2d76c Merge pull request #88 from alexey-romanov/develop
workaround for msvc compilers <= 1920
2021-07-24 21:35:04 +03:00
Aleksei Romanov
d1e7e87a31 workaround for msvc compilers <= 1920 2021-07-15 12:16:17 +03:00
Antony Polukhin
0436e48a79 Restore inspect tool runs 2021-06-12 19:42:09 +03:00
Antony Polukhin
4d9294cb1f final polishings for of boost-free version 2021-06-10 18:47:18 +03:00
Antony Polukhin
e75c066ddc freestanding docs anc CI fixes 2021-06-10 18:12:22 +03:00
Antony Polukhin
e51a594dbb fix strip_boost_namespace.sh work if target pathh is missing 2021-06-10 11:42:19 +03:00
Antony Polukhin
12f2b3a365 CI fixes 2021-06-10 11:18:25 +03:00
Antony Polukhin
2a1b206244 temporary disable inspect tool, as it is broken in develop 2021-06-10 10:10:38 +03:00
Antony Polukhin
b4bee46c54 Merge github.com:boostorg/pfr into develop 2021-06-09 21:06:07 +03:00
Antony Polukhin
444094f20d add helper script to remove boost namespace from the library and smoke-test the result 2021-06-09 21:05:19 +03:00
Peter Dimov
da12b52759 Add CMakeLists.txt 2021-05-28 00:10:03 +03:00
13 changed files with 125 additions and 210 deletions

View File

@@ -17,14 +17,10 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-16.04
install: g++-4.8
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
- toolset: gcc-9
- toolset: gcc-9 # Do not remove! It is the only toolset that tests misc/strip_boost_namespace.sh
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
- toolset: gcc-10
@@ -33,18 +29,6 @@ jobs:
cxxflags: "cxxflags=--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined"
linkflags: "linkflags=--coverage -lasan -lubsan"
gcov_tool: "gcov-10"
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-16.04
install: clang-3.7
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17" # Do not run in 2a mode because of the "chrono:1345:24: error: unknown type name 'strong_ordering'"
os: ubuntu-20.04
cxxflags: "cxxflags=--coverage"
linkflags: "linkflags=--coverage"
gcov_tool: "llvm-cov-9 gcov"
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
@@ -102,6 +86,10 @@ jobs:
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release "${{matrix.cxxflags}}" "${{matrix.linkflags}}" "${{matrix.launcher}}"
dist/bin/inspect libs/$LIBRARY
- name: Test boost namespace stripping
if: ${{matrix.toolset == 'gcc-9'}}
run: ../boost-root/libs/$LIBRARY/misc/strip_boost_namespace.sh
- name: Prepare coverage data
if: matrix.gcov_tool
run: |
@@ -168,7 +156,7 @@ jobs:
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
git clone -b %BOOST_BRANCH% --depth 10 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

View File

@@ -1,178 +0,0 @@
# Use, modification, and distribution are
# subject to 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)
#
# Copyright Antony Polukhin 2014-2020.
#
# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
# and how it can be used with Boost libraries.
#
# File revision #9 (with DIFF)
language: cpp
os: linux
dist: bionic
# `--coverage` flags required to generate coverage info for Coveralls
matrix:
include:
# - env: B2_ARGS='cxxstd=14,1y toolset=gcc-6 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD -fno-rtti" linkflags="--coverage -lasan -lubsan"'
# name: "GCC-6, no RTTI"
# addons:
# apt:
# sources: ubuntu-toolchain-r-test
# packages: g++-6
- env: B2_ARGS='cxxstd=14,17,2a toolset=gcc-10 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -lasan -lubsan"'
name: "GCC-10"
sudo: required # Required by leak sanitizer
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-10
- env: B2_ARGS='cxxstd=14,17,2a toolset=gcc-8 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -lasan -lubsan"'
name: "GCC-8"
sudo: required # Required by leak sanitizer
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-8
- env: B2_ARGS='cxxstd=1y toolset=gcc-5 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -lasan -lubsan"'
name: "GCC-5"
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: g++-5
# - env: B2_ARGS='cxxstd=14,1y toolset=gcc-8 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD -fno-exceptions" linkflags="--coverage -lasan -lubsan"'
# name: "GCC-8, no exceptions"
# sudo: required # Required by leak sanitizer
# addons:
# apt:
# sources: ubuntu-toolchain-r-test
# packages: g++-8
- env: B2_ARGS='cxxstd=14 toolset=clang-6 cxxflags="--coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="--coverage -fsanitize=address,leak,undefined"'
name: "Clang-6"
sudo: required # Required by leak sanitizer
addons:
apt:
sources: llvm-toolchain-trusty-6
packages: clang-6.0
- env: B2_ARGS='cxxstd=14,17,20 toolset=clang-10 cxxflags="-stdlib=libc++ --coverage -fsanitize=address,leak,undefined -fno-sanitize-recover=undefined -DBOOST_TRAVISCI_BUILD" linkflags="-stdlib=libc++ --coverage -fsanitize=address,leak,undefined"'
name: "Clang-10, libc++"
sudo: required # Required by leak sanitizer
addons:
apt:
sources: llvm-toolchain-bionic-10
packages:
- clang-10
- libc++-10-dev
- libc++abi-10-dev
# Sanitizers disabled for this toolset as they started causing link troubles:
# hidden symbol `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE11__recommendEm' isn't defined
- env: B2_ARGS='cxxstd=14 toolset=clang-libc++ cxxflags="--coverage -DBOOST_TRAVISCI_BUILD" linkflags="--coverage"'
name: "Clang-3.8, libc++"
addons:
apt:
packages: libc++-dev
###############################################################################################################
# From this point and below code is same for all the Boost libs
###############################################################################################################
# Installing additional tools
addons:
apt:
sources: git-core
packages:
- git
- python-yaml
before_install:
# Autodetect Boost branch by using the following code: - BOOST_BRANCH=$TRAVIS_BRANCH
# or just directly specify it
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
# Files, which coverage results must be ignored (files from other projects).
# Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/*'
- IGNORE_COVERAGE=''
# Explicitly remove the following library from Boost and use the folder for tests. This may be usefull, if you're for example running Travis
# from `Boost.DLL` repo, while Boost already has `dll`.
#
# By default is eaual to - BOOST_LIBS_FOLDER=$(basename $TRAVIS_BUILD_DIR)
# This will force to use local repo content, instead of the Boost's default.
- BOOST_LIBS_FOLDER=pfr #$(basename $TRAVIS_BUILD_DIR)
# Global options for sanitizers
- UBSAN_OPTIONS=print_stacktrace=1
- LSAN_OPTIONS=verbosity=1:log_threads=1
# Cloning minimal set of Boost libraries
- BOOST=$HOME/boost-local
- echo "Testing $BOOST_LIBS_FOLDER, to remove $BOOST/libs/$BOOST_LIBS_FOLDER, testing branch $BOOST_BRANCH"
- git clone -b $BOOST_BRANCH --depth 10 https://github.com/boostorg/boost.git $BOOST
- cd $BOOST
- git submodule update --init --depth 10 tools/build tools/boostdep tools/inspect libs/filesystem
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" $BOOST/libs/filesystem
# Replacing Boost module with this project and installing Boost dependencies
- rm -rf $BOOST/libs/$BOOST_LIBS_FOLDER
- mv $TRAVIS_BUILD_DIR $BOOST/libs/$BOOST_LIBS_FOLDER
- TRAVIS_BUILD_DIR=$BOOST/libs/$BOOST_LIBS_FOLDER
- python tools/boostdep/depinst/depinst.py --git_args "--depth 10 --jobs 2" -I example -I examples $(basename $TRAVIS_BUILD_DIR)
- git status
# Adding missing toolsets and preparing Boost headers
- ./bootstrap.sh
- ./b2 headers
- ./b2 -j4 variant=debug tools/inspect/build
- |-
echo "using gcc ;" >> ~/user-config.jam
echo "using clang ;" >> ~/user-config.jam
echo "using clang : 3.8 : clang++-3.8 ;" >> ~/user-config.jam
echo "using clang : 4 : clang++-4.0 ;" >> ~/user-config.jam
echo "using clang : 5 : clang++-5.0 ;" >> ~/user-config.jam
echo "using clang : 6 : clang++-6.0 ;" >> ~/user-config.jam
echo "using clang : 7 : clang++-7.0 ;" >> ~/user-config.jam
echo "using clang : 8 : clang++-8 ;" >> ~/user-config.jam
echo "using clang : 10 : clang++-10 ;" >> ~/user-config.jam
echo "using clang : libc++ : clang++-libc++ ;" >> ~/user-config.jam
- cd $BOOST/libs/$BOOST_LIBS_FOLDER/test/
script:
- sh -c "../../../b2 -j2 $B2_ARGS"
- ../../../dist/bin/inspect ..
after_success:
- exit 0 # we run coverage reports from GithubActions
# Copying Coveralls data to a separate folder
- mkdir -p $TRAVIS_BUILD_DIR/coverals
- wget https://github.com/linux-test-project/lcov/archive/v1.15.zip
- unzip v1.15.zip
- LCOV="`pwd`/lcov-1.15/bin/lcov"
# Preparing Coveralls data by changind data format to a readable one
- echo "$LCOV --directory $BOOST/bin.v2/libs/$BOOST_LIBS_FOLDER --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info"
- $LCOV --directory $BOOST/bin.v2/libs/$BOOST_LIBS_FOLDER --base-directory `pwd` --capture --output-file $TRAVIS_BUILD_DIR/coverals/coverage.info
# ... erasing /test/ /example/ folder data
- cd $BOOST
- $LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info "/usr*" "*/$BOOST_LIBS_FOLDER/test/*" $IGNORE_COVERAGE "*/$BOOST_LIBS_FOLDER/tests/*" "*/$BOOST_LIBS_FOLDER/examples/*" "*/$BOOST_LIBS_FOLDER/example/*" -o $TRAVIS_BUILD_DIR/coverals/coverage.info
# ... erasing data that is not related to this project directly
- OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$BOOST_LIBS_FOLDER\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
- echo $OTHER_LIBS
- eval "$LCOV --remove $TRAVIS_BUILD_DIR/coverals/coverage.info $OTHER_LIBS -o $TRAVIS_BUILD_DIR/coverals/coverage.info"
# Sending data to Coveralls
- cd $TRAVIS_BUILD_DIR
- gem install coveralls-lcov
- coveralls-lcov coverals/coverage.info

20
CMakeLists.txt Normal file
View File

@@ -0,0 +1,20 @@
# Generated by `boostdep --cmake pfr`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_pfr VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_pfr INTERFACE)
add_library(Boost::pfr ALIAS boost_pfr)
target_include_directories(boost_pfr INTERFACE include)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -2,14 +2,16 @@
This is a C++14 library for very basic reflection that gives you access to structure elements by index and provides other `std::tuple` like methods for user defined types without any macro or boilerplate code.
Boost.PFR is a part of the [Boost C++ Libraries](https://github.com/boostorg). However, Boost.PFR is a header only library that does not depend on Boost. You can just copy the content of the "include" folder from the github into your project, and the library will work fine.
[Boost.PFR](https://boost.org/libs/pfr) is a part of the [Boost C++ Libraries](https://github.com/boostorg). However, Boost.PFR is a header only library that does not depend on Boost. You can just copy the content of the "include" folder from the github into your project, and the library will work fine.
For a version of the library without `boost::` namespace see [PFR](https://github.com/apolukhin/pfr_non_boost).
### Test results
Branches | Build | Tests coverage | More info
----------------|-------------- | -------------- |-----------
Develop: | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build Status](https://travis-ci.org/apolukhin/magic_get.svg?branch=develop)](https://travis-ci.org/apolukhin/magic_get) [![Build status](https://ci.appveyor.com/api/projects/status/3tled9gd24k9paia/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/magic-get/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=develop)](https://coveralls.io/github/apolukhin/magic_get?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/pfr.html)
Master: | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build Status](https://travis-ci.org/apolukhin/magic_get.svg?branch=master)](https://travis-ci.org/apolukhin/magic_get) [![Build status](https://ci.appveyor.com/api/projects/status/3tled9gd24k9paia/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/magic-get/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=master)](https://coveralls.io/github/apolukhin/magic_get?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/pfr.html)
Develop: | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/0mavmnkdmltcdmqa/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/pfr/branch/develop) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=develop)](https://coveralls.io/github/apolukhin/magic_get?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/pfr.html)
Master: | [![CI](https://github.com/boostorg/pfr/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/pfr/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/0mavmnkdmltcdmqa/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/pfr/branch/master) | [![Coverage Status](https://coveralls.io/repos/github/apolukhin/magic_get/badge.png?branch=master)](https://coveralls.io/github/apolukhin/magic_get?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/pfr.html)
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/boost_pfr.html)

View File

@@ -55,10 +55,10 @@ user_info retrieve_friend(std::string_view name) {
db::insert(
"INSERT INTO user_infos(id, name, email, login) VALUES ($0, $1, $2, $3)",
std::move(friend_info.id), //////////////////////////////////////////////
std::move(friend_info.name), // Users are forced to move individual fields
std::move(friend_info.email), // because your library can not iterate over
std::move(friend_info.login) // the fields of a user provided structure
friend_info.id, /////////////////////////////////////////////////////////
friend_info.name, // Users are forced to enumerate fields because your
friend_info.email, // library can not iterate over the fields of a user
friend_info.login // provided structure
);
return friend_info;
@@ -94,8 +94,8 @@ user_info retrieve_friend(std::string_view name) {
db::insert(
"INSERT INTO user_infos(id, name, email, login) VALUES ($0, $1, $2, $3)",
friend_info ////////////////////////////////////////////////////////////
// Boost.PFR allows you to iterate over all the fields of a
// user provided structure
// Boost.PFR allows you to iterate over all the fields
// of a user provided structure
//
);
@@ -169,7 +169,7 @@ Boost.PFR adds the following out-of-the-box functionality for aggregate initiali
* methods for cooperation with `std::tuple`
* methods to visit each field of the structure
Boost.PFR is a header only library that does not depend on Boost. You can just copy the content of the "include" folder [@https://github.com/boostorg/pfr from the github] into your project, and the library will work fine.
Boost.PFR is a header only library that does not depend on Boost. You can just copy the content of the "include" folder [@https://github.com/boostorg/pfr from the Boost.PFR github] into your project, and the library will work fine. For a version of the library without `boost::` namespace see [@https://github.com/apolukhin/pfr_non_boost PFR].
[caution Recommended C++ Standards are C++17 and above. Library requires at least C++14! Pre C++14 compilers (C++11, C++03...) are not supported]

View File

@@ -295,7 +295,13 @@ constexpr std::size_t fields_count() noexcept {
// );
//#endif
#if defined(_MSC_VER) && (_MSC_VER <= 1920)
// Workaround for msvc compilers. Versions <= 1920 have a limit of max 1024 elements in template parameter pack
constexpr std::size_t max_fields_count = (sizeof(type) * CHAR_BIT >= 1024 ? 1024 : sizeof(type) * CHAR_BIT);
#else
constexpr std::size_t max_fields_count = (sizeof(type) * CHAR_BIT); // We multiply by CHAR_BIT because the type may have bitfields in T
#endif
constexpr std::size_t result = detail::detect_fields_count_dispatch<type>(size_t_<max_fields_count>{}, 1L, 1L);
detail::assert_first_not_base<type>(detail::make_index_sequence<result>{});

View File

@@ -31,7 +31,7 @@ void for_each_field_impl_apply(T&& v, F&& f, I /*i*/, int) {
template <class T, class F, std::size_t... I>
void for_each_field_impl(T& t, F&& f, std::index_sequence<I...>, std::false_type /*move_values*/) {
const int v[] = {(
const int v[] = {0, (
detail::for_each_field_impl_apply(sequence_tuple::get<I>(t), std::forward<F>(f), size_t_<I>{}, 1L),
0
)...};
@@ -41,7 +41,7 @@ void for_each_field_impl(T& t, F&& f, std::index_sequence<I...>, std::false_type
template <class T, class F, std::size_t... I>
void for_each_field_impl(T& t, F&& f, std::index_sequence<I...>, std::true_type /*move_values*/) {
const int v[] = {(
const int v[] = {0, (
detail::for_each_field_impl_apply(sequence_tuple::get<I>(std::move(t)), std::forward<F>(f), size_t_<I>{}, 1L),
0
)...};

View File

@@ -12,6 +12,7 @@
#include <type_traits>
#include <utility>
#include <memory> // std::addressof
#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/rvalue_t.hpp>
#include <boost/pfr/detail/size_t_.hpp>

View File

@@ -39,6 +39,6 @@ struct tie_from_structure_tuple : std::tuple<Elements&...> {
}
};
}}} // boost::pfr::detail
}}} // namespace boost::pfr::detail
#endif // BOOST_PFR_DETAIL_TIE_FROM_STRUCTURE_TUPLE_HPP

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python
# Copyright (c) 2016-2020 Antony Polukhin
# Copyright (c) 2016-2021 Antony Polukhin
#
# 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)

64
misc/strip_boost_namespace.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Copyright (c) 2021 Antony Polukhin
#
# 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)
echo "***** Making target path"
TARGET_PATH="`dirname \"$0\"`/../../pfr_non_boost"
rm -rf ${TARGET_PATH}/*
mkdir -p ${TARGET_PATH}
TARGET_PATH=`cd "${TARGET_PATH}";pwd`
SOURCE_PATH="`dirname \"$0\"`/.."
SOURCE_PATH=`cd "${SOURCE_PATH}";pwd`
echo "***** Copying from ${SOURCE_PATH} to ${TARGET_PATH}"
cp -rf ${SOURCE_PATH}/* ${TARGET_PATH}
mv ${TARGET_PATH}/include/boost/* ${TARGET_PATH}/include/
rm -rf ${TARGET_PATH}/include/boost
rm -rf ${TARGET_PATH}/test
rm ${TARGET_PATH}/misc/strip_boost_namespace.sh
rm -rf ${TARGET_PATH}/meta
echo "***** Changing sources"
find ${TARGET_PATH} -type f | xargs sed -i 's|namespace boost { ||g'
find ${TARGET_PATH} -type f | xargs sed -i 's|namespace boost {||g'
find ${TARGET_PATH} -type f | xargs sed -i 's|} // namespace boost::| // namespace |g'
find ${TARGET_PATH} -type f | xargs sed -i 's/::boost::pfr/::pfr/g'
find ${TARGET_PATH} -type f | xargs sed -i 's/boost::pfr/pfr/g'
find ${TARGET_PATH} -type f | xargs sed -i 's/BOOST_PFR_/PFR_/g'
find ${TARGET_PATH} -type f | xargs sed -i 's|boost/pfr|pfr|g'
find ${TARGET_PATH}/doc -type f | xargs sed -i 's|boost.pfr.|pfr.|g'
find ${TARGET_PATH}/doc -type f | xargs sed -i 's|Boost.PFR|PFR|g'
sed -i 's|# \[Boost.PFR\](https://boost.org/libs/pfr)|# [PFR](https://apolukhin.github.io/pfr_non_boost/)|g' ${TARGET_PATH}/README.md
echo -n "***** Testing: "
if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=0 -DPFR_USE_CPP17=1 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/motivating_example0.cpp && ./a.out > /dev/null; then
echo -n "OK"
else
echo -n "FAIL"
exit 2
fi
if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=1 -DPFR_USE_CPP17=0 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/motivating_example0.cpp && ./a.out > /dev/null; then
echo -n ", OK"
else
echo -n ", FAIL"
exit 3
fi
if g++-9 -std=c++17 -DPFR_USE_LOOPHOLE=0 -DPFR_USE_CPP17=0 -I ${TARGET_PATH}/include/ ${TARGET_PATH}/example/get.cpp && ./a.out > /dev/null; then
echo -e ", OK"
else
echo -e ", FAIL"
exit 4
fi
rm a.out || :
echo "***** Done"

View File

@@ -54,6 +54,8 @@ struct simple {
short d;
};
struct empty{};
int main () {
std::size_t control = 0;
@@ -108,6 +110,13 @@ int main () {
ss << val << ' ';
});
BOOST_TEST_EQ("42 a 3 ", ss.str());
ss.str("");
boost::pfr::for_each_field(empty{}, [&ss](auto&& val) {
ss << val << ' ';
});
BOOST_TEST_EQ("", ss.str());
ss.str("");
return boost::report_errors();
}

View File

@@ -12,5 +12,8 @@ int main() {
struct with_reference { int& i; char data; };
static_assert(boost::pfr::tuple_size_v<with_reference> == 2, "");
struct empty {};
static_assert(boost::pfr::tuple_size_v<empty> == 0, "");
}