Compare commits

..

24 Commits

Author SHA1 Message Date
ec4f3b23c2 Merge branch 'master' into develop 2021-06-10 01:38:57 +03:00
ab9a627688 Update CMakeLists.txt 2021-06-10 00:49:34 +03:00
5a80dcdbf3 Merge pull request #19 from sdarwin/githubactions
GitHub Actions config
2021-03-05 07:09:48 +08:00
ceb4528e46 Add GitHub Actions config [ci skip] 2021-03-04 15:07:23 +00:00
c8c44605ed Merge pull request #18 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-22 08:00:10 +08:00
d4316fb288 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-21 16:24:54 -05:00
a4dff52f67 Merge branch 'develop' 2020-05-26 09:31:40 +08:00
cf820922ac Merge pull request #15 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74
2020-04-09 21:38:47 +08:00
c4addf9795 Corrected previous fix. 2020-04-08 17:48:25 -04:00
87ff02bf79 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-30 13:31:11 -04:00
9fd6a5e2c6 Merge pull request #11 from awulkiew/patch-1
Use class keyword in std::tuple_size and std::tuple_element specializations
2020-01-23 22:37:20 +08:00
ddaa127cee Merge pull request #13 from Romain-Geissler-1A/fix-deprecated-copy-warning
Fix -Wdeprecated-copy warning with gcc 9.
2020-01-23 22:36:37 +08:00
19f7cfdcdb [CMake] Generate cmake target that other libraries can use
... to express their dependency on boost tuple and get
usage requiremments, such as the include directory
2020-01-06 16:36:37 +02:00
504a70bd04 Merge pull request #14 from Lastique/patch-1
Fix narrowing conversion in tuple_manipulator constructor
2019-09-16 08:03:52 +08:00
72f2e7535e Fix narrowing conversion in tuple_manipulator ctor
This fixes unnecessary, possibly wrapping conversion of the character argument of tuple manipulators on tuple_manipulator construction. This should silence MSVC warning C4244:

  tuple_io.hpp(142,71): warning C4244:  'argument': conversion from 'const CharType' to 'const char', possible loss of data

Related to https://github.com/boostorg/filesystem/issues/118.
2019-09-15 15:41:29 +03:00
1e0276741b Fix -Wdeprecated-copy warning with gcc 9. 2019-04-17 21:13:33 +00:00
0b724234ce Merge pull request #12 from Mike-Devel/min_cmake
[CMake] Generate cmake target that other libraries can use
2018-12-24 07:25:52 +08:00
292f3f9dc8 [CMake] Generate cmake target that other libraries can use
... to express their dependency on boost tuple and get
usage requiremments, such as the include directory
2018-12-23 22:01:55 +01:00
30794afc61 Use class keyword in std::tuple_size and std::tuple_element specializations
To avoid warnings 'X defined as a struct template but previously declared as a class template'.
2018-01-06 12:40:55 +01:00
b8e982cd6f Merge pull request #10 from Kojoley/suppress-clang-mismatched-tags-warning
Suppress mismatched tags warning
2018-01-06 06:11:11 +08:00
37ef42e2c3 Suppress mismatched tags warning 2018-01-05 16:09:49 +03:00
327c1c4fe0 Merge pull request #8 from boostorg/feature/structured-bindings
Make boost::tuple tuple-like to support structured bindings
2018-01-04 07:10:48 +08:00
16731d2689 Make boost::tuple tuple-like to support structured bindings 2018-01-03 19:26:11 +02:00
c51d8a9495 Switch tests to lightweight_test 2018-01-03 18:41:14 +02:00
13 changed files with 579 additions and 46 deletions

271
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,271 @@
name: GitHub Actions CI
on:
pull_request:
push:
branches:
- master
- develop
- githubactions*
- feature/**
- fix/**
- pr/**
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 0"
buildtype: "boost"
packages: ""
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++"
cxxstd: "03,11"
- name: "TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 1"
buildtype: "boost"
packages: "g++-5"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-5"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-5"
cxxstd: "03,11,14,1z"
- name: "TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 2"
buildtype: "boost"
packages: "g++-6"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-6"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-6"
cxxstd: "03,11,14,1z"
- name: "TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 3"
buildtype: "boost"
packages: "g++-7"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "g++-7"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "gcc"
compiler: "g++-7"
cxxstd: "03,11,14,17"
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 4"
buildtype: "boost"
packages: ""
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11"
- name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 5"
buildtype: "boost"
packages: "clang-4.0"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-4.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "4.0"
toolset: "clang"
compiler: "clang++-4.0"
cxxstd: "03,11,14"
- name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 6"
buildtype: "boost"
packages: "clang-5.0"
packages_to_remove: ""
os: "ubuntu-16.04"
cxx: "clang++-5.0"
sources: ""
llvm_os: "xenial"
llvm_ver: "5.0"
toolset: "clang"
compiler: "clang++-5.0"
cxxstd: "03,11,14,1z"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Check if running in container
if: matrix.container != ''
run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: linux
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
COMPILER: ${{ matrix.compiler }}
CXXSTD: ${{ matrix.cxxstd }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "linux"
run: |
echo '==================================> SETUP'
echo '==================================> PACKAGES'
set -e
if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi
echo ">>>>> APT: REPO.."
for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done
if test -n "${LLVM_OS}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if test -n "${LLVM_VER}" ; then
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main"
else
# Snapshot (i.e. trunk) build of clang
sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main"
fi
fi
echo ">>>>> APT: UPDATE.."
sudo -E apt-get -o Acquire::Retries=3 update
if test -n "${SOURCES}" ; then
echo ">>>>> APT: INSTALL SOURCES.."
for SOURCE in $SOURCES; do
sudo -E apt-add-repository ppa:$SOURCE
done
fi
echo ">>>>> APT: INSTALL ${PACKAGES}.."
sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES}
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/build
git submodule update --init libs/config
git submodule update --init tools/boostdep
cp -r $TRAVIS_BUILD_DIR/* libs/tuple
python tools/boostdep/depinst/depinst.py tuple
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j 3 libs/tuple/test toolset=$TOOLSET cxxstd=$CXXSTD
fi
osx:
strategy:
fail-fast: false
matrix:
include:
- name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 7"
buildtype: "boost"
packages: ""
os: "macos-10.15"
cxx: "clang++"
sources: ""
llvm_os: ""
llvm_ver: ""
xcode_version: 11.7
toolset: "clang"
compiler: "clang++"
cxxstd: "03,11,14,1z"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set DEVELOPER_DIR
if: matrix.xcode_version != ''
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV
- name: Test DEVELOPER_DIR
run: echo $DEVELOPER_DIR
- name: "osx"
shell: bash
env:
CXX: ${{ matrix.cxx }}
SOURCES: ${{ matrix.sources }}
LLVM_OS: ${{ matrix.llvm_os }}
LLVM_VER: ${{ matrix.llvm_ver }}
PACKAGES: ${{ matrix.packages }}
JOB_BUILDTYPE: ${{ matrix.buildtype }}
TOOLSET: ${{ matrix.toolset }}
COMPILER: ${{ matrix.compiler }}
CXXSTD: ${{ matrix.cxxstd }}
TRAVIS_BRANCH: ${{ github.base_ref }}
TRAVIS_OS_NAME: "osx"
run: |
echo '==================================> SETUP'
set -e
sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck
echo '==================================> PACKAGES'
echo '==================================> INSTALL AND COMPILE'
set -e
export TRAVIS_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
export VCS_COMMIT_ID=$GITHUB_SHA
export GIT_COMMIT=$GITHUB_SHA
export REPO_NAME=$(basename $GITHUB_REPOSITORY)
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
if [ "$JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/build
git submodule update --init libs/config
git submodule update --init tools/boostdep
cp -r $TRAVIS_BUILD_DIR/* libs/tuple
python tools/boostdep/depinst/depinst.py tuple
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j 3 libs/tuple/test toolset=$TOOLSET cxxstd=$CXXSTD
fi

19
CMakeLists.txt Normal file
View File

@ -0,0 +1,19 @@
# Copyright 2018 Mike Dev
# 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
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_tuple VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_tuple INTERFACE)
add_library(Boost::tuple ALIAS boost_tuple)
target_include_directories(boost_tuple INTERFACE include)
target_link_libraries(boost_tuple
INTERFACE
Boost::config
Boost::core
Boost::static_assert
Boost::type_traits
)

View File

@ -37,6 +37,7 @@
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/utility/swap.hpp>
#include <boost/detail/workaround.hpp> // needed for BOOST_WORKAROUND
@ -140,7 +141,7 @@ private:
typedef BOOST_DEDUCED_TYPENAME detail::drop_front<N>::BOOST_NESTED_TEMPLATE
apply<T>::type::head_type unqualified_type;
public:
#if BOOST_WORKAROUND(__BORLANDC__,<0x600)
#if BOOST_WORKAROUND(BOOST_BORLANDC,<0x600)
typedef const unqualified_type type;
#else
typedef BOOST_DEDUCED_TYPENAME boost::add_const<unqualified_type>::type type;
@ -309,6 +310,7 @@ struct cons {
tail (t2, t3, t4, t5, t6, t7, t8, t9, t10, detail::cnull())
{}
cons( const cons& u ) : head(u.head), tail(u.tail) {}
template <class HT2, class TT2>
cons( const cons<HT2, TT2>& u ) : head(u.head), tail(u.tail) {}
@ -388,6 +390,8 @@ struct cons<HT, null_type> {
const null_type&, const null_type&, const null_type&)
: head () {}
cons( const cons& u ) : head(u.head) {}
template <class HT2>
cons( const cons<HT2, null_type>& u ) : head(u.head) {}
@ -420,28 +424,28 @@ struct cons<HT, null_type> {
// templates for finding out the length of the tuple -------------------
template<class T>
struct length {
BOOST_STATIC_CONSTANT(int, value = 1 + length<typename T::tail_type>::value);
struct length: boost::integral_constant<int, 1 + length<typename T::tail_type>::value>
{
};
template<>
struct length<tuple<> > {
BOOST_STATIC_CONSTANT(int, value = 0);
struct length<tuple<> >: boost::integral_constant<int, 0>
{
};
template<>
struct length<tuple<> const> {
BOOST_STATIC_CONSTANT(int, value = 0);
struct length<tuple<> const>: boost::integral_constant<int, 0>
{
};
template<>
struct length<null_type> {
BOOST_STATIC_CONSTANT(int, value = 0);
struct length<null_type>: boost::integral_constant<int, 0>
{
};
template<>
struct length<null_type const> {
BOOST_STATIC_CONSTANT(int, value = 0);
struct length<null_type const>: boost::integral_constant<int, 0>
{
};
namespace detail {

View File

@ -63,5 +63,56 @@ get(const tuples::cons<HT, TT>& c) {
} // end namespace boost
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
#include <tuple>
#include <cstddef>
namespace std
{
#if defined(BOOST_CLANG)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
// std::tuple_size
template<class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10>
class tuple_size< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >:
public boost::tuples::length< boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
{
};
template<class H, class T> class tuple_size< boost::tuples::cons<H, T> >:
public boost::tuples::length< boost::tuples::cons<H, T> >
{
};
template<> class tuple_size< boost::tuples::null_type >:
public boost::tuples::length< boost::tuples::null_type >
{
};
// std::tuple_element
template<std::size_t I, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10>
class tuple_element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >:
public boost::tuples::element< I, boost::tuples::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
{
};
template<std::size_t I, class H, class T> class tuple_element< I, boost::tuples::cons<H, T> >:
public boost::tuples::element< I, boost::tuples::cons<H, T> >
{
};
#if defined(BOOST_CLANG)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // !defined(BOOST_NO_CXX11_HDR_TUPLE)
#endif // BOOST_TUPLE_HPP

View File

@ -102,7 +102,7 @@ class tuple_manipulator {
CharType f_c;
public:
explicit tuple_manipulator(detail::format_info::manipulator_type m,
const char c = 0)
CharType c = CharType())
: mt(m), f_c(c) {}
template<class CharTrait>
@ -259,7 +259,7 @@ extract_and_check_delimiter(
#if defined (BOOST_NO_STD_LOCALE)
const bool is_delimiter = !isspace(d);
#elif defined ( __BORLANDC__ )
#elif defined ( BOOST_BORLANDC )
const bool is_delimiter = !std::use_facet< std::ctype< CharType > >
(is.getloc() ).is( std::ctype_base::space, d);
#else

View File

@ -13,5 +13,6 @@
],
"maintainers": [
"Jaakko Jarvi <jarvi -at- cs.tamu.edu>"
]
],
"cxxstd": "03"
}

View File

@ -1,8 +1,11 @@
project : requirements <library>/boost/test//boost_test_exec_monitor ;
# Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
# Distributed under the Boost Software License, Version 1.0.
test-suite tuple :
[ run tuple_test_bench.cpp ]
[ run io_test.cpp ]
[ run another_tuple_test_bench.cpp ]
;
[ run std_tuple_size.cpp ]
[ run std_tuple_element.cpp ]
[ run structured_bindings.cpp ]
;

View File

@ -15,11 +15,10 @@
// Defining any of E1 to E5 or E7 to E11 opens some illegal code that
// should cause the compliation to fail.
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
#include <boost/test/test_tools.hpp> // see "Header Implementation Option"
#include "boost/tuple/tuple.hpp"
#include "boost/core/lightweight_test.hpp"
#include <string>
#include <utility>
@ -149,7 +148,7 @@ void foo7() {
// --------------------------------
// ----------------------------
int test_main(int, char *[]) {
int main() {
foo1();
foo2();
@ -159,5 +158,5 @@ int test_main(int, char *[]) {
foo7();
return 0;
return boost::report_errors();
}

View File

@ -10,12 +10,11 @@
//
// Testing the I/O facilities of tuples
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
#include "boost/test/test_tools.hpp" // see "Header Implementation Option"
#include "boost/tuple/tuple_io.hpp"
#include "boost/tuple/tuple_comparison.hpp"
#include "boost/core/lightweight_test.hpp"
#include <fstream>
#include <iterator>
#include <algorithm>
@ -28,6 +27,8 @@
#include <sstream>
#endif
#define BOOST_CHECK BOOST_TEST
using namespace boost;
#if defined BOOST_NO_STRINGSTREAM
@ -38,9 +39,7 @@ typedef std::ostringstream useThisOStringStream;
typedef std::istringstream useThisIStringStream;
#endif
int test_main(int argc, char * argv[] ) {
(void)argc;
(void)argv;
int main() {
using boost::tuples::set_close;
using boost::tuples::set_open;
using boost::tuples::set_delimiter;
@ -138,6 +137,5 @@ int test_main(int argc, char * argv[] ) {
// general. If this is wanted, some kind of a parseable string class
// should be used.
return 0;
return boost::report_errors();
}

View File

@ -0,0 +1,56 @@
// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/tuple/tuple.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_NO_CXX11_HDR_TUPLE)
BOOST_PRAGMA_MESSAGE("Skipping std::tuple_element tests for lack of <tuple>")
int main() {}
#else
#include <tuple>
template<class Tp, std::size_t I, class E> void test()
{
BOOST_TEST_TRAIT_TRUE((boost::is_same<typename std::tuple_element<I, Tp>::type, E>));
typedef typename Tp::inherited Tp2;
BOOST_TEST_TRAIT_TRUE((boost::is_same<typename std::tuple_element<I, Tp2>::type, E>));
}
template<int> struct X
{
};
int main()
{
test<boost::tuple<X<0> const>, 0, X<0> const>();
test<boost::tuple<X<0> const, X<1> const>, 0, X<0> const>();
test<boost::tuple<X<0> const, X<1> const>, 1, X<1> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const>, 0, X<0> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const>, 1, X<1> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const>, 2, X<2> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const>, 0, X<0> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const>, 1, X<1> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const>, 2, X<2> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const>, 3, X<3> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const, X<4> const>, 0, X<0> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const, X<4> const>, 1, X<1> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const, X<4> const>, 2, X<2> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const, X<4> const>, 3, X<3> const>();
test<boost::tuple<X<0> const, X<1> const, X<2> const, X<3> const, X<4> const>, 4, X<4> const>();
return boost::report_errors();
}
#endif

61
test/std_tuple_size.cpp Normal file
View File

@ -0,0 +1,61 @@
// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/tuple/tuple.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_NO_CXX11_HDR_TUPLE)
BOOST_PRAGMA_MESSAGE("Skipping std::tuple_size tests for lack of <tuple>")
int main() {}
#else
#include <tuple>
template<class Tp> void test( std::size_t x )
{
BOOST_TEST_EQ( std::tuple_size< Tp >::value, x );
BOOST_TEST_EQ( std::tuple_size< typename Tp::inherited >::value, x );
}
struct V
{
};
int main()
{
test< boost::tuple<> >( 0 );
test< boost::tuple<V> >( 1 );
test< boost::tuple<V, V> >( 2 );
test< boost::tuple<V, V, V> >( 3 );
test< boost::tuple<V, V, V, V> >( 4 );
test< boost::tuple<V, V, V, V, V> >( 5 );
test< boost::tuple<V, V, V, V, V, V> >( 6 );
test< boost::tuple<V, V, V, V, V, V, V> >( 7 );
test< boost::tuple<V, V, V, V, V, V, V, V> >( 8 );
test< boost::tuple<V, V, V, V, V, V, V, V, V> >( 9 );
test< boost::tuple<V, V, V, V, V, V, V, V, V, V> >( 10 );
#if !defined(BOOST_NO_CXX11_DECLTYPE)
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple())>::value, 0 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1))>::value, 1 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2))>::value, 2 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3))>::value, 3 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4))>::value, 4 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5))>::value, 5 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6))>::value, 6 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7))>::value, 7 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8))>::value, 8 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8, 9))>::value, 9 );
BOOST_TEST_EQ( std::tuple_size<decltype(boost::make_tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))>::value, 10 );
#endif
return boost::report_errors();
}
#endif

View File

@ -0,0 +1,77 @@
// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/tuple/tuple.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_NO_CXX17_STRUCTURED_BINDINGS)
BOOST_PRAGMA_MESSAGE("Skipping structured bindings test, not supported")
int main() {}
#else
int main()
{
// make_tuple
{
auto [x1] = boost::make_tuple( 1 );
BOOST_TEST_EQ( x1, 1 );
}
{
auto [x1, x2] = boost::make_tuple( 1, 2 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
}
{
auto [x1, x2, x3] = boost::make_tuple( 1, 2, 3 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
BOOST_TEST_EQ( x3, 3 );
}
{
auto [x1, x2, x3, x4] = boost::make_tuple( 1, 2, 3, 4 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
BOOST_TEST_EQ( x3, 3 );
BOOST_TEST_EQ( x4, 4 );
}
// tuple
{
auto [x1] = boost::tuple<int>( 1 );
BOOST_TEST_EQ( x1, 1 );
}
{
auto [x1, x2] = boost::tuple<int, int>( 1, 2 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
}
{
auto [x1, x2, x3] = boost::tuple<int, int, int>( 1, 2, 3 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
BOOST_TEST_EQ( x3, 3 );
}
{
auto [x1, x2, x3, x4] = boost::tuple<int, int, int, int>( 1, 2, 3, 4 );
BOOST_TEST_EQ( x1, 1 );
BOOST_TEST_EQ( x2, 2 );
BOOST_TEST_EQ( x3, 3 );
BOOST_TEST_EQ( x4, 4 );
}
return boost::report_errors();
}
#endif

View File

@ -8,19 +8,18 @@
// tuple_test_bench.cpp --------------------------------
#define BOOST_INCLUDE_MAIN // for testing, include rather than link
#include <boost/test/test_tools.hpp> // see "Header Implementation Option"
#include "boost/tuple/tuple.hpp"
#include "boost/tuple/tuple_comparison.hpp"
#include "boost/type_traits/is_const.hpp"
#include "boost/ref.hpp"
#include "boost/core/lightweight_test.hpp"
#include <string>
#include <utility>
#define BOOST_CHECK BOOST_TEST
using namespace boost;
// ----------------------------------------------------------------------------
@ -82,7 +81,7 @@ typedef tuple<std::string, std::pair<A, B> > t4;
typedef tuple<A*, tuple<const A*, const B&, C>, bool, void*> t5;
typedef tuple<volatile int, const volatile char&, int(&)(float) > t6;
# if !defined(__BORLANDC__) || __BORLAND__ > 0x0551
# if !defined(BOOST_BORLANDC) || BOOST_BORLANDC > 0x0551
typedef tuple<B(A::*)(C&), A&> t7;
#endif
@ -307,7 +306,7 @@ make_tuple_test()
// With function pointers, make_tuple works just fine
#if !defined(__BORLANDC__) || __BORLAND__ > 0x0551
#if !defined(BOOST_BORLANDC) || BOOST_BORLANDC > 0x0551
make_tuple(&make_tuple_test);
#endif
@ -472,7 +471,7 @@ void tuple_swap_test()
// - main ---------------------------------------------------------------------
// ----------------------------------------------------------------------------
int test_main(int, char *[]) {
int main() {
construction_test();
element_access_test();
@ -486,12 +485,6 @@ int test_main(int, char *[]) {
const_tuple_test();
tuple_length_test();
tuple_swap_test();
return 0;
return boost::report_errors();
}