mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Merge branch 'develop'
- Various CI improvements, including appveyor support - Stop using boost::next in tests, because of warnings - Use std::iterator_traits, to drop dependency on iterator - Use std::piecewise_construct from dinukumware/Visual C++ - Template deduction guides, just copied from the standard, they don't work that well. I think some other implementations enhance them - Some internal changes - Stop inheriting from std::iterator, deprecated in C++17 (#7) - Implement allocator_traits::is_always_equal - Rewrite node handles using a simple class based on std::optional, so that it's closer to the standard - noexcept support for swap, operator= - Fix some compiler warnings - Fix some of the tests on Visual C++ 7.1 - Add element_type to iterators, so that pointer_traits will work - Use boost::to_address internally, instead of own custom implementation - Stop using BOOST_DEDUCED_TYPENAME - it's for very old compilers that are no longer supported, and makes the code look ugly
This commit is contained in:
32
.appveyor.yml
Normal file
32
.appveyor.yml
Normal file
@ -0,0 +1,32 @@
|
||||
# Copyright 2017 Daniel James
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
|
||||
install:
|
||||
- set BOOST_ROOT=c:\projects\boost
|
||||
- cd c:\projects\
|
||||
- python %APPVEYOR_BUILD_FOLDER%\build\download-boost-snapshot.py master
|
||||
- rd /s /q %BOOST_ROOT%\boost\unordered
|
||||
- cd %BOOST_ROOT%\tools\build
|
||||
- cmd /c bootstrap
|
||||
- cd %APPVEYOR_BUILD_FOLDER%
|
||||
- echo. 2>Jamroot.jam
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test
|
||||
- cmd /c %BOOST_ROOT%\tools\build\b2 -j 3 toolset=%TOOLSET% include=%APPVEYOR_BUILD_FOLDER%\include include=%BOOST_ROOT%
|
57
.travis.yml
57
.travis.yml
@ -11,7 +11,6 @@ language: c++
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libboost-tools-dev
|
||||
- libxml2-utils
|
||||
- g++-multilib
|
||||
|
||||
@ -19,46 +18,70 @@ matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
env: |
|
||||
label="gcc C++03";
|
||||
user_config="using gcc : : g++-4.8 --coverage -fsanitize=address -Werror --std=c++03 ;"
|
||||
enable_coverage=1
|
||||
- compiler: gcc
|
||||
env: |
|
||||
label="gcc C++11";
|
||||
user_config="using gcc : : g++-4.8 --coverage -fsanitize=address -Werror --std=c++11 ;"
|
||||
label="gcc C++03/11";
|
||||
user_config="using gcc : : g++-4.8 --coverage -fsanitize=address -Werror ;"
|
||||
enable_coverage=1
|
||||
CXXSTD=03,11
|
||||
- compiler: gcc
|
||||
env: |
|
||||
label="gcc 32 bit C++11";
|
||||
user_config="using gcc : : g++-4.8 -m32 -fsanitize=address -Werror --std=c++11 ;"
|
||||
user_config="using gcc : : g++-4.8 -m32 -fsanitize=address -Werror ;"
|
||||
CXXSTD=11
|
||||
- compiler: clang
|
||||
env: |
|
||||
label="clang C++11";
|
||||
user_config="using clang : : clang++ -fsanitize=address -Werror --std=c++11 ;"
|
||||
label="clang C++11/17";
|
||||
user_config="using clang : : clang++ -fsanitize=address -Werror ;"
|
||||
CXXSTD=11,17
|
||||
# sanitized=address not available for 32-bit clang on travis.
|
||||
- compiler: clang
|
||||
env: |
|
||||
label="clang 32 bit";
|
||||
user_config="using clang : : clang++ -m32 -Werror --std=c++03 ;"
|
||||
user_config="using clang : : clang++ -m32 -Werror ;"
|
||||
CXXSTD=03
|
||||
|
||||
before_install:
|
||||
- if [ -n $enable_coverage ]; then pip install --user cpp-coveralls; fi
|
||||
|
||||
before_script:
|
||||
- export BOOST_VERSION=1.66.0
|
||||
- export BOOST_FILENAME=boost_1_66_0
|
||||
- export BOOST_ROOT=${HOME}/boost
|
||||
- cd ${TRAVIS_BUILD_DIR}
|
||||
- touch Jamroot.jam
|
||||
- cd $HOME
|
||||
- echo $user_config > ~/user-config.jam
|
||||
- cat ~/user-config.jam
|
||||
- wget -O boost.tar.bz2 https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2
|
||||
- tar -xjf boost.tar.bz2
|
||||
- mv boost_1_64_0 boost
|
||||
- rm -r boost/boost/unordered
|
||||
- |
|
||||
# Pick snapshot to use
|
||||
if [ "$TRAVIS_EVENT_TYPE" == "cron" ]
|
||||
then
|
||||
if [ "$TRAVIS_BRANCH" == "master" ]
|
||||
then
|
||||
snapshot=master
|
||||
else
|
||||
snapshot=develop
|
||||
fi
|
||||
else
|
||||
#snapshot=stable
|
||||
snapshot=master
|
||||
fi
|
||||
|
||||
# Download and extract snapshot
|
||||
echo "Downloading ${download_url}"
|
||||
mkdir $HOME/download
|
||||
cd $HOME/download
|
||||
python ${TRAVIS_BUILD_DIR}/build/download-boost-snapshot.py $snapshot
|
||||
mv * ${BOOST_ROOT}
|
||||
- rm -r ${BOOST_ROOT}/boost/unordered
|
||||
- cd ${BOOST_ROOT}/tools/build
|
||||
- mkdir ${HOME}/opt
|
||||
- bash bootstrap.sh
|
||||
- ./b2 install --prefix=$HOME/opt
|
||||
|
||||
after_success:
|
||||
if [ -n $enable_coverage ]; then coveralls -r ${TRAVIS_BUILD_DIR} -b ${TRAVIS_BUILD_DIR}/test --gcov-options '\-lp' --include include/boost/unordered/ ; fi
|
||||
|
||||
script:
|
||||
- cd ${TRAVIS_BUILD_DIR}/test
|
||||
- bjam -q include=${HOME}/boost include=${TRAVIS_BUILD_DIR}/include
|
||||
- ${HOME}/opt/bin/b2 -j 3 cxxstd=$CXXSTD -q include=${BOOST_ROOT} include=${TRAVIS_BUILD_DIR}/include
|
||||
- xmllint --noout ${TRAVIS_BUILD_DIR}/doc/ref.xml
|
||||
|
66
build/download-boost-snapshot.py
Normal file
66
build/download-boost-snapshot.py
Normal file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import urllib, os, os.path, sys, json, tarfile, zipfile, tempfile
|
||||
|
||||
def download(snapshot):
|
||||
if snapshot == 'stable':
|
||||
# TODO: Default version/filename if not available?
|
||||
downloads = [
|
||||
"https://sourceforge.net/projects/boost/files/boost/%s/%s.tar.bz2/download" %
|
||||
(os.environ['BOOST_VERSION'], os.environ['BOOST_FILENAME'])]
|
||||
else:
|
||||
json_response = urllib.urlopen('https://api.bintray.com/packages/boostorg/%s/snapshot/files' % (snapshot))
|
||||
x = json.load(json_response)
|
||||
|
||||
extension_priorities = { '.bz2': 2, '.gz': 1, '.zip': 0 }
|
||||
file_list = []
|
||||
version_dates = {}
|
||||
for file in x:
|
||||
file_extension = os.path.splitext(file['path'])[1]
|
||||
if (file_extension in extension_priorities):
|
||||
file['priority'] = extension_priorities[file_extension]
|
||||
file_list.append(file)
|
||||
if not file['version'] in version_dates or file['created'] < version_dates[file['version']]:
|
||||
version_dates[file['version']] = file['created']
|
||||
file_list.sort(key=lambda x: (version_dates[x['version']], x['priority']), reverse=True)
|
||||
downloads = ['http://dl.bintray.com/boostorg/%s/%s' % (snapshot, file['path']) for file in file_list]
|
||||
|
||||
filename = ''
|
||||
for download_url in downloads:
|
||||
try:
|
||||
print "Downloading: " + download_url
|
||||
(filename, headers) = urllib.urlretrieve(download_url)
|
||||
|
||||
print "Extracting: " + filename
|
||||
dir = tempfile.mkdtemp()
|
||||
extract(filename, dir)
|
||||
os.remove(filename)
|
||||
files = os.listdir(dir)
|
||||
assert(len(files) == 1)
|
||||
os.rename(os.path.join(dir, files[0]), 'boost')
|
||||
return
|
||||
except IOError:
|
||||
print "Error opening URL: " + download_url
|
||||
|
||||
def extract(filename, path = '.'):
|
||||
if (filename.endswith(".gz")):
|
||||
tar = tarfile.open(filename, "r:gz")
|
||||
tar.extractall(path)
|
||||
tar.close
|
||||
elif (filename.endswith(".bz2")):
|
||||
tar = tarfile.open(filename, "r:bz2")
|
||||
tar.extractall(path)
|
||||
tar.close
|
||||
elif (filename.endswith(".zip")):
|
||||
zip = zipfile.ZipFile(filename, "r")
|
||||
zip.extractall(path)
|
||||
zip.close
|
||||
else:
|
||||
assert False
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
download('stable')
|
||||
elif len(sys.argv) == 2:
|
||||
download(sys.argv[1])
|
||||
else:
|
||||
print "Usage: %s [stable|branch-name]" % (sys.argv[0])
|
@ -4,7 +4,7 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include "../../examples/fnv1.hpp"
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//[point_example1
|
||||
struct point {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
//[point_example2
|
||||
struct point {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "./case_insensitive.hpp"
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
struct word_info {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/predef.h>
|
||||
|
||||
#if defined(BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT)
|
||||
// Already defined.
|
||||
#elif defined(BOOST_LIBSTDCXX11)
|
||||
@ -18,16 +20,19 @@
|
||||
#if BOOST_LIBSTDCXX_VERSION > 40600
|
||||
#define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1
|
||||
#endif
|
||||
#elif defined(_LIBCPP_VERSION)
|
||||
#elif BOOST_LIB_STD_CXX
|
||||
// https://github.com/llvm-mirror/libcxx/blob/release_30/include/utility#L206
|
||||
#if _LIBCPP_VERSION >= 3000
|
||||
#if BOOST_LIB_STD_CXX >= BOOST_VERSION_NUMBER(3, 0, 0)
|
||||
#define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1
|
||||
#endif
|
||||
#elif defined(BOOST_MSVC)
|
||||
#elif defined(BOOST_LIB_STD_DINKUMWARE)
|
||||
// Apparently C++11 standard supported in Visual Studio 2012
|
||||
// https://msdn.microsoft.com/en-us/library/hh567368.aspx#stl
|
||||
// 2012 = VC+11 = BOOST_MSVC 1700 Hopefully!
|
||||
#if BOOST_MSVC >= 1700
|
||||
// I have no idea when Dinkumware added it, probably a lot
|
||||
// earlier than this check.
|
||||
#if BOOST_LIB_STD_DINKUMWARE >= BOOST_VERSION_NUMBER(6, 50, 0) || \
|
||||
BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(17, 0, 0)
|
||||
#define BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT 1
|
||||
#endif
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,10 +26,12 @@
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
// conditional expression is constant
|
||||
#pragma warning(disable : 4127)
|
||||
#if BOOST_MSVC >= 1400
|
||||
#pragma warning(disable : 4396) // the inline specifier cannot be used when a
|
||||
// friend declaration refers to a specialization
|
||||
// of a function template
|
||||
// the inline specifier cannot be used when a friend declaration refers to a
|
||||
// specialization of a function template
|
||||
#pragma warning(disable : 4396)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -151,10 +153,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_map& operator=(BOOST_RV_REF(unordered_map) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@ -168,10 +169,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_map& operator=(unordered_map&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@ -715,11 +715,10 @@ namespace boost {
|
||||
BOOST_UNORDERED_DEPRECATED("Use erase instead")
|
||||
void erase_return_void(const_iterator it) { erase(it); }
|
||||
|
||||
void swap(unordered_map&);
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
void swap(unordered_map&)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value);
|
||||
void clear() BOOST_NOEXCEPT { table_.clear_impl(); }
|
||||
|
||||
template <typename H2, typename P2>
|
||||
@ -831,6 +830,81 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_map
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
using iter_key_t =
|
||||
typename std::iterator_traits<T>::value_type::first_type;
|
||||
template <typename T>
|
||||
using iter_val_t =
|
||||
typename std::iterator_traits<T>::value_type::second_type;
|
||||
template <typename T>
|
||||
using iter_to_alloc_t =
|
||||
typename std::pair<iter_key_t<T> const, iter_val_t<T> >;
|
||||
}
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Pred =
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Allocator = std::allocator<
|
||||
boost::unordered::detail::iter_to_alloc_t<InputIterator> > >
|
||||
unordered_map(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash = boost::hash<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_map<Key, T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_map(
|
||||
std::initializer_list<std::pair<const Key, T> >, std::size_t, Allocator)
|
||||
->unordered_map<Key, T, boost::hash<Key>, std::equal_to<Key>, Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >, Allocator)
|
||||
->unordered_map<Key, T, boost::hash<Key>, std::equal_to<Key>, Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash, class Allocator>
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >, std::size_t,
|
||||
Hash, Allocator)
|
||||
->unordered_map<Key, T, Hash, std::equal_to<Key>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
class unordered_multimap
|
||||
{
|
||||
@ -949,10 +1023,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@ -966,10 +1039,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multimap& operator=(unordered_multimap&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@ -1252,11 +1324,10 @@ namespace boost {
|
||||
BOOST_UNORDERED_DEPRECATED("Use erase instead")
|
||||
void erase_return_void(const_iterator it) { erase(it); }
|
||||
|
||||
void swap(unordered_multimap&);
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
void swap(unordered_multimap&)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value);
|
||||
void clear() BOOST_NOEXCEPT { table_.clear_impl(); }
|
||||
|
||||
template <typename H2, typename P2>
|
||||
@ -1363,6 +1434,73 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_multimap
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Pred =
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Allocator = std::allocator<
|
||||
boost::unordered::detail::iter_to_alloc_t<InputIterator> > >
|
||||
unordered_multimap(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash = boost::hash<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
unordered_multimap(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multimap<Key, T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multimap(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multimap(InputIterator, InputIterator, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_multimap(
|
||||
InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_multimap(
|
||||
std::initializer_list<std::pair<const Key, T> >, std::size_t, Allocator)
|
||||
->unordered_multimap<Key, T, boost::hash<Key>, std::equal_to<Key>,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_multimap(
|
||||
std::initializer_list<std::pair<const Key, T> >, Allocator)
|
||||
->unordered_multimap<Key, T, boost::hash<Key>, std::equal_to<Key>,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash, class Allocator>
|
||||
unordered_multimap(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t, Hash, Allocator)
|
||||
->unordered_multimap<Key, T, Hash, std::equal_to<Key>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
@ -1598,10 +1736,9 @@ namespace boost {
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_map<K, T, H, P, A>::swap(unordered_map& other)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value)
|
||||
{
|
||||
table_.swap(other.table_);
|
||||
}
|
||||
@ -2075,10 +2212,9 @@ namespace boost {
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
void unordered_multimap<K, T, H, P, A>::swap(unordered_multimap& other)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value)
|
||||
{
|
||||
table_.swap(other.table_);
|
||||
}
|
||||
@ -2314,72 +2450,51 @@ namespace boost {
|
||||
|
||||
private:
|
||||
node_pointer ptr_;
|
||||
bool has_alloc_;
|
||||
boost::unordered::detail::value_base<value_allocator> alloc_;
|
||||
boost::unordered::detail::optional<value_allocator> alloc_;
|
||||
|
||||
node_handle_map(node_pointer ptr, allocator_type const& a)
|
||||
: ptr_(ptr), has_alloc_(false)
|
||||
: ptr_(ptr), alloc_(a)
|
||||
{
|
||||
if (ptr_) {
|
||||
new ((void*)&alloc_) value_allocator(a);
|
||||
has_alloc_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_CONSTEXPR node_handle_map() BOOST_NOEXCEPT : ptr_(),
|
||||
has_alloc_(false)
|
||||
{
|
||||
}
|
||||
BOOST_CONSTEXPR node_handle_map() BOOST_NOEXCEPT : ptr_(), alloc_() {}
|
||||
|
||||
~node_handle_map()
|
||||
{
|
||||
if (has_alloc_ && ptr_) {
|
||||
node_allocator node_alloc(alloc_.value());
|
||||
if (ptr_) {
|
||||
node_allocator node_alloc(*alloc_);
|
||||
boost::unordered::detail::node_tmp<node_allocator> tmp(
|
||||
ptr_, node_alloc);
|
||||
}
|
||||
if (has_alloc_) {
|
||||
alloc_.value_ptr()->~value_allocator();
|
||||
}
|
||||
}
|
||||
|
||||
node_handle_map(BOOST_RV_REF(node_handle_map) n) BOOST_NOEXCEPT
|
||||
: ptr_(n.ptr_),
|
||||
has_alloc_(false)
|
||||
alloc_(boost::move(n.alloc_))
|
||||
{
|
||||
if (n.has_alloc_) {
|
||||
new ((void*)&alloc_) value_allocator(boost::move(n.alloc_.value()));
|
||||
has_alloc_ = true;
|
||||
n.ptr_ = node_pointer();
|
||||
n.alloc_.value_ptr()->~value_allocator();
|
||||
n.has_alloc_ = false;
|
||||
}
|
||||
n.ptr_ = node_pointer();
|
||||
}
|
||||
|
||||
node_handle_map& operator=(BOOST_RV_REF(node_handle_map) n)
|
||||
{
|
||||
BOOST_ASSERT(!has_alloc_ ||
|
||||
BOOST_ASSERT(!alloc_.has_value() ||
|
||||
value_allocator_traits::
|
||||
propagate_on_container_move_assignment::value ||
|
||||
(n.has_alloc_ && alloc_.value() == n.alloc_.value()));
|
||||
(n.alloc_.has_value() && alloc_ == n.alloc_));
|
||||
|
||||
if (ptr_) {
|
||||
node_allocator node_alloc(alloc_.value());
|
||||
node_allocator node_alloc(*alloc_);
|
||||
boost::unordered::detail::node_tmp<node_allocator> tmp(
|
||||
ptr_, node_alloc);
|
||||
ptr_ = node_pointer();
|
||||
}
|
||||
|
||||
if (has_alloc_) {
|
||||
alloc_.value_ptr()->~value_allocator();
|
||||
has_alloc_ = false;
|
||||
if (!alloc_.has_value() ||
|
||||
value_allocator_traits::propagate_on_container_move_assignment::
|
||||
value) {
|
||||
alloc_ = boost::move(n.alloc_);
|
||||
}
|
||||
|
||||
if (!has_alloc_ && n.has_alloc_) {
|
||||
move_allocator(n);
|
||||
}
|
||||
|
||||
ptr_ = n.ptr_;
|
||||
n.ptr_ = node_pointer();
|
||||
|
||||
@ -2393,7 +2508,7 @@ namespace boost {
|
||||
|
||||
mapped_type& mapped() const { return ptr_->value().second; }
|
||||
|
||||
allocator_type get_allocator() const { return alloc_.value(); }
|
||||
allocator_type get_allocator() const { return *alloc_; }
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
|
||||
|
||||
@ -2402,38 +2517,19 @@ namespace boost {
|
||||
bool empty() const BOOST_NOEXCEPT { return ptr_ ? 0 : 1; }
|
||||
|
||||
void swap(node_handle_map& n) BOOST_NOEXCEPT_IF(
|
||||
value_allocator_traits::propagate_on_container_swap::value
|
||||
/* || value_allocator_traits::is_always_equal::value */)
|
||||
value_allocator_traits::propagate_on_container_swap::value ||
|
||||
value_allocator_traits::is_always_equal::value)
|
||||
{
|
||||
if (!has_alloc_) {
|
||||
if (n.has_alloc_) {
|
||||
move_allocator(n);
|
||||
}
|
||||
} else if (!n.has_alloc_) {
|
||||
n.move_allocator(*this);
|
||||
} else {
|
||||
swap_impl(
|
||||
n, boost::unordered::detail::integral_constant<bool,
|
||||
value_allocator_traits::propagate_on_container_swap::value>());
|
||||
BOOST_ASSERT(
|
||||
!alloc_.has_value() || !n.alloc_.has_value() ||
|
||||
value_allocator_traits::propagate_on_container_swap::value ||
|
||||
alloc_ == n.alloc_);
|
||||
if (value_allocator_traits::propagate_on_container_swap::value ||
|
||||
!alloc_.has_value() || !n.alloc_.has_value()) {
|
||||
boost::swap(alloc_, n.alloc_);
|
||||
}
|
||||
boost::swap(ptr_, n.ptr_);
|
||||
}
|
||||
|
||||
private:
|
||||
void move_allocator(node_handle_map& n)
|
||||
{
|
||||
new ((void*)&alloc_) value_allocator(boost::move(n.alloc_.value()));
|
||||
n.alloc_.value_ptr()->~value_allocator();
|
||||
has_alloc_ = true;
|
||||
n.has_alloc_ = false;
|
||||
}
|
||||
|
||||
void swap_impl(node_handle_map&, boost::unordered::detail::false_type) {}
|
||||
|
||||
void swap_impl(node_handle_map& n, boost::unordered::detail::true_type)
|
||||
{
|
||||
boost::swap(alloc_, n.alloc_);
|
||||
}
|
||||
};
|
||||
|
||||
template <class N, class K, class T, class A>
|
||||
|
@ -25,10 +25,12 @@
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
// conditional expression is constant
|
||||
#pragma warning(disable : 4127)
|
||||
#if BOOST_MSVC >= 1400
|
||||
#pragma warning(disable : 4396) // the inline specifier cannot be used when a
|
||||
// friend declaration refers to a specialization
|
||||
// of a function template
|
||||
// the inline specifier cannot be used when a friend declaration refers to a
|
||||
// specialization of a function template
|
||||
#pragma warning(disable : 4396)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -149,10 +151,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@ -166,10 +167,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_set& operator=(unordered_set&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::true_type());
|
||||
return *this;
|
||||
@ -441,11 +441,10 @@ namespace boost {
|
||||
BOOST_UNORDERED_DEPRECATED("Use erase instead")
|
||||
void erase_return_void(const_iterator it) { erase(it); }
|
||||
|
||||
void swap(unordered_set&);
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
void swap(unordered_set&)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value);
|
||||
void clear() BOOST_NOEXCEPT { table_.clear_impl(); }
|
||||
|
||||
template <typename H2, typename P2>
|
||||
@ -545,6 +544,52 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_set
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Pred =
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Allocator = std::allocator<
|
||||
typename std::iterator_traits<InputIterator>::value_type> >
|
||||
unordered_set(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
Hash, Pred, Allocator>;
|
||||
|
||||
template <class T, class Hash = boost::hash<T>,
|
||||
class Pred = std::equal_to<T>, class Allocator = std::allocator<T> >
|
||||
unordered_set(std::initializer_list<T>,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_set<T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_set(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_set(InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
Hash,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Allocator>
|
||||
unordered_set(std::initializer_list<T>, std::size_t, Allocator)
|
||||
->unordered_set<T, boost::hash<T>, std::equal_to<T>, Allocator>;
|
||||
|
||||
template <class T, class Hash, class Allocator>
|
||||
unordered_set(std::initializer_list<T>, std::size_t, Hash, Allocator)
|
||||
->unordered_set<T, Hash, std::equal_to<T>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
template <class T, class H, class P, class A> class unordered_multiset
|
||||
{
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
@ -661,10 +706,9 @@ namespace boost {
|
||||
}
|
||||
|
||||
unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@ -678,10 +722,9 @@ namespace boost {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
unordered_multiset& operator=(unordered_multiset&& x)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_move_assignable<H>::value&&
|
||||
boost::is_nothrow_move_assignable<P>::value)
|
||||
{
|
||||
table_.move_assign(x.table_, boost::unordered::detail::false_type());
|
||||
return *this;
|
||||
@ -945,11 +988,10 @@ namespace boost {
|
||||
BOOST_UNORDERED_DEPRECATED("Use erase instead")
|
||||
void erase_return_void(const_iterator it) { erase(it); }
|
||||
|
||||
void swap(unordered_multiset&);
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
void swap(unordered_multiset&)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value);
|
||||
void clear() BOOST_NOEXCEPT { table_.clear_impl(); }
|
||||
|
||||
template <typename H2, typename P2>
|
||||
@ -1049,6 +1091,55 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_multiset
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Pred =
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Allocator = std::allocator<
|
||||
typename std::iterator_traits<InputIterator>::value_type> >
|
||||
unordered_multiset(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Hash = boost::hash<T>,
|
||||
class Pred = std::equal_to<T>, class Allocator = std::allocator<T> >
|
||||
unordered_multiset(std::initializer_list<T>,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multiset<T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multiset(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type,
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_multiset(
|
||||
InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type, Hash,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Allocator>
|
||||
unordered_multiset(std::initializer_list<T>, std::size_t, Allocator)
|
||||
->unordered_multiset<T, boost::hash<T>, std::equal_to<T>, Allocator>;
|
||||
|
||||
template <class T, class Hash, class Allocator>
|
||||
unordered_multiset(std::initializer_list<T>, std::size_t, Hash, Allocator)
|
||||
->unordered_multiset<T, Hash, std::equal_to<T>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_set<T, H, P, A>::unordered_set()
|
||||
@ -1270,10 +1361,9 @@ namespace boost {
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_set<T, H, P, A>::swap(unordered_set& other)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value)
|
||||
{
|
||||
table_.swap(other.table_);
|
||||
}
|
||||
@ -1665,10 +1755,9 @@ namespace boost {
|
||||
|
||||
template <class T, class H, class P, class A>
|
||||
void unordered_multiset<T, H, P, A>::swap(unordered_multiset& other)
|
||||
// C++17 support: BOOST_NOEXCEPT_IF(
|
||||
// value_allocator_traits::is_always_equal::value &&
|
||||
// is_nothrow_move_assignable_v<H> &&
|
||||
// is_nothrow_move_assignable_v<P>)
|
||||
BOOST_NOEXCEPT_IF(value_allocator_traits::is_always_equal::value&&
|
||||
boost::is_nothrow_swappable<H>::value&&
|
||||
boost::is_nothrow_swappable<P>::value)
|
||||
{
|
||||
table_.swap(other.table_);
|
||||
}
|
||||
@ -1875,15 +1964,11 @@ namespace boost {
|
||||
private:
|
||||
node_pointer ptr_;
|
||||
bool has_alloc_;
|
||||
boost::unordered::detail::value_base<value_allocator> alloc_;
|
||||
boost::unordered::detail::optional<value_allocator> alloc_;
|
||||
|
||||
node_handle_set(node_pointer ptr, allocator_type const& a)
|
||||
: ptr_(ptr), has_alloc_(false)
|
||||
: ptr_(ptr), alloc_(a)
|
||||
{
|
||||
if (ptr_) {
|
||||
new ((void*)&alloc_) value_allocator(a);
|
||||
has_alloc_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1894,52 +1979,39 @@ namespace boost {
|
||||
|
||||
~node_handle_set()
|
||||
{
|
||||
if (has_alloc_ && ptr_) {
|
||||
node_allocator node_alloc(alloc_.value());
|
||||
if (ptr_) {
|
||||
node_allocator node_alloc(*alloc_);
|
||||
boost::unordered::detail::node_tmp<node_allocator> tmp(
|
||||
ptr_, node_alloc);
|
||||
}
|
||||
if (has_alloc_) {
|
||||
alloc_.value_ptr()->~value_allocator();
|
||||
}
|
||||
}
|
||||
|
||||
node_handle_set(BOOST_RV_REF(node_handle_set) n) BOOST_NOEXCEPT
|
||||
: ptr_(n.ptr_),
|
||||
has_alloc_(false)
|
||||
alloc_(boost::move(n.alloc_))
|
||||
{
|
||||
if (n.has_alloc_) {
|
||||
new ((void*)&alloc_) value_allocator(boost::move(n.alloc_.value()));
|
||||
has_alloc_ = true;
|
||||
n.ptr_ = node_pointer();
|
||||
n.alloc_.value_ptr()->~value_allocator();
|
||||
n.has_alloc_ = false;
|
||||
}
|
||||
n.ptr_ = node_pointer();
|
||||
}
|
||||
|
||||
node_handle_set& operator=(BOOST_RV_REF(node_handle_set) n)
|
||||
{
|
||||
BOOST_ASSERT(!has_alloc_ ||
|
||||
BOOST_ASSERT(!alloc_.has_value() ||
|
||||
value_allocator_traits::
|
||||
propagate_on_container_move_assignment::value ||
|
||||
(n.has_alloc_ && alloc_.value() == n.alloc_.value()));
|
||||
(n.alloc_.has_value() && alloc_ == n.alloc_));
|
||||
|
||||
if (ptr_) {
|
||||
node_allocator node_alloc(alloc_.value());
|
||||
node_allocator node_alloc(*alloc_);
|
||||
boost::unordered::detail::node_tmp<node_allocator> tmp(
|
||||
ptr_, node_alloc);
|
||||
ptr_ = node_pointer();
|
||||
}
|
||||
|
||||
if (has_alloc_) {
|
||||
alloc_.value_ptr()->~value_allocator();
|
||||
has_alloc_ = false;
|
||||
if (!alloc_.has_value() ||
|
||||
value_allocator_traits::propagate_on_container_move_assignment::
|
||||
value) {
|
||||
alloc_ = boost::move(n.alloc_);
|
||||
}
|
||||
|
||||
if (!has_alloc_ && n.has_alloc_) {
|
||||
move_allocator(n);
|
||||
}
|
||||
|
||||
ptr_ = n.ptr_;
|
||||
n.ptr_ = node_pointer();
|
||||
|
||||
@ -1948,7 +2020,7 @@ namespace boost {
|
||||
|
||||
value_type& value() const { return ptr_->value(); }
|
||||
|
||||
allocator_type get_allocator() const { return alloc_.value(); }
|
||||
allocator_type get_allocator() const { return *alloc_; }
|
||||
|
||||
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
|
||||
|
||||
@ -1957,38 +2029,19 @@ namespace boost {
|
||||
bool empty() const BOOST_NOEXCEPT { return ptr_ ? 0 : 1; }
|
||||
|
||||
void swap(node_handle_set& n) BOOST_NOEXCEPT_IF(
|
||||
value_allocator_traits::propagate_on_container_swap::value
|
||||
/* || value_allocator_traits::is_always_equal::value */)
|
||||
value_allocator_traits::propagate_on_container_swap::value ||
|
||||
value_allocator_traits::is_always_equal::value)
|
||||
{
|
||||
if (!has_alloc_) {
|
||||
if (n.has_alloc_) {
|
||||
move_allocator(n);
|
||||
}
|
||||
} else if (!n.has_alloc_) {
|
||||
n.move_allocator(*this);
|
||||
} else {
|
||||
swap_impl(
|
||||
n, boost::unordered::detail::integral_constant<bool,
|
||||
value_allocator_traits::propagate_on_container_swap::value>());
|
||||
BOOST_ASSERT(
|
||||
!alloc_.has_value() || !n.alloc_.has_value() ||
|
||||
value_allocator_traits::propagate_on_container_swap::value ||
|
||||
alloc_ == n.alloc_);
|
||||
if (value_allocator_traits::propagate_on_container_swap::value ||
|
||||
!alloc_.has_value() || !n.alloc_.has_value()) {
|
||||
boost::swap(alloc_, n.alloc_);
|
||||
}
|
||||
boost::swap(ptr_, n.ptr_);
|
||||
}
|
||||
|
||||
private:
|
||||
void move_allocator(node_handle_set& n)
|
||||
{
|
||||
new ((void*)&alloc_) value_allocator(boost::move(n.alloc_.value()));
|
||||
n.alloc_.value_ptr()->~value_allocator();
|
||||
has_alloc_ = true;
|
||||
n.has_alloc_ = false;
|
||||
}
|
||||
|
||||
void swap_impl(node_handle_set&, boost::unordered::detail::false_type) {}
|
||||
|
||||
void swap_impl(node_handle_set& n, boost::unordered::detail::true_type)
|
||||
{
|
||||
boost::swap(alloc_, n.alloc_);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename N, typename T, typename A>
|
||||
|
@ -1,4 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017-2018 Daniel James
|
||||
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)
|
||||
-->
|
||||
<explicit-failures-markup>
|
||||
<!-- unordered -->
|
||||
<library name="unordered">
|
||||
@ -17,11 +23,22 @@
|
||||
<test name="compile_map_unordered_allocator"/>
|
||||
<toolset name="msvc-7.1"/>
|
||||
<note author="Daniel James">
|
||||
This tests whether inserting elements creates as few copies as I think
|
||||
is possible. If this fails it just means that the container might be
|
||||
a little inefficient.
|
||||
This test fail because it's using unordered's internal
|
||||
allocator traits, which doesn't work on Visual C++ 7.1.
|
||||
It normally uses the one from Boost.Container by default.
|
||||
</note>
|
||||
</mark-expected-failures>
|
||||
</library>
|
||||
|
||||
<mark-expected-failures>
|
||||
<test name="noexcept_tests"/>
|
||||
<toolset name="gcc-4.3c+"/>
|
||||
<note author="Daniel James">
|
||||
boost::is_nothrow_move_constructible and
|
||||
boost::is_nothrow_move_assignable don't seem to work on this
|
||||
compiler. I'd hope that anyone wanting noexcept support would
|
||||
use a more recent compiler anyway.
|
||||
</note>
|
||||
</mark-expected-failures>
|
||||
</library>
|
||||
</explicit-failures-markup>
|
||||
|
||||
|
@ -63,6 +63,7 @@ test-suite unordered
|
||||
[ run unordered/equality_tests.cpp ]
|
||||
[ run unordered/swap_tests.cpp ]
|
||||
[ run unordered/detail_tests.cpp ]
|
||||
[ run unordered/deduction_tests.cpp ]
|
||||
|
||||
[ run unordered/compile_set.cpp : :
|
||||
: <define>BOOST_UNORDERED_USE_MOVE
|
||||
|
@ -54,9 +54,9 @@ template <class T> struct assign_base : public test::exception_base
|
||||
test::random_values<T> x_values, y_values;
|
||||
T x, y;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME T::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::hasher hasher;
|
||||
typedef typename T::key_equal key_equal;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
assign_base(int tag1, int tag2, float mlf1 = 1.0, float mlf2 = 1.0)
|
||||
: x_values(), y_values(),
|
||||
|
@ -172,9 +172,9 @@ template <class T> struct input_range_construct_test : public range<T>, objects
|
||||
|
||||
void run() const
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
|
||||
begin = this->values.begin(),
|
||||
end = this->values.end();
|
||||
typename test::random_values<T>::const_iterator begin =
|
||||
this->values.begin(),
|
||||
end = this->values.end();
|
||||
T x(test::input_iterator(begin), test::input_iterator(end), 0, hash,
|
||||
equal_to, allocator);
|
||||
|
||||
|
@ -38,8 +38,7 @@ template <class T> struct erase_by_key_test1 : public erase_test_base<T>
|
||||
{
|
||||
void run(T& x) const
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
|
||||
iterator;
|
||||
typedef typename test::random_values<T>::const_iterator iterator;
|
||||
|
||||
for (iterator it = this->values.begin(), end = this->values.end();
|
||||
it != end; ++it) {
|
||||
|
@ -18,7 +18,7 @@ test::seed_t initialize_seed(747373);
|
||||
template <typename T> void rehash_prep(T& x)
|
||||
{
|
||||
using namespace std;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::size_type size_type;
|
||||
typedef typename T::size_type size_type;
|
||||
|
||||
x.max_load_factor(0.25);
|
||||
size_type bucket_count = x.bucket_count();
|
||||
@ -146,23 +146,24 @@ struct insert_lvalue_end_type : inserter_base
|
||||
}
|
||||
} insert_lvalue_end;
|
||||
|
||||
template <typename T> struct insert_lvalue_pos_type_impl : inserter_base
|
||||
{
|
||||
typename T::iterator pos;
|
||||
|
||||
insert_lvalue_pos_type_impl(T& x) : pos(x.begin()) {}
|
||||
|
||||
template <typename Iterator> void operator()(T& x, Iterator it)
|
||||
{
|
||||
pos = get_iterator(x.insert(pos, *it));
|
||||
}
|
||||
};
|
||||
|
||||
struct insert_lvalue_pos_type
|
||||
{
|
||||
template <typename T> struct impl : inserter_base
|
||||
template <typename T>
|
||||
friend insert_lvalue_pos_type_impl<T> generate(insert_lvalue_pos_type, T& x)
|
||||
{
|
||||
typename T::iterator pos;
|
||||
|
||||
impl(T& x) : pos(x.begin()) {}
|
||||
|
||||
template <typename Iterator> void operator()(T& x, Iterator it)
|
||||
{
|
||||
pos = get_iterator(x.insert(pos, *it));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> friend impl<T> generate(insert_lvalue_pos_type, T& x)
|
||||
{
|
||||
return impl<T>(x);
|
||||
return insert_lvalue_pos_type_impl<T>(x);
|
||||
}
|
||||
} insert_lvalue_pos;
|
||||
|
||||
@ -198,23 +199,24 @@ struct emplace_lvalue_end_type : inserter_base
|
||||
}
|
||||
} emplace_lvalue_end;
|
||||
|
||||
template <typename T> struct emplace_lvalue_pos_type_impl : inserter_base
|
||||
{
|
||||
typename T::iterator pos;
|
||||
|
||||
emplace_lvalue_pos_type_impl(T& x) : pos(x.begin()) {}
|
||||
|
||||
template <typename Iterator> void operator()(T& x, Iterator it)
|
||||
{
|
||||
pos = get_iterator(x.emplace_hint(pos, *it));
|
||||
}
|
||||
};
|
||||
|
||||
struct emplace_lvalue_pos_type
|
||||
{
|
||||
template <typename T> struct impl : inserter_base
|
||||
template <typename T>
|
||||
friend emplace_lvalue_pos_type_impl<T> generate(emplace_lvalue_pos_type, T& x)
|
||||
{
|
||||
typename T::iterator pos;
|
||||
|
||||
impl(T& x) : pos(x.begin()) {}
|
||||
|
||||
template <typename Iterator> void operator()(T& x, Iterator it)
|
||||
{
|
||||
pos = get_iterator(x.emplace_hint(pos, *it));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> friend impl<T> generate(emplace_lvalue_pos_type, T& x)
|
||||
{
|
||||
return impl<T>(x);
|
||||
return emplace_lvalue_pos_type_impl<T>(x);
|
||||
}
|
||||
} emplace_lvalue_pos;
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
|
||||
// Copyright 2017-2018 Daniel James.
|
||||
// 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)
|
||||
|
||||
#include "../helpers/exception_test.hpp"
|
||||
#include "../helpers/invariants.hpp"
|
||||
#include "../helpers/metafunctions.hpp"
|
||||
|
@ -21,9 +21,9 @@ template <class T> struct move_assign_base : public test::exception_base
|
||||
test::random_values<T> x_values, y_values;
|
||||
T x, y;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME T::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::hasher hasher;
|
||||
typedef typename T::key_equal key_equal;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
move_assign_base(int tag1, int tag2, float mlf1 = 1.0, float mlf2 = 1.0)
|
||||
: x_values(), y_values(),
|
||||
|
@ -60,9 +60,9 @@ template <class T> struct swap_base : public test::exception_base
|
||||
const test::random_values<T> x_values, y_values;
|
||||
const T initial_x, initial_y;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME T::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::hasher hasher;
|
||||
typedef typename T::key_equal key_equal;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
swap_base(unsigned int count1, unsigned int count2, int tag1, int tag2)
|
||||
: x_values(count1, test::limited_range),
|
||||
@ -90,7 +90,7 @@ template <class T> struct swap_base : public test::exception_base
|
||||
{
|
||||
try {
|
||||
d.x.swap(d.y);
|
||||
} catch (std::runtime_error) {
|
||||
} catch (std::runtime_error&) {
|
||||
}
|
||||
|
||||
DISABLE_EXCEPTIONS;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#if !defined(BOOST_UNORDERED_TEST_HELPERS_COUNT_HEAD)
|
||||
#define BOOST_UNORDERED_TEST_HELPERS_COUNT_HEAD
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
namespace test {
|
||||
struct object_count
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "./list.hpp"
|
||||
#include "./metafunctions.hpp"
|
||||
#include <algorithm>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
@ -58,12 +58,12 @@ namespace test {
|
||||
|
||||
template <class Container> class unordered_equivalence_tester
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME Container::size_type size_;
|
||||
BOOST_DEDUCED_TYPENAME Container::hasher hasher_;
|
||||
BOOST_DEDUCED_TYPENAME Container::key_equal key_equal_;
|
||||
typename Container::size_type size_;
|
||||
typename Container::hasher hasher_;
|
||||
typename Container::key_equal key_equal_;
|
||||
float max_load_factor_;
|
||||
|
||||
typedef test::list<BOOST_DEDUCED_TYPENAME Container::value_type> value_list;
|
||||
typedef test::list<typename Container::value_type> value_list;
|
||||
value_list values_;
|
||||
|
||||
public:
|
||||
|
@ -176,21 +176,18 @@ namespace test {
|
||||
DISABLE_EXCEPTIONS;
|
||||
test::check_instances check;
|
||||
test::scope = "";
|
||||
BOOST_DEDUCED_TYPENAME Test::data_type x(test_.init());
|
||||
BOOST_DEDUCED_TYPENAME Test::strong_type strong;
|
||||
typename Test::data_type x(test_.init());
|
||||
typename Test::strong_type strong;
|
||||
strong.store(x);
|
||||
try {
|
||||
ENABLE_EXCEPTIONS;
|
||||
call_ignore_extra_parameters<Test,
|
||||
BOOST_DEDUCED_TYPENAME Test::data_type,
|
||||
BOOST_DEDUCED_TYPENAME Test::strong_type>(
|
||||
&Test::run, test_, x, strong);
|
||||
call_ignore_extra_parameters<Test, typename Test::data_type,
|
||||
typename Test::strong_type>(&Test::run, test_, x, strong);
|
||||
} catch (...) {
|
||||
try {
|
||||
DISABLE_EXCEPTIONS;
|
||||
call_ignore_extra_parameters<Test,
|
||||
BOOST_DEDUCED_TYPENAME Test::data_type const,
|
||||
BOOST_DEDUCED_TYPENAME Test::strong_type const>(
|
||||
call_ignore_extra_parameters<Test, typename Test::data_type const,
|
||||
typename Test::strong_type const>(
|
||||
&Test::check, test_, constant(x), constant(strong));
|
||||
} catch (...) {
|
||||
exception_in_check_ = true;
|
||||
|
@ -6,10 +6,12 @@
|
||||
#if !defined(BOOST_UNORDERED_TEST_HELPERS_HEADER)
|
||||
#define BOOST_UNORDERED_TEST_HELPERS_HEADER
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace test {
|
||||
template <class Container> struct get_key_impl
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::key_type key_type;
|
||||
typedef typename Container::key_type key_type;
|
||||
|
||||
static key_type const& get_key(key_type const& x) { return x; }
|
||||
|
||||
@ -28,7 +30,7 @@ namespace test {
|
||||
};
|
||||
|
||||
template <class Container, class T>
|
||||
inline BOOST_DEDUCED_TYPENAME Container::key_type const& get_key(T const& x)
|
||||
inline typename Container::key_type const& get_key(T const& x)
|
||||
{
|
||||
return get_key_impl<Container>::get_key(x);
|
||||
}
|
||||
@ -36,16 +38,17 @@ namespace test {
|
||||
// test::next
|
||||
//
|
||||
// Increments an iterator by 1 or a given value.
|
||||
// Like boost::next, but simpler and slower.
|
||||
// Like boost::next, but simpler.
|
||||
// Mainly because boost::next uses an MPL file
|
||||
// which causes warnings.
|
||||
|
||||
template <typename Iterator> Iterator next(Iterator it) { return ++it; }
|
||||
|
||||
template <typename Iterator, typename IntType>
|
||||
Iterator next(Iterator it, IntType x)
|
||||
{
|
||||
for (; x > 0; --x) {
|
||||
++it;
|
||||
}
|
||||
std::advance(it,
|
||||
static_cast<typename std::iterator_traits<Iterator>::difference_type>(x));
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,12 @@
|
||||
#define BOOST_UNORDERED_TEST_HELPERS_INPUT_ITERATOR_HEADER
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace test {
|
||||
template <class Iterator> struct proxy
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Iterator::value_type value_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
|
||||
explicit proxy(value_type const& v) : v_(v) {}
|
||||
proxy(proxy const& x) : v_(x.v_) {}
|
||||
@ -25,16 +24,13 @@ namespace test {
|
||||
proxy& operator=(proxy const&);
|
||||
};
|
||||
|
||||
template <class Iterator>
|
||||
struct input_iterator_adaptor
|
||||
: public std::iterator<std::input_iterator_tag,
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type,
|
||||
std::ptrdiff_t,
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_pointer<Iterator>::type,
|
||||
proxy<Iterator> >
|
||||
template <class Iterator> struct input_iterator_adaptor
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type
|
||||
value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
||||
typedef proxy<Iterator> reference;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
|
||||
input_iterator_adaptor() : base_() {}
|
||||
explicit input_iterator_adaptor(Iterator& it) : base_(&it) {}
|
||||
@ -66,19 +62,15 @@ namespace test {
|
||||
return input_iterator_adaptor<Iterator>(it);
|
||||
}
|
||||
|
||||
template <class Iterator>
|
||||
struct copy_iterator_adaptor
|
||||
: public std::iterator<
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_category<Iterator>::type,
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type,
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_difference<Iterator>::type,
|
||||
BOOST_DEDUCED_TYPENAME boost::iterator_pointer<Iterator>::type,
|
||||
proxy<Iterator> >
|
||||
template <class Iterator> struct copy_iterator_adaptor
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<Iterator>::type
|
||||
value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<Iterator>::type
|
||||
difference_type;
|
||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||
typedef
|
||||
typename std::iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef typename std::iterator_traits<Iterator>::iterator_category
|
||||
iterator_category;
|
||||
typedef typename std::iterator_traits<Iterator>::pointer pointer;
|
||||
typedef proxy<Iterator> reference;
|
||||
|
||||
copy_iterator_adaptor() : base_() {}
|
||||
explicit copy_iterator_adaptor(Iterator const& it) : base_(it) {}
|
||||
|
@ -24,12 +24,12 @@
|
||||
namespace test {
|
||||
template <class X> void check_equivalent_keys(X const& x1)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME X::key_equal eq = x1.key_eq();
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typename X::key_equal eq = x1.key_eq();
|
||||
typedef typename X::key_type key_type;
|
||||
std::set<key_type, std::less<key_type> > found_;
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::const_iterator it = x1.begin(), end = x1.end();
|
||||
BOOST_DEDUCED_TYPENAME X::size_type size = 0;
|
||||
typename X::const_iterator it = x1.begin(), end = x1.end();
|
||||
typename X::size_type size = 0;
|
||||
while (it != end) {
|
||||
// First test that the current key has not occurred before, required
|
||||
// to test either that keys are unique or that equivalent keys are
|
||||
@ -60,9 +60,9 @@ namespace test {
|
||||
|
||||
// Check that the keys are in the correct bucket and are
|
||||
// adjacent in the bucket.
|
||||
BOOST_DEDUCED_TYPENAME X::size_type bucket = x1.bucket(key);
|
||||
BOOST_DEDUCED_TYPENAME X::const_local_iterator lit = x1.begin(bucket),
|
||||
lend = x1.end(bucket);
|
||||
typename X::size_type bucket = x1.bucket(key);
|
||||
typename X::const_local_iterator lit = x1.begin(bucket),
|
||||
lend = x1.end(bucket);
|
||||
|
||||
unsigned int count_checked = 0;
|
||||
for (; lit != lend && !eq(get_key<X>(*lit), key); ++lit) {
|
||||
@ -106,12 +106,11 @@ namespace test {
|
||||
|
||||
// Check that size in the buckets matches up.
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type bucket_size = 0;
|
||||
typename X::size_type bucket_size = 0;
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME X::size_type i = 0; i < x1.bucket_count();
|
||||
++i) {
|
||||
for (BOOST_DEDUCED_TYPENAME X::const_local_iterator begin2 = x1.begin(i),
|
||||
end2 = x1.end(i);
|
||||
for (typename X::size_type i = 0; i < x1.bucket_count(); ++i) {
|
||||
for (typename X::const_local_iterator begin2 = x1.begin(i),
|
||||
end2 = x1.end(i);
|
||||
begin2 != end2; ++begin2) {
|
||||
++bucket_size;
|
||||
}
|
||||
|
@ -81,9 +81,7 @@ namespace test {
|
||||
list_data& operator=(list_data const&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class list_iterator
|
||||
: public std::iterator<std::forward_iterator_tag, T, int, T*, T&>
|
||||
template <typename T> class list_iterator
|
||||
{
|
||||
friend class list_const_iterator<T>;
|
||||
friend class test::list<T>;
|
||||
@ -93,6 +91,12 @@ namespace test {
|
||||
node* ptr_;
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef int difference_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
list_iterator() : ptr_(0) {}
|
||||
explicit list_iterator(node* x) : ptr_(x) {}
|
||||
|
||||
@ -113,9 +117,7 @@ namespace test {
|
||||
bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class list_const_iterator : public std::iterator<std::forward_iterator_tag,
|
||||
T, int, T const*, T const&>
|
||||
template <typename T> class list_const_iterator
|
||||
{
|
||||
friend class list_iterator<T>;
|
||||
friend class test::list<T>;
|
||||
@ -126,6 +128,12 @@ namespace test {
|
||||
node* ptr_;
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef T const* pointer;
|
||||
typedef T const& reference;
|
||||
typedef int difference_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
list_const_iterator() : ptr_(0) {}
|
||||
list_const_iterator(list_iterator<T> const& x) : ptr_(x.ptr_) {}
|
||||
|
||||
|
@ -11,23 +11,19 @@
|
||||
|
||||
namespace test {
|
||||
template <class Container>
|
||||
struct is_set
|
||||
: public boost::is_same<BOOST_DEDUCED_TYPENAME Container::key_type,
|
||||
BOOST_DEDUCED_TYPENAME Container::value_type>
|
||||
struct is_set : public boost::is_same<typename Container::key_type,
|
||||
typename Container::value_type>
|
||||
{
|
||||
};
|
||||
|
||||
template <class Container> struct has_unique_keys
|
||||
{
|
||||
static char flip(BOOST_DEDUCED_TYPENAME Container::iterator const&);
|
||||
static long flip(
|
||||
std::pair<BOOST_DEDUCED_TYPENAME Container::iterator, bool> const&);
|
||||
static char flip(typename Container::iterator const&);
|
||||
static long flip(std::pair<typename Container::iterator, bool> const&);
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = sizeof(long) ==
|
||||
sizeof(
|
||||
flip(((Container*)0)
|
||||
->insert(
|
||||
*(BOOST_DEDUCED_TYPENAME Container::value_type*)0))));
|
||||
sizeof(flip(
|
||||
((Container*)0)->insert(*(typename Container::value_type*)0))));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace test {
|
||||
template <class X> struct unordered_generator_set
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef typename X::value_type value_type;
|
||||
|
||||
random_generator type_;
|
||||
|
||||
@ -41,8 +41,8 @@ namespace test {
|
||||
|
||||
template <class X> struct unordered_generator_map
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
|
||||
typedef typename X::key_type key_type;
|
||||
typedef typename X::mapped_type mapped_type;
|
||||
|
||||
random_generator type_;
|
||||
|
||||
@ -78,7 +78,7 @@ namespace test {
|
||||
template <class X>
|
||||
struct unordered_generator : public unordered_generator_base<X>::type
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME unordered_generator_base<X>::type base;
|
||||
typedef typename unordered_generator_base<X>::type base;
|
||||
|
||||
unordered_generator(random_generator const& type = default_generator)
|
||||
: base(type)
|
||||
@ -87,7 +87,7 @@ namespace test {
|
||||
};
|
||||
|
||||
template <class X>
|
||||
struct random_values : public test::list<BOOST_DEDUCED_TYPENAME X::value_type>
|
||||
struct random_values : public test::list<typename X::value_type>
|
||||
{
|
||||
random_values() {}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace test {
|
||||
template <class X> class strong
|
||||
{
|
||||
typedef test::list<BOOST_DEDUCED_TYPENAME X::value_type> values_type;
|
||||
typedef test::list<typename X::value_type> values_type;
|
||||
values_type values_;
|
||||
unsigned int allocations_;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#if !defined(BOOST_UNORDERED_TEST_TEST_HEADER)
|
||||
#define BOOST_UNORDERED_TEST_TEST_HEADER
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace test {
|
||||
template <typename X> struct equals_to_compare
|
||||
{
|
||||
typedef std::less<BOOST_DEDUCED_TYPENAME X::first_argument_type> type;
|
||||
typedef std::less<typename X::first_argument_type> type;
|
||||
};
|
||||
|
||||
template <> struct equals_to_compare<test::equal_to>
|
||||
@ -32,7 +32,7 @@ namespace test {
|
||||
|
||||
template <class X1, class X2> void compare_range(X1 const& x1, X2 const& x2)
|
||||
{
|
||||
typedef test::list<BOOST_DEDUCED_TYPENAME X1::value_type> value_list;
|
||||
typedef test::list<typename X1::value_type> value_list;
|
||||
value_list values1(x1.begin(), x1.end());
|
||||
value_list values2(x2.begin(), x2.end());
|
||||
values1.sort();
|
||||
@ -60,44 +60,38 @@ namespace test {
|
||||
|
||||
template <typename X> struct ordered_base<X, true, true>
|
||||
{
|
||||
typedef std::set<BOOST_DEDUCED_TYPENAME X::value_type,
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
equals_to_compare<BOOST_DEDUCED_TYPENAME X::key_equal>::type>
|
||||
typedef std::set<typename X::value_type,
|
||||
typename equals_to_compare<typename X::key_equal>::type>
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename X> struct ordered_base<X, true, false>
|
||||
{
|
||||
typedef std::multiset<BOOST_DEDUCED_TYPENAME X::value_type,
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
equals_to_compare<BOOST_DEDUCED_TYPENAME X::key_equal>::type>
|
||||
typedef std::multiset<typename X::value_type,
|
||||
typename equals_to_compare<typename X::key_equal>::type>
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename X> struct ordered_base<X, false, true>
|
||||
{
|
||||
typedef std::map<BOOST_DEDUCED_TYPENAME X::key_type,
|
||||
BOOST_DEDUCED_TYPENAME X::mapped_type,
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
equals_to_compare<BOOST_DEDUCED_TYPENAME X::key_equal>::type>
|
||||
typedef std::map<typename X::key_type, typename X::mapped_type,
|
||||
typename equals_to_compare<typename X::key_equal>::type>
|
||||
type;
|
||||
};
|
||||
|
||||
template <typename X> struct ordered_base<X, false, false>
|
||||
{
|
||||
typedef std::multimap<BOOST_DEDUCED_TYPENAME X::key_type,
|
||||
BOOST_DEDUCED_TYPENAME X::mapped_type,
|
||||
BOOST_DEDUCED_TYPENAME
|
||||
equals_to_compare<BOOST_DEDUCED_TYPENAME X::key_equal>::type>
|
||||
typedef std::multimap<typename X::key_type, typename X::mapped_type,
|
||||
typename equals_to_compare<typename X::key_equal>::type>
|
||||
type;
|
||||
};
|
||||
|
||||
template <class X> class ordered : public ordered_base<X>::type
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME ordered_base<X>::type base;
|
||||
typedef typename ordered_base<X>::type base;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME base::key_compare key_compare;
|
||||
typedef typename base::key_compare key_compare;
|
||||
|
||||
ordered() : base() {}
|
||||
|
||||
@ -105,12 +99,10 @@ namespace test {
|
||||
|
||||
void compare(X const& x) { compare_range(x, *this); }
|
||||
|
||||
void compare_key(
|
||||
X const& x, BOOST_DEDUCED_TYPENAME X::value_type const& val)
|
||||
void compare_key(X const& x, typename X::value_type const& val)
|
||||
{
|
||||
compare_pairs(x.equal_range(get_key<X>(val)),
|
||||
this->equal_range(get_key<X>(val)),
|
||||
(BOOST_DEDUCED_TYPENAME X::value_type*)0);
|
||||
this->equal_range(get_key<X>(val)), (typename X::value_type*)0);
|
||||
}
|
||||
|
||||
template <class It> void insert_range(It b, It e)
|
||||
@ -123,10 +115,9 @@ namespace test {
|
||||
};
|
||||
|
||||
template <class Equals>
|
||||
BOOST_DEDUCED_TYPENAME equals_to_compare<Equals>::type create_compare(
|
||||
Equals const&)
|
||||
typename equals_to_compare<Equals>::type create_compare(Equals const&)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME equals_to_compare<Equals>::type x;
|
||||
typename equals_to_compare<Equals>::type x;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,9 @@ namespace test {
|
||||
int type_;
|
||||
|
||||
public:
|
||||
explicit hash(int t = 0) : type_(t) {}
|
||||
hash() : type_(0) {}
|
||||
|
||||
explicit hash(int t) : type_(t) {}
|
||||
|
||||
std::size_t operator()(object const& x) const
|
||||
{
|
||||
@ -298,7 +300,9 @@ namespace test {
|
||||
int type_;
|
||||
|
||||
public:
|
||||
explicit equal_to(int t = 0) : type_(t) {}
|
||||
equal_to() : type_(0) {}
|
||||
|
||||
explicit equal_to(int t) : type_(t) {}
|
||||
|
||||
bool operator()(object const& x1, object const& x2) const
|
||||
{
|
||||
@ -354,10 +358,9 @@ namespace test {
|
||||
typedef allocator1<U> other;
|
||||
};
|
||||
|
||||
explicit allocator1(int t = 0) : tag_(t)
|
||||
{
|
||||
detail::tracker.allocator_ref();
|
||||
}
|
||||
allocator1() : tag_(0) { detail::tracker.allocator_ref(); }
|
||||
|
||||
explicit allocator1(int t) : tag_(t) { detail::tracker.allocator_ref(); }
|
||||
|
||||
template <class Y> allocator1(allocator1<Y> const& x) : tag_(x.tag_)
|
||||
{
|
||||
@ -601,10 +604,9 @@ namespace test {
|
||||
typedef allocator2<U> other;
|
||||
};
|
||||
|
||||
explicit allocator2(int t = 0) : tag_(t)
|
||||
{
|
||||
detail::tracker.allocator_ref();
|
||||
}
|
||||
allocator2() : tag_(0) { detail::tracker.allocator_ref(); }
|
||||
|
||||
explicit allocator2(int t) : tag_(t) { detail::tracker.allocator_ref(); }
|
||||
|
||||
template <class Y> allocator2(allocator2<Y> const& x) : tag_(x.tag_)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
// 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)
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
@ -36,8 +36,8 @@
|
||||
{ \
|
||||
return (std::numeric_limits<std::size_t>::max)(); \
|
||||
} \
|
||||
bool operator==(name<T> const&) { return true; } \
|
||||
bool operator!=(name<T> const&) { return false; } \
|
||||
bool operator==(name<T> const&) const { return true; } \
|
||||
bool operator!=(name<T> const&) const { return false; } \
|
||||
/**/
|
||||
|
||||
#define ALLOCATOR_METHODS_TYPEDEFS(name) \
|
||||
@ -126,6 +126,7 @@ void test_empty_allocator()
|
||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||
BOOST_TEST(traits::is_always_equal::value);
|
||||
BOOST_TEST(call_select<allocator>() == 0);
|
||||
}
|
||||
|
||||
@ -139,6 +140,7 @@ template <typename T> struct allocator1
|
||||
typedef yes_type propagate_on_container_copy_assignment;
|
||||
typedef yes_type propagate_on_container_move_assignment;
|
||||
typedef yes_type propagate_on_container_swap;
|
||||
typedef yes_type is_always_equal;
|
||||
|
||||
allocator1<T> select_on_container_copy_construction() const
|
||||
{
|
||||
@ -166,6 +168,7 @@ void test_allocator1()
|
||||
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
||||
BOOST_TEST(traits::propagate_on_container_move_assignment::value);
|
||||
BOOST_TEST(traits::propagate_on_container_swap::value);
|
||||
BOOST_TEST(traits::is_always_equal::value);
|
||||
BOOST_TEST(call_select<allocator>() == 1);
|
||||
}
|
||||
|
||||
@ -192,6 +195,7 @@ template <typename T> struct allocator2 : allocator2_base<allocator2<T> >
|
||||
typedef no_type propagate_on_container_copy_assignment;
|
||||
typedef no_type propagate_on_container_move_assignment;
|
||||
typedef no_type propagate_on_container_swap;
|
||||
typedef no_type is_always_equal;
|
||||
};
|
||||
|
||||
void test_allocator2()
|
||||
@ -208,6 +212,7 @@ void test_allocator2()
|
||||
BOOST_TEST(!traits::propagate_on_container_copy_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||
BOOST_TEST(!traits::is_always_equal::value);
|
||||
BOOST_TEST(call_select<allocator>() == 1);
|
||||
}
|
||||
|
||||
@ -240,6 +245,8 @@ template <typename T> struct allocator3
|
||||
typedef ptr<T const> const_pointer;
|
||||
typedef unsigned short size_type;
|
||||
|
||||
int x; // Just to make it non-empty, so that is_always_equal is false.
|
||||
|
||||
ALLOCATOR_METHODS_TYPEDEFS(allocator3)
|
||||
|
||||
typedef yes_type propagate_on_container_copy_assignment;
|
||||
@ -267,6 +274,7 @@ void test_allocator3()
|
||||
BOOST_TEST(traits::propagate_on_container_copy_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_move_assignment::value);
|
||||
BOOST_TEST(!traits::propagate_on_container_swap::value);
|
||||
BOOST_TEST(!traits::is_always_equal::value);
|
||||
BOOST_TEST(call_select<allocator>() == 1);
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ namespace assign_tests {
|
||||
|
||||
template <class T> void assign_tests1(T*, test::random_generator generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "assign_tests1.1\n";
|
||||
{
|
||||
@ -68,14 +68,14 @@ namespace assign_tests {
|
||||
|
||||
template <class T> void assign_tests2(T*, test::random_generator generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
typename T::hasher hf1(1);
|
||||
typename T::hasher hf2(2);
|
||||
typename T::key_equal eq1(1);
|
||||
typename T::key_equal eq2(2);
|
||||
typename T::allocator_type al1(1);
|
||||
typename T::allocator_type al2(2);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "assign_tests2.0 - empty container\n";
|
||||
{
|
||||
|
@ -25,13 +25,13 @@ namespace at_tests {
|
||||
try {
|
||||
x.at("one");
|
||||
BOOST_ERROR("Should have thrown.");
|
||||
} catch (std::out_of_range) {
|
||||
} catch (std::out_of_range&) {
|
||||
}
|
||||
|
||||
try {
|
||||
x_const.at("one");
|
||||
BOOST_ERROR("Should have thrown.");
|
||||
} catch (std::out_of_range) {
|
||||
} catch (std::out_of_range&) {
|
||||
}
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Add elements" << std::endl;
|
||||
@ -51,13 +51,13 @@ namespace at_tests {
|
||||
try {
|
||||
x.at("three");
|
||||
BOOST_ERROR("Should have thrown.");
|
||||
} catch (std::out_of_range) {
|
||||
} catch (std::out_of_range&) {
|
||||
}
|
||||
|
||||
try {
|
||||
x_const.at("three");
|
||||
BOOST_ERROR("Should have thrown.");
|
||||
} catch (std::out_of_range) {
|
||||
} catch (std::out_of_range&) {
|
||||
}
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Finished" << std::endl;
|
||||
|
@ -29,8 +29,8 @@ namespace bucket_tests {
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef typename X::size_type size_type;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
X x(v.begin(), v.end());
|
||||
@ -41,9 +41,8 @@ namespace bucket_tests {
|
||||
<< "<=" << x.max_bucket_count() << "\n";
|
||||
}
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
|
||||
it = v.begin(),
|
||||
end = v.end();
|
||||
for (typename test::random_values<X>::const_iterator it = v.begin(),
|
||||
end = v.end();
|
||||
it != end; ++it) {
|
||||
size_type bucket = x.bucket(test::get_key<X>(*it));
|
||||
|
||||
|
@ -17,11 +17,12 @@
|
||||
#endif
|
||||
|
||||
#include "../helpers/check_return_type.hpp"
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/predef.h>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/cv_traits.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/utility/swap.hpp>
|
||||
@ -51,27 +52,27 @@ template <class T> int implicit_construct()
|
||||
|
||||
template <class X, class T> void container_test(X& r, T const&)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::difference_type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::difference_type difference_type;
|
||||
typedef typename X::size_type size_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<iterator>::type
|
||||
iterator_value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value<const_iterator>::type
|
||||
typedef
|
||||
typename std::iterator_traits<iterator>::value_type iterator_value_type;
|
||||
typedef typename std::iterator_traits<const_iterator>::value_type
|
||||
const_iterator_value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type
|
||||
typedef typename std::iterator_traits<iterator>::difference_type
|
||||
iterator_difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<
|
||||
const_iterator>::type const_iterator_difference_type;
|
||||
typedef typename std::iterator_traits<const_iterator>::difference_type
|
||||
const_iterator_difference_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::reference reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_reference const_reference;
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::reference reference;
|
||||
typedef typename X::const_reference const_reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
typedef typename X::node_type node_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
|
||||
// value_type
|
||||
|
||||
@ -96,8 +97,8 @@ template <class X, class T> void container_test(X& r, T const&)
|
||||
|
||||
// node_type
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<allocator_type,
|
||||
BOOST_DEDUCED_TYPENAME node_type::allocator_type>::value));
|
||||
BOOST_STATIC_ASSERT((
|
||||
boost::is_same<allocator_type, typename node_type::allocator_type>::value));
|
||||
|
||||
// difference_type
|
||||
|
||||
@ -207,9 +208,9 @@ template <class X, class T> void container_test(X& r, T const&)
|
||||
|
||||
template <class X> void unordered_destructible_test(X&)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::size_type size_type;
|
||||
|
||||
X x1;
|
||||
|
||||
@ -246,31 +247,30 @@ template <class X> void unordered_destructible_test(X&)
|
||||
|
||||
// Allocator
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
test::check_return_type<allocator_type>::equals(a_const.get_allocator());
|
||||
}
|
||||
|
||||
template <class X, class Key> void unordered_set_test(X& r, Key const&)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::key_type key_type;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type, key_type>::value));
|
||||
|
||||
// iterator pointer / const_pointer_type
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
|
||||
iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::local_iterator local_iterator;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
typedef typename std::iterator_traits<iterator>::pointer iterator_pointer;
|
||||
typedef typename std::iterator_traits<const_iterator>::pointer
|
||||
const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
|
||||
typedef typename std::iterator_traits<local_iterator>::pointer
|
||||
local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
|
||||
const_local_iterator>::type const_local_iterator_pointer;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::pointer
|
||||
const_local_iterator_pointer;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<value_type const*, iterator_pointer>::value));
|
||||
@ -281,8 +281,46 @@ template <class X, class Key> void unordered_set_test(X& r, Key const&)
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME node_type::value_type node_value_type;
|
||||
// pointer_traits<iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<iterator,
|
||||
typename boost::pointer_traits<iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<const_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
|
||||
typename boost::pointer_traits<const_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<const_iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<const_iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<local_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
|
||||
typename boost::pointer_traits<local_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<local_iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<local_iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<const_local_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
|
||||
typename boost::pointer_traits<const_local_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<const_local_iterator>::element_type>::
|
||||
value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<const_local_iterator>::difference_type>::
|
||||
value));
|
||||
|
||||
typedef typename X::node_type node_type;
|
||||
typedef typename node_type::value_type node_value_type;
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type, node_value_type>::value));
|
||||
|
||||
// Call node_type functions.
|
||||
@ -297,26 +335,25 @@ template <class X, class Key> void unordered_set_test(X& r, Key const&)
|
||||
template <class X, class Key, class T>
|
||||
void unordered_map_test(X& r, Key const& k, T const& v)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::value_type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typedef typename X::value_type value_type;
|
||||
typedef typename X::key_type key_type;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<value_type, std::pair<key_type const, T> >::value));
|
||||
|
||||
// iterator pointer / const_pointer_type
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
|
||||
iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::local_iterator local_iterator;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
typedef typename std::iterator_traits<iterator>::pointer iterator_pointer;
|
||||
typedef typename std::iterator_traits<const_iterator>::pointer
|
||||
const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
|
||||
typedef typename std::iterator_traits<local_iterator>::pointer
|
||||
local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
|
||||
const_local_iterator>::type const_local_iterator_pointer;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::pointer
|
||||
const_local_iterator_pointer;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type*, iterator_pointer>::value));
|
||||
BOOST_STATIC_ASSERT(
|
||||
@ -326,9 +363,47 @@ void unordered_map_test(X& r, Key const& k, T const& v)
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<value_type const*, const_local_iterator_pointer>::value));
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME node_type::key_type node_key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME node_type::mapped_type node_mapped_type;
|
||||
// pointer_traits<iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<iterator,
|
||||
typename boost::pointer_traits<iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type,
|
||||
typename boost::pointer_traits<iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<const_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<const_iterator,
|
||||
typename boost::pointer_traits<const_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<const_iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<const_iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<local_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<local_iterator,
|
||||
typename boost::pointer_traits<local_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type,
|
||||
typename boost::pointer_traits<local_iterator>::element_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<local_iterator>::difference_type>::value));
|
||||
|
||||
// pointer_traits<const_local_iterator>
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<const_local_iterator,
|
||||
typename boost::pointer_traits<const_local_iterator>::pointer>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<value_type const,
|
||||
typename boost::pointer_traits<const_local_iterator>::element_type>::
|
||||
value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<std::ptrdiff_t,
|
||||
typename boost::pointer_traits<const_local_iterator>::difference_type>::
|
||||
value));
|
||||
|
||||
typedef typename X::node_type node_type;
|
||||
typedef typename node_type::key_type node_key_type;
|
||||
typedef typename node_type::mapped_type node_mapped_type;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<Key, node_key_type>::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_same<T, node_mapped_type>::value));
|
||||
@ -400,12 +475,12 @@ template <class X> void equality_test(X& r)
|
||||
|
||||
template <class X, class T> void unordered_unique_test(X& r, T const& t)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
test::check_return_type<std::pair<iterator, bool> >::equals(r.insert(t));
|
||||
test::check_return_type<std::pair<iterator, bool> >::equals(r.emplace(t));
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::insert_return_type insert_return_type;
|
||||
typedef typename X::node_type node_type;
|
||||
typedef typename X::insert_return_type insert_return_type;
|
||||
|
||||
// insert_return_type
|
||||
|
||||
@ -432,7 +507,7 @@ template <class X, class T> void unordered_unique_test(X& r, T const& t)
|
||||
|
||||
template <class X, class T> void unordered_equivalent_test(X& r, T const& t)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
test::check_return_type<iterator>::equals(r.insert(t));
|
||||
test::check_return_type<iterator>::equals(r.emplace(t));
|
||||
}
|
||||
@ -440,8 +515,8 @@ template <class X, class T> void unordered_equivalent_test(X& r, T const& t)
|
||||
template <class X, class Key, class T>
|
||||
void unordered_map_functions(X&, Key const& k, T const& v)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::mapped_type mapped_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::mapped_type mapped_type;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
X a;
|
||||
test::check_return_type<mapped_type>::equals_ref(a[k]);
|
||||
@ -472,52 +547,50 @@ void unordered_test(X& x, Key& k, Hash& hf, Pred& eq)
|
||||
{
|
||||
unordered_destructible_test(x);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_type key_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::size_type size_type;
|
||||
typedef typename X::key_type key_type;
|
||||
typedef typename X::hasher hasher;
|
||||
typedef typename X::key_equal key_equal;
|
||||
typedef typename X::size_type size_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::local_iterator local_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_local_iterator const_local_iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::local_iterator local_iterator;
|
||||
typedef typename X::const_local_iterator const_local_iterator;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<iterator>::type
|
||||
typedef typename std::iterator_traits<iterator>::iterator_category
|
||||
iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<iterator>::type
|
||||
typedef typename std::iterator_traits<iterator>::difference_type
|
||||
iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<iterator>::type
|
||||
iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<iterator>::type
|
||||
iterator_reference;
|
||||
typedef typename std::iterator_traits<iterator>::pointer iterator_pointer;
|
||||
typedef typename std::iterator_traits<iterator>::reference iterator_reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
|
||||
local_iterator>::type local_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_difference<local_iterator>::type local_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<local_iterator>::type
|
||||
typedef typename std::iterator_traits<local_iterator>::iterator_category
|
||||
local_iterator_category;
|
||||
typedef typename std::iterator_traits<local_iterator>::difference_type
|
||||
local_iterator_difference;
|
||||
typedef typename std::iterator_traits<local_iterator>::pointer
|
||||
local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<local_iterator>::type
|
||||
typedef typename std::iterator_traits<local_iterator>::reference
|
||||
local_iterator_reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
|
||||
const_iterator>::type const_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::iterator_difference<const_iterator>::type const_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<const_iterator>::type
|
||||
typedef typename std::iterator_traits<const_iterator>::iterator_category
|
||||
const_iterator_category;
|
||||
typedef typename std::iterator_traits<const_iterator>::difference_type
|
||||
const_iterator_difference;
|
||||
typedef typename std::iterator_traits<const_iterator>::pointer
|
||||
const_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<const_iterator>::type
|
||||
typedef typename std::iterator_traits<const_iterator>::reference
|
||||
const_iterator_reference;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::BOOST_ITERATOR_CATEGORY<
|
||||
const_local_iterator>::type const_local_iterator_category;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_difference<
|
||||
const_local_iterator>::type const_local_iterator_difference;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_pointer<
|
||||
const_local_iterator>::type const_local_iterator_pointer;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_reference<
|
||||
const_local_iterator>::type const_local_iterator_reference;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::iterator_category
|
||||
const_local_iterator_category;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::difference_type
|
||||
const_local_iterator_difference;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::pointer
|
||||
const_local_iterator_pointer;
|
||||
typedef typename std::iterator_traits<const_local_iterator>::reference
|
||||
const_local_iterator_reference;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<Key, key_type>::value));
|
||||
// boost::function_requires<boost::CopyConstructibleConcept<key_type> >();
|
||||
@ -636,15 +709,15 @@ void unordered_copyable_test(X& x, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
{
|
||||
unordered_test(x, k, hf, eq);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
|
||||
X a;
|
||||
allocator_type m = a.get_allocator();
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::value_type* i = 0;
|
||||
BOOST_DEDUCED_TYPENAME X::value_type* j = 0;
|
||||
typename X::value_type* i = 0;
|
||||
typename X::value_type* j = 0;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -734,8 +807,8 @@ void unordered_copyable_test(X& x, Key& k, T& t, Hash& hf, Pred& eq)
|
||||
sink(a7a);
|
||||
sink(a9a);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::node_type node_type;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
node_type const n_const = a.extract(a.begin());
|
||||
test::check_return_type<allocator_type>::equals(n_const.get_allocator());
|
||||
}
|
||||
@ -745,9 +818,9 @@ void unordered_movable_test(X& x, Key& k, T& /* t */, Hash& hf, Pred& eq)
|
||||
{
|
||||
unordered_test(x, k, hf, eq);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
X x1(rvalue_default<X>());
|
||||
|
@ -25,9 +25,9 @@ namespace constructor_tests {
|
||||
template <class T>
|
||||
void constructor_tests1(T*, test::random_generator generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
typename T::allocator_type al;
|
||||
|
||||
UNORDERED_SUB_TEST("Construct 1")
|
||||
{
|
||||
@ -176,15 +176,15 @@ namespace constructor_tests {
|
||||
template <class T>
|
||||
void constructor_tests2(T*, test::random_generator const& generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq2(2);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
typename T::hasher hf;
|
||||
typename T::hasher hf1(1);
|
||||
typename T::hasher hf2(2);
|
||||
typename T::key_equal eq;
|
||||
typename T::key_equal eq1(1);
|
||||
typename T::key_equal eq2(2);
|
||||
typename T::allocator_type al;
|
||||
typename T::allocator_type al1(1);
|
||||
typename T::allocator_type al2(2);
|
||||
|
||||
UNORDERED_SUB_TEST("Construct 1")
|
||||
{
|
||||
@ -274,14 +274,11 @@ namespace constructor_tests {
|
||||
{
|
||||
test::check_instances check_;
|
||||
test::random_values<T> v(100, generator);
|
||||
BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator v_begin =
|
||||
v.begin(),
|
||||
v_end =
|
||||
v.end();
|
||||
typename test::random_values<T>::const_iterator v_begin = v.begin(),
|
||||
v_end = v.end();
|
||||
T x(test::input_iterator(v_begin), test::input_iterator(v_end), 0, hf1,
|
||||
eq1);
|
||||
BOOST_DEDUCED_TYPENAME T::const_iterator x_begin = x.begin(),
|
||||
x_end = x.end();
|
||||
typename T::const_iterator x_begin = x.begin(), x_end = x.end();
|
||||
T y(test::input_iterator(x_begin), test::input_iterator(x_end), 0, hf2,
|
||||
eq2);
|
||||
test::check_container(x, v);
|
||||
@ -320,7 +317,7 @@ namespace constructor_tests {
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||
std::initializer_list<BOOST_DEDUCED_TYPENAME T::value_type> list;
|
||||
std::initializer_list<typename T::value_type> list;
|
||||
|
||||
UNORDERED_SUB_TEST("Initializer list construct 1")
|
||||
{
|
||||
@ -386,8 +383,8 @@ namespace constructor_tests {
|
||||
template <class T>
|
||||
void map_constructor_test(T*, test::random_generator const& generator)
|
||||
{
|
||||
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME T::key_type,
|
||||
BOOST_DEDUCED_TYPENAME T::mapped_type> >
|
||||
typedef test::list<
|
||||
std::pair<typename T::key_type, typename T::mapped_type> >
|
||||
list;
|
||||
test::random_values<T> v(1000, generator);
|
||||
list l(v.begin(), v.end());
|
||||
|
@ -25,11 +25,11 @@ namespace copy_tests {
|
||||
template <class T>
|
||||
void copy_construct_tests1(T*, test::random_generator const& generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
typename T::allocator_type al;
|
||||
|
||||
{
|
||||
test::check_instances check_;
|
||||
@ -84,12 +84,12 @@ namespace copy_tests {
|
||||
template <class T>
|
||||
void copy_construct_tests2(T*, test::random_generator const& generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
typename T::hasher hf(1);
|
||||
typename T::key_equal eq(1);
|
||||
typename T::allocator_type al(1);
|
||||
typename T::allocator_type al2(2);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
352
test/unordered/deduction_tests.cpp
Normal file
352
test/unordered/deduction_tests.cpp
Normal file
@ -0,0 +1,352 @@
|
||||
|
||||
// Copyright 2017-2018 Daniel James.
|
||||
// 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)
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
struct hash_equals
|
||||
{
|
||||
template <typename T> bool operator()(T const& x) const
|
||||
{
|
||||
boost::hash<T> hf;
|
||||
return hf(x);
|
||||
}
|
||||
|
||||
template <typename T> bool operator()(T const& x, T const& y) const
|
||||
{
|
||||
std::equal_to<T> eq;
|
||||
return eq(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct test_allocator
|
||||
{
|
||||
typedef T value_type;
|
||||
test_allocator() = default;
|
||||
template <typename T2> test_allocator(test_allocator<T2> const&) {}
|
||||
T* allocate(std::size_t n) const { return (T*)malloc(sizeof(T) * n); }
|
||||
void deallocate(T* ptr, std::size_t) const { free(ptr); }
|
||||
bool operator==(test_allocator const&) { return true; }
|
||||
bool operator!=(test_allocator const&) { return false; }
|
||||
};
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES: "
|
||||
<< BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES << std::endl;
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
std::vector<std::pair<int, int> > x;
|
||||
x.push_back(std::make_pair(1, 3));
|
||||
x.push_back(std::make_pair(5, 10));
|
||||
test_allocator<std::pair<const int, int> > pair_allocator;
|
||||
hash_equals f;
|
||||
|
||||
// unordered_map
|
||||
|
||||
/*
|
||||
template<class InputIterator,
|
||||
class Hash = hash<iter_key_t<InputIterator>>,
|
||||
class Pred = equal_to<iter_key_t<InputIterator>>,
|
||||
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
|
||||
unordered_map(InputIterator, InputIterator, typename see below::size_type =
|
||||
see below,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
||||
Hash, Pred,
|
||||
Allocator>;
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end());
|
||||
static_assert(
|
||||
std::is_same<decltype(m), boost::unordered_map<int, int> >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous:
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
std::hash<int>>>::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>(),
|
||||
std::equal_to<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
std::hash<int>, std::equal_to<int>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), 0, std::hash<int>(),
|
||||
std::equal_to<int>(), pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
/*
|
||||
template<class Key, class T, class Hash = hash<Key>,
|
||||
class Pred = equal_to<Key>, class Allocator = allocator<pair<const
|
||||
Key, T>>>
|
||||
unordered_map(initializer_list<pair<const Key, T>>,
|
||||
typename see below::size_type = see below, Hash = Hash(),
|
||||
Pred = Pred(), Allocator = Allocator())
|
||||
-> unordered_map<Key, T, Hash, Pred, Allocator>;
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1, 2)});
|
||||
static_assert(
|
||||
std::is_same<decltype(m), boost::unordered_map<int, int> >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0,
|
||||
std::hash<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
std::hash<int>>>::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0,
|
||||
std::hash<int>(), std::equal_to<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
std::hash<int>, std::equal_to<int>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_map m(
|
||||
{std::pair<int const, int>(1, 2)}, 0, f, f, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_map<int, int, hash_equals, hash_equals,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
/*
|
||||
template<class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, typename see below::size_type,
|
||||
Allocator)
|
||||
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
||||
hash<iter_key_t<InputIterator>>,
|
||||
equal_to<iter_key_t<InputIterator>>,
|
||||
Allocator>;
|
||||
*/
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), 0u, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template<class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, Allocator)
|
||||
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
||||
hash<iter_key_t<InputIterator>>,
|
||||
equal_to<iter_key_t<InputIterator>>,
|
||||
Allocator>;
|
||||
*/
|
||||
|
||||
/* No constructor:
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template<class InputIterator, class Hash, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, typename see below::size_type,
|
||||
Hash, Allocator)
|
||||
-> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
|
||||
Hash,
|
||||
equal_to<iter_key_t<InputIterator>>, Allocator>;
|
||||
*/
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_map m(x.begin(), x.end(), 0u, f, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_map<int, int,
|
||||
hash_equals, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template<class Key, class T, typename Allocator>
|
||||
unordered_map(initializer_list<pair<const Key, T>>, typename see
|
||||
below::size_type,
|
||||
Allocator)
|
||||
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
|
||||
*/
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template<class Key, class T, typename Allocator>
|
||||
unordered_map(initializer_list<pair<const Key, T>>, Allocator)
|
||||
-> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>;
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1, 2)}, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_map<int, int, boost::hash<int>, std::equal_to<int>,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
/*
|
||||
template<class Key, class T, class Hash, class Allocator>
|
||||
unordered_map(initializer_list<pair<const Key, T>>, typename see
|
||||
below::size_type, Hash,
|
||||
Allocator)
|
||||
-> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>;
|
||||
*/
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_map m({std::pair<int const, int>(1,2)}, 0, f,
|
||||
pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_map<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
// unordered_multimap
|
||||
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end());
|
||||
static_assert(
|
||||
std::is_same<decltype(m), boost::unordered_multimap<int, int> >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous:
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
std::hash<int>>>::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>(),
|
||||
std::equal_to<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
std::hash<int>, std::equal_to<int>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), 0, std::hash<int>(),
|
||||
std::equal_to<int>(), pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_multimap m({std::pair<int const, int>(1, 2)});
|
||||
static_assert(
|
||||
std::is_same<decltype(m), boost::unordered_multimap<int, int> >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
|
||||
std::hash<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
std::hash<int>>>::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
|
||||
std::hash<int>(), std::equal_to<int>());
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
std::hash<int>, std::equal_to<int>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_multimap m(
|
||||
{std::pair<int const, int>(1, 2)}, 0, f, f, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_multimap<int, int, hash_equals, hash_equals,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), 0u, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/* No constructor:
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_multimap m(x.begin(), x.end(), 0u, f, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m), boost::unordered_multimap<int, int,
|
||||
hash_equals, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0,
|
||||
pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
boost::unordered_multimap m(
|
||||
{std::pair<int const, int>(1, 2)}, pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),
|
||||
boost::unordered_multimap<int, int, boost::hash<int>, std::equal_to<int>,
|
||||
test_allocator<std::pair<const int, int> > > >::value);
|
||||
}
|
||||
|
||||
/* Ambiguous
|
||||
{
|
||||
boost::unordered_multimap m({std::pair<int const, int>(1,2)}, 0, f,
|
||||
pair_allocator);
|
||||
static_assert(std::is_same<decltype(m),boost::unordered_multimap<int, int,
|
||||
boost::hash<int>, std::equal_to<int>, test_allocator<std::pair<const int,
|
||||
int>>>>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
}
|
@ -31,36 +31,36 @@ namespace equality_tests {
|
||||
};
|
||||
|
||||
#define UNORDERED_EQUALITY_SET_TEST(seq1, op, seq2) \
|
||||
do { \
|
||||
{ \
|
||||
boost::unordered_set<int, mod_compare, mod_compare> set1, set2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
|
||||
BOOST_TEST(set1 op set2); \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MULTISET_TEST(seq1, op, seq2) \
|
||||
do { \
|
||||
{ \
|
||||
boost::unordered_multiset<int, mod_compare, mod_compare> set1, set2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_SET_INSERT, set2, seq2) \
|
||||
BOOST_TEST(set1 op set2); \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MAP_TEST(seq1, op, seq2) \
|
||||
do { \
|
||||
{ \
|
||||
boost::unordered_map<int, int, mod_compare, mod_compare> map1, map2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
|
||||
BOOST_TEST(map1 op map2); \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
#define UNORDERED_EQUALITY_MULTIMAP_TEST(seq1, op, seq2) \
|
||||
do { \
|
||||
{ \
|
||||
boost::unordered_multimap<int, int, mod_compare, mod_compare> map1, map2; \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map1, seq1) \
|
||||
BOOST_PP_SEQ_FOR_EACH(UNORDERED_MAP_INSERT, map2, seq2) \
|
||||
BOOST_TEST(map1 op map2); \
|
||||
} while (0)
|
||||
}
|
||||
|
||||
#define UNORDERED_SET_INSERT(r, set, item) set.insert(item);
|
||||
#define UNORDERED_MAP_INSERT(r, map, item) \
|
||||
@ -89,46 +89,45 @@ namespace equality_tests {
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_key_value_tests) {
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2));
|
||||
UNORDERED_EQUALITY_SET_TEST((2), ==, (2));
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)));
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (2))
|
||||
UNORDERED_EQUALITY_SET_TEST((2), ==, (2))
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1))((2)(1)), !=, ((1)(1))((3)(1)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_collision_test) {
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (501));
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1)(251), !=, (1)(501));
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((251)(1))((1)(1)), !=, ((501)(1))((1)(1)));
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1)(501), ==, (1)(501));
|
||||
UNORDERED_EQUALITY_SET_TEST((1)(501), ==, (501)(1));
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1), !=, (501))
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1)(251), !=, (1)(501))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((251)(1))((1)(1)), !=, ((501)(1))((1)(1)))
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((1)(501), ==, (1)(501))
|
||||
UNORDERED_EQUALITY_SET_TEST((1)(501), ==, (501)(1))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_group_size_test) {
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((10)(20)(20), !=, (10)(10)(20));
|
||||
UNORDERED_EQUALITY_MULTISET_TEST((10)(20)(20), !=, (10)(10)(20))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((10)(1))((20)(1))((20)(1)), !=, ((10)(1))((20)(1))((10)(1)));
|
||||
((10)(1))((20)(1))((20)(1)), !=, ((10)(1))((20)(1))((10)(1)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(
|
||||
((20)(1))((10)(1))((10)(1)), ==, ((10)(1))((20)(1))((10)(1)));
|
||||
((20)(1))((10)(1))((10)(1)), ==, ((10)(1))((20)(1))((10)(1)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_map_value_test) {
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), !=, ((1)(2)));
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), ==, ((1)(1)));
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1)), !=, ((1)(2)));
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1))((1)(1)), !=, ((1)(1))((1)(2)));
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), ==, ((1)(1))((1)(2)));
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), !=, ((1)(1))((1)(3)));
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), !=, ((1)(2)))
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(1)), ==, ((1)(1)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1)), !=, ((1)(2)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(1))((1)(1)), !=, ((1)(1))((1)(2)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), ==, ((1)(1))((1)(2)))
|
||||
UNORDERED_EQUALITY_MULTIMAP_TEST(((1)(2))((1)(1)), !=, ((1)(1))((1)(3)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_predicate_test) {
|
||||
UNORDERED_EQUALITY_SET_TEST((1), !=, (1001));
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(2))((1001)(1)), !=, ((1001)(2))((1)(1)));
|
||||
UNORDERED_EQUALITY_SET_TEST((1), !=, (1001))
|
||||
UNORDERED_EQUALITY_MAP_TEST(((1)(2))((1001)(1)), !=, ((1001)(2))((1)(1)))
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (equality_multiple_group_test) {
|
||||
UNORDERED_EQUALITY_MULTISET_TEST(
|
||||
(1)(1)(1)(1001)(2001)(2001)(2)(1002)(3)(1003)(2003), ==,
|
||||
(3)(1003)(2003)(1002)(2)(2001)(2001)(1)(1001)(1)(1));
|
||||
(3)(1003)(2003)(1002)(2)(2001)(2001)(1)(1001)(1)(1))
|
||||
}
|
||||
|
||||
// Test that equality still works when the two containers have
|
||||
|
@ -27,8 +27,8 @@ namespace erase_tests {
|
||||
template <class Container>
|
||||
void erase_tests1(Container*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::const_iterator c_iterator;
|
||||
typedef typename Container::iterator iterator;
|
||||
typedef typename Container::const_iterator c_iterator;
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Erase by key.\n";
|
||||
{
|
||||
@ -37,8 +37,7 @@ namespace erase_tests {
|
||||
test::random_values<Container> v(1000, generator);
|
||||
Container x(v.begin(), v.end());
|
||||
int iterations = 0;
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<Container>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
std::size_t count = x.count(test::get_key<Container>(*it));
|
||||
std::size_t old_size = x.size();
|
||||
@ -60,8 +59,7 @@ namespace erase_tests {
|
||||
std::size_t size = x.size();
|
||||
int iterations = 0;
|
||||
while (size > 0 && !x.empty()) {
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*x.begin());
|
||||
typename Container::key_type key = test::get_key<Container>(*x.begin());
|
||||
std::size_t count = x.count(key);
|
||||
iterator pos = x.erase(x.begin());
|
||||
--size;
|
||||
@ -92,8 +90,7 @@ namespace erase_tests {
|
||||
pos = test::next(prev);
|
||||
}
|
||||
next = test::next(pos);
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*pos);
|
||||
typename Container::key_type key = test::get_key<Container>(*pos);
|
||||
std::size_t count = x.count(key);
|
||||
BOOST_TEST(count > 0);
|
||||
BOOST_TEST(next == x.erase(pos));
|
||||
@ -163,7 +160,7 @@ namespace erase_tests {
|
||||
test::next(iterators.begin(), start + length));
|
||||
|
||||
BOOST_TEST(x.size() == iterators.size() - 1);
|
||||
BOOST_DEDUCED_TYPENAME std::vector<c_iterator>::const_iterator i2 =
|
||||
typename std::vector<c_iterator>::const_iterator i2 =
|
||||
iterators.begin();
|
||||
for (c_iterator i1 = x.cbegin(); i1 != x.cend(); ++i1) {
|
||||
BOOST_TEST(i1 == *i2);
|
||||
@ -186,8 +183,7 @@ namespace erase_tests {
|
||||
std::size_t size = x.size();
|
||||
int iterations = 0;
|
||||
while (size > 0 && !x.empty()) {
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*x.begin());
|
||||
typename Container::key_type key = test::get_key<Container>(*x.begin());
|
||||
std::size_t count = x.count(key);
|
||||
x.quick_erase(x.begin());
|
||||
--size;
|
||||
@ -209,7 +205,7 @@ namespace erase_tests {
|
||||
int iterations = 0;
|
||||
while (size > 0 && !x.empty()) {
|
||||
std::size_t index = test::random_value(x.size());
|
||||
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
|
||||
typename Container::const_iterator prev, pos, next;
|
||||
if (index == 0) {
|
||||
prev = pos = x.begin();
|
||||
} else {
|
||||
@ -217,8 +213,7 @@ namespace erase_tests {
|
||||
pos = test::next(prev);
|
||||
}
|
||||
next = test::next(pos);
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*pos);
|
||||
typename Container::key_type key = test::get_key<Container>(*pos);
|
||||
std::size_t count = x.count(key);
|
||||
BOOST_TEST(count > 0);
|
||||
x.quick_erase(pos);
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "../helpers/test.hpp"
|
||||
#include "../helpers/tracker.hpp"
|
||||
#include "../objects/test.hpp"
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
namespace extract_tests {
|
||||
|
||||
@ -33,8 +32,7 @@ namespace extract_tests {
|
||||
test::random_values<Container> v(1000, generator);
|
||||
Container x(v.begin(), v.end());
|
||||
int iterations = 0;
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<Container>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<Container>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
std::size_t count = x.count(test::get_key<Container>(*it));
|
||||
std::size_t old_size = x.size();
|
||||
@ -65,8 +63,7 @@ namespace extract_tests {
|
||||
std::size_t size = x.size();
|
||||
int iterations = 0;
|
||||
while (size > 0 && !x.empty()) {
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*x.begin());
|
||||
typename Container::key_type key = test::get_key<Container>(*x.begin());
|
||||
std::size_t count = x.count(key);
|
||||
typename Container::node_type n = x.extract(x.begin());
|
||||
BOOST_TEST(n);
|
||||
@ -90,23 +87,21 @@ namespace extract_tests {
|
||||
while (size > 0 && !x.empty()) {
|
||||
using namespace std;
|
||||
int index = rand() % (int)x.size();
|
||||
BOOST_DEDUCED_TYPENAME Container::const_iterator prev, pos, next;
|
||||
typename Container::const_iterator prev, pos, next;
|
||||
if (index == 0) {
|
||||
prev = pos = x.begin();
|
||||
} else {
|
||||
prev = boost::next(x.begin(), index - 1);
|
||||
pos = boost::next(prev);
|
||||
prev = test::next(x.begin(), index - 1);
|
||||
pos = test::next(prev);
|
||||
}
|
||||
next = boost::next(pos);
|
||||
BOOST_DEDUCED_TYPENAME Container::key_type key =
|
||||
test::get_key<Container>(*pos);
|
||||
next = test::next(pos);
|
||||
typename Container::key_type key = test::get_key<Container>(*pos);
|
||||
std::size_t count = x.count(key);
|
||||
typename Container::node_type n = x.extract(pos);
|
||||
BOOST_TEST(n);
|
||||
--size;
|
||||
if (size > 0)
|
||||
BOOST_TEST(
|
||||
index == 0 ? next == x.begin() : next == boost::next(prev));
|
||||
BOOST_TEST(index == 0 ? next == x.begin() : next == test::next(prev));
|
||||
BOOST_TEST(x.count(key) == count - 1);
|
||||
BOOST_TEST(x.size() == size);
|
||||
if (++iterations % 20 == 0)
|
||||
|
@ -22,7 +22,7 @@ namespace find_tests {
|
||||
|
||||
template <class X> void find_tests1(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
{
|
||||
test::check_instances check_;
|
||||
@ -33,11 +33,10 @@ namespace find_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
tracker.insert_range(v.begin(), v.end());
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::ordered<X>::const_iterator it1 =
|
||||
tracker.begin();
|
||||
for (typename test::ordered<X>::const_iterator it1 = tracker.begin();
|
||||
it1 != tracker.end(); ++it1) {
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it1);
|
||||
BOOST_DEDUCED_TYPENAME X::const_iterator const_pos = x_const.find(key);
|
||||
typename X::key_type key = test::get_key<X>(*it1);
|
||||
typename X::const_iterator const_pos = x_const.find(key);
|
||||
iterator pos = x.find(key);
|
||||
BOOST_TEST(const_pos != x_const.end());
|
||||
BOOST_TEST(const_pos != x_const.end() &&
|
||||
@ -48,16 +47,15 @@ namespace find_tests {
|
||||
BOOST_TEST(x.count(key) == tracker.count(key));
|
||||
|
||||
test::compare_pairs(x.equal_range(key), tracker.equal_range(key),
|
||||
(BOOST_DEDUCED_TYPENAME X::value_type*)0);
|
||||
(typename X::value_type*)0);
|
||||
test::compare_pairs(x_const.equal_range(key), tracker.equal_range(key),
|
||||
(BOOST_DEDUCED_TYPENAME X::value_type*)0);
|
||||
(typename X::value_type*)0);
|
||||
}
|
||||
|
||||
test::random_values<X> v2(500, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it2 =
|
||||
v2.begin();
|
||||
for (typename test::random_values<X>::const_iterator it2 = v2.begin();
|
||||
it2 != v2.end(); ++it2) {
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it2);
|
||||
typename X::key_type key = test::get_key<X>(*it2);
|
||||
if (tracker.find(test::get_key<X>(key)) == tracker.end()) {
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
BOOST_TEST(x_const.find(key) == x_const.end());
|
||||
@ -74,10 +72,9 @@ namespace find_tests {
|
||||
X x;
|
||||
|
||||
test::random_values<X> v2(5, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator it3 =
|
||||
v2.begin();
|
||||
for (typename test::random_values<X>::const_iterator it3 = v2.begin();
|
||||
it3 != v2.end(); ++it3) {
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it3);
|
||||
typename X::key_type key = test::get_key<X>(*it3);
|
||||
BOOST_TEST(x.find(key) == x.end());
|
||||
BOOST_TEST(x.count(key) == 0);
|
||||
std::pair<iterator, iterator> range = x.equal_range(key);
|
||||
@ -116,8 +113,7 @@ namespace find_tests {
|
||||
template <class X>
|
||||
void find_compatible_keys_test(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator
|
||||
value_iterator;
|
||||
typedef typename test::random_values<X>::iterator value_iterator;
|
||||
test::random_values<X> v(500, generator);
|
||||
X x(v.begin(), v.end());
|
||||
|
||||
@ -125,14 +121,14 @@ namespace find_tests {
|
||||
compatible_predicate eq;
|
||||
|
||||
for (value_iterator it = v.begin(), end = v.end(); it != end; ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it);
|
||||
typename X::key_type key = test::get_key<X>(*it);
|
||||
BOOST_TEST(x.find(key) == x.find(compatible_key(key), h, eq));
|
||||
}
|
||||
|
||||
test::random_values<X> v2(20, generator);
|
||||
|
||||
for (value_iterator it = v2.begin(), end = v2.end(); it != end; ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::key_type key = test::get_key<X>(*it);
|
||||
typename X::key_type key = test::get_key<X>(*it);
|
||||
BOOST_TEST(x.find(key) == x.find(compatible_key(key), h, eq));
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace insert_tests {
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef test::ordered<X> ordered;
|
||||
|
||||
UNORDERED_SUB_TEST("insert(value) tests for containers with unique keys")
|
||||
@ -40,16 +40,14 @@ namespace insert_tests {
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
std::pair<iterator, bool> r1 = x.insert(*it);
|
||||
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
|
||||
tracker.insert(*it);
|
||||
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(r1.second == r2.second);
|
||||
BOOST_TEST(*r1.first == *r2.first);
|
||||
@ -71,17 +69,15 @@ namespace insert_tests {
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::value_type value = *it;
|
||||
std::pair<iterator, bool> r1 = x.insert(boost::move(value));
|
||||
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
|
||||
tracker.insert(*it);
|
||||
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(r1.second == r2.second);
|
||||
BOOST_TEST(*r1.first == *r2.first);
|
||||
@ -109,15 +105,13 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(*it);
|
||||
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
|
||||
tracker.insert(*it);
|
||||
typename X::iterator r1 = x.insert(*it);
|
||||
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(*r1 == *r2);
|
||||
|
||||
@ -138,16 +132,14 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::value_type value = *it;
|
||||
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.insert(boost::move(value));
|
||||
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
|
||||
tracker.insert(*it);
|
||||
typename X::iterator r1 = x.insert(boost::move(value));
|
||||
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(*r1 == *r2);
|
||||
|
||||
@ -164,10 +156,10 @@ namespace insert_tests {
|
||||
|
||||
template <class X> void insert_tests2(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME test::ordered<X> tracker_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::const_iterator const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME tracker_type::iterator tracker_iterator;
|
||||
typedef typename test::ordered<X> tracker_type;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef typename X::const_iterator const_iterator;
|
||||
typedef typename tracker_type::iterator tracker_iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("insert(begin(), value) tests")
|
||||
{
|
||||
@ -177,10 +169,9 @@ namespace insert_tests {
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator r1 = x.insert(x.begin(), *it);
|
||||
@ -206,10 +197,9 @@ namespace insert_tests {
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(100, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
const_iterator r1 = x.insert(x_const.end(), *it);
|
||||
@ -235,10 +225,9 @@ namespace insert_tests {
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
pos = x.insert(pos, *it);
|
||||
@ -264,10 +253,9 @@ namespace insert_tests {
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::value_type value = *it;
|
||||
@ -293,10 +281,9 @@ namespace insert_tests {
|
||||
tracker_type tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
x.insert(it, test::next(it));
|
||||
@ -349,10 +336,8 @@ namespace insert_tests {
|
||||
X x;
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator begin =
|
||||
v.begin(),
|
||||
end =
|
||||
v.end();
|
||||
typename test::random_values<X>::const_iterator begin = v.begin(),
|
||||
end = v.end();
|
||||
x.insert(test::input_iterator(begin), test::input_iterator(end));
|
||||
test::check_container(x, v);
|
||||
|
||||
@ -394,14 +379,12 @@ namespace insert_tests {
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end();) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count =
|
||||
x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator next = it;
|
||||
typename test::random_values<X>::iterator next = it;
|
||||
for (std::size_t j = test::random_value(20); j > 0; ++j) {
|
||||
++next;
|
||||
if (next == v.end()) {
|
||||
@ -428,7 +411,7 @@ namespace insert_tests {
|
||||
template <class X>
|
||||
void unique_emplace_tests1(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
typedef test::ordered<X> ordered;
|
||||
|
||||
X x;
|
||||
@ -436,15 +419,14 @@ namespace insert_tests {
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
std::pair<iterator, bool> r1 = x.emplace(*it);
|
||||
std::pair<BOOST_DEDUCED_TYPENAME ordered::iterator, bool> r2 =
|
||||
tracker.insert(*it);
|
||||
std::pair<typename ordered::iterator, bool> r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(r1.second == r2.second);
|
||||
BOOST_TEST(*r1.first == *r2.first);
|
||||
@ -467,14 +449,13 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::iterator r1 = x.emplace(*it);
|
||||
BOOST_DEDUCED_TYPENAME test::ordered<X>::iterator r2 =
|
||||
tracker.insert(*it);
|
||||
typename X::iterator r1 = x.emplace(*it);
|
||||
typename test::ordered<X>::iterator r2 = tracker.insert(*it);
|
||||
|
||||
BOOST_TEST(*r1 == *r2);
|
||||
|
||||
@ -497,10 +478,10 @@ namespace insert_tests {
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
typename X::value_type value = *it;
|
||||
@ -558,9 +539,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it = v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
x[it->first] = it->second;
|
||||
@ -579,7 +560,7 @@ namespace insert_tests {
|
||||
|
||||
template <class X> void map_tests2(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("insert_or_assign")
|
||||
{
|
||||
@ -589,10 +570,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
std::pair<iterator, bool> r = x.insert_or_assign(it->first, it->second);
|
||||
@ -618,10 +598,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator r = x.insert_or_assign(x.begin(), it->first, it->second);
|
||||
@ -647,10 +626,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator r = x.insert_or_assign(x.end(), it->first, it->second);
|
||||
@ -677,10 +655,9 @@ namespace insert_tests {
|
||||
iterator last = x.begin();
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator r = x.insert_or_assign(last, it->first, it->second);
|
||||
@ -704,7 +681,7 @@ namespace insert_tests {
|
||||
template <class X>
|
||||
void try_emplace_tests(X*, test::random_generator generator)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("try_emplace(key, value)")
|
||||
{
|
||||
@ -714,10 +691,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator pos = x.find(it->first);
|
||||
@ -745,7 +721,7 @@ namespace insert_tests {
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("try_emplace(begin(), key, value)")
|
||||
{
|
||||
@ -755,10 +731,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator pos = x.find(it->first);
|
||||
@ -783,7 +758,7 @@ namespace insert_tests {
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("try_emplace(end(), key, value)")
|
||||
{
|
||||
@ -793,10 +768,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator pos = x.find(it->first);
|
||||
@ -820,7 +794,7 @@ namespace insert_tests {
|
||||
test::check_equivalent_keys(x);
|
||||
}
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::iterator iterator;
|
||||
typedef typename X::iterator iterator;
|
||||
|
||||
UNORDERED_SUB_TEST("try_emplace(pos, key, value)")
|
||||
{
|
||||
@ -830,10 +804,9 @@ namespace insert_tests {
|
||||
test::ordered<X> tracker = test::create_ordered(x);
|
||||
|
||||
test::random_values<X> v(1000, generator);
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::iterator it =
|
||||
v.begin();
|
||||
for (typename test::random_values<X>::iterator it = v.begin();
|
||||
it != v.end(); ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_bucket_count = x.bucket_count();
|
||||
float b = x.max_load_factor();
|
||||
|
||||
iterator pos = x.find(it->first);
|
||||
@ -866,8 +839,8 @@ namespace insert_tests {
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
||||
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type,
|
||||
BOOST_DEDUCED_TYPENAME X::mapped_type> >
|
||||
typedef test::list<
|
||||
std::pair<typename X::key_type, typename X::mapped_type> >
|
||||
list;
|
||||
test::random_values<X> v(1000, generator);
|
||||
list l(v.begin(), v.end());
|
||||
@ -883,11 +856,11 @@ namespace insert_tests {
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
||||
typedef test::list<std::pair<BOOST_DEDUCED_TYPENAME X::key_type const,
|
||||
test::implicitly_convertible> >
|
||||
typedef test::list<
|
||||
std::pair<typename X::key_type const, test::implicitly_convertible> >
|
||||
list;
|
||||
test::random_values<boost::unordered_map<BOOST_DEDUCED_TYPENAME X::key_type,
|
||||
test::implicitly_convertible> >
|
||||
test::random_values<
|
||||
boost::unordered_map<typename X::key_type, test::implicitly_convertible> >
|
||||
v(1000, generator);
|
||||
list l(v.begin(), v.end());
|
||||
|
||||
|
@ -47,12 +47,11 @@ namespace load_factor_tests {
|
||||
|
||||
test::random_values<X> values(1000, generator);
|
||||
|
||||
for (BOOST_DEDUCED_TYPENAME test::random_values<X>::const_iterator
|
||||
it = values.begin(),
|
||||
end = values.end();
|
||||
for (typename test::random_values<X>::const_iterator it = values.begin(),
|
||||
end = values.end();
|
||||
it != end; ++it) {
|
||||
BOOST_DEDUCED_TYPENAME X::size_type old_size = x.size(),
|
||||
old_bucket_count = x.bucket_count();
|
||||
typename X::size_type old_size = x.size(),
|
||||
old_bucket_count = x.bucket_count();
|
||||
x.insert(*it);
|
||||
if (static_cast<double>(old_size + 1) <=
|
||||
b * static_cast<double>(old_bucket_count))
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "../helpers/test.hpp"
|
||||
#include "../helpers/tracker.hpp"
|
||||
#include "../objects/test.hpp"
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
namespace merge_tests {
|
||||
|
||||
@ -174,8 +173,8 @@ namespace merge_tests {
|
||||
|
||||
test::random_values<X1> v1(1000, generator);
|
||||
test::random_values<X2> v2(1000, generator);
|
||||
v1.insert(v2.begin(), boost::next(v2.begin(), 100));
|
||||
v2.insert(v1.begin(), boost::next(v1.begin(), 100));
|
||||
v1.insert(v2.begin(), test::next(v2.begin(), 100));
|
||||
v2.insert(v1.begin(), test::next(v1.begin(), 100));
|
||||
|
||||
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
|
||||
test::equal_to(hash_equal1));
|
||||
@ -207,8 +206,8 @@ namespace merge_tests {
|
||||
|
||||
test::random_values<X1> v1(1000, generator);
|
||||
test::random_values<X2> v2(1000, generator);
|
||||
v1.insert(v2.begin(), boost::next(v2.begin(), 100));
|
||||
v2.insert(v1.begin(), boost::next(v1.begin(), 100));
|
||||
v1.insert(v2.begin(), test::next(v2.begin(), 100));
|
||||
v2.insert(v1.begin(), test::next(v1.begin(), 100));
|
||||
|
||||
X1 x1(v1.begin(), v1.end(), 0, test::hash(hash_equal1),
|
||||
test::equal_to(hash_equal1));
|
||||
|
@ -4,7 +4,7 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "../objects/test.hpp"
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/unordered/detail/implementation.hpp>
|
||||
|
@ -43,8 +43,8 @@ namespace move_tests {
|
||||
|
||||
template <class T>
|
||||
T create(test::random_values<T> const& v, test::object_count& count,
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf, BOOST_DEDUCED_TYPENAME T::key_equal eq,
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al, float mlf)
|
||||
typename T::hasher hf, typename T::key_equal eq,
|
||||
typename T::allocator_type al, float mlf)
|
||||
{
|
||||
T x(0, hf, eq, al);
|
||||
x.max_load_factor(mlf);
|
||||
@ -56,9 +56,9 @@ namespace move_tests {
|
||||
template <class T>
|
||||
void move_construct_tests1(T* ptr, test::random_generator const& generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf;
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq;
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al;
|
||||
typename T::hasher hf;
|
||||
typename T::key_equal eq;
|
||||
typename T::allocator_type al;
|
||||
|
||||
{
|
||||
test::check_instances check_;
|
||||
@ -107,10 +107,10 @@ namespace move_tests {
|
||||
template <class T>
|
||||
void move_construct_tests2(T*, test::random_generator const& generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
typename T::hasher hf(1);
|
||||
typename T::key_equal eq(1);
|
||||
typename T::allocator_type al(1);
|
||||
typename T::allocator_type al2(2);
|
||||
|
||||
test::object_count count;
|
||||
|
||||
@ -180,11 +180,11 @@ namespace move_tests {
|
||||
template <class T>
|
||||
void move_assign_tests2(T*, test::random_generator const& generator)
|
||||
{
|
||||
BOOST_DEDUCED_TYPENAME T::hasher hf(1);
|
||||
BOOST_DEDUCED_TYPENAME T::key_equal eq(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al1(1);
|
||||
BOOST_DEDUCED_TYPENAME T::allocator_type al2(2);
|
||||
typedef BOOST_DEDUCED_TYPENAME T::allocator_type allocator_type;
|
||||
typename T::hasher hf(1);
|
||||
typename T::key_equal eq(1);
|
||||
typename T::allocator_type al1(1);
|
||||
typename T::allocator_type al2(2);
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
{
|
||||
test::random_values<T> v(500, generator);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "../helpers/helpers.hpp"
|
||||
#include "../helpers/metafunctions.hpp"
|
||||
#include "../helpers/test.hpp"
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <set>
|
||||
@ -146,24 +147,24 @@ UNORDERED_AUTO_TEST (failed_insertion_with_hint) {
|
||||
|
||||
template <typename NodeHandle>
|
||||
bool node_handle_compare(
|
||||
NodeHandle const& nh, BOOST_DEDUCED_TYPENAME NodeHandle::value_type const& x)
|
||||
NodeHandle const& nh, typename NodeHandle::value_type const& x)
|
||||
{
|
||||
return x == nh.value();
|
||||
}
|
||||
|
||||
template <typename NodeHandle>
|
||||
bool node_handle_compare(NodeHandle const& nh,
|
||||
std::pair<BOOST_DEDUCED_TYPENAME NodeHandle::key_type const,
|
||||
BOOST_DEDUCED_TYPENAME NodeHandle::mapped_type> const& x)
|
||||
bool node_handle_compare(
|
||||
NodeHandle const& nh, std::pair<typename NodeHandle::key_type const,
|
||||
typename NodeHandle::mapped_type> const& x)
|
||||
{
|
||||
return x.first == nh.key() && x.second == nh.mapped();
|
||||
}
|
||||
|
||||
template <typename Container> void node_handle_tests_impl(Container& c)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container::node_type node_type;
|
||||
typedef typename Container::node_type node_type;
|
||||
|
||||
BOOST_DEDUCED_TYPENAME Container::value_type value = *c.begin();
|
||||
typename Container::value_type value = *c.begin();
|
||||
|
||||
node_type n1;
|
||||
BOOST_TEST(!n1);
|
||||
@ -194,9 +195,9 @@ template <typename Container> void node_handle_tests_impl(Container& c)
|
||||
n3 = boost::move(n3);
|
||||
BOOST_TEST(!n3);
|
||||
|
||||
BOOST_DEDUCED_TYPENAME Container::value_type value1 = *c.begin();
|
||||
typename Container::value_type value1 = *c.begin();
|
||||
n1 = c.extract(c.begin());
|
||||
BOOST_DEDUCED_TYPENAME Container::value_type value2 = *c.begin();
|
||||
typename Container::value_type value2 = *c.begin();
|
||||
n2 = c.extract(c.begin());
|
||||
n3 = node_type();
|
||||
|
||||
@ -247,15 +248,13 @@ UNORDERED_AUTO_TEST (node_handle_tests) {
|
||||
template <typename Container1, typename Container2>
|
||||
void insert_node_handle_unique(Container1& c1, Container2& c2)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(boost::is_same<node_type,
|
||||
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
|
||||
typedef typename Container1::node_type node_type;
|
||||
typedef typename Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<node_type, typename Container2::node_type>::value));
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::insert_return_type
|
||||
insert_return_type1;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container2::insert_return_type
|
||||
insert_return_type2;
|
||||
typedef typename Container1::insert_return_type insert_return_type1;
|
||||
typedef typename Container2::insert_return_type insert_return_type2;
|
||||
|
||||
insert_return_type1 r1 = c1.insert(node_type());
|
||||
insert_return_type2 r2 = c2.insert(node_type());
|
||||
@ -268,14 +267,14 @@ void insert_node_handle_unique(Container1& c1, Container2& c2)
|
||||
|
||||
while (!c1.empty()) {
|
||||
value_type v = *c1.begin();
|
||||
value_type const* v_ptr = boost::addressof(*c1.begin());
|
||||
value_type const* v_ptr = boost::to_address(c1.begin());
|
||||
std::size_t count = c2.count(test::get_key<Container1>(v));
|
||||
insert_return_type2 r = c2.insert(c1.extract(c1.begin()));
|
||||
if (!count) {
|
||||
BOOST_TEST(r.inserted);
|
||||
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
|
||||
BOOST_TEST(r.position != c2.end());
|
||||
BOOST_TEST(boost::addressof(*r.position) == v_ptr);
|
||||
BOOST_TEST(boost::to_address(r.position) == v_ptr);
|
||||
BOOST_TEST(!r.node);
|
||||
} else {
|
||||
BOOST_TEST(!r.inserted);
|
||||
@ -292,25 +291,24 @@ void insert_node_handle_unique(Container1& c1, Container2& c2)
|
||||
template <typename Container1, typename Container2>
|
||||
void insert_node_handle_unique2(Container1& c1, Container2& c2)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(boost::is_same<node_type,
|
||||
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
|
||||
typedef typename Container1::node_type node_type;
|
||||
typedef typename Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<node_type, typename Container2::node_type>::value));
|
||||
|
||||
// typedef BOOST_DEDUCED_TYPENAME Container1::insert_return_type
|
||||
// typedef typename Container1::insert_return_type
|
||||
// insert_return_type1;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container2::insert_return_type
|
||||
insert_return_type2;
|
||||
typedef typename Container2::insert_return_type insert_return_type2;
|
||||
|
||||
while (!c1.empty()) {
|
||||
value_type v = *c1.begin();
|
||||
value_type const* v_ptr = boost::addressof(*c1.begin());
|
||||
value_type const* v_ptr = boost::to_address(c1.begin());
|
||||
std::size_t count = c2.count(test::get_key<Container1>(v));
|
||||
insert_return_type2 r = c2.insert(c1.extract(test::get_key<Container1>(v)));
|
||||
if (r.inserted) {
|
||||
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
|
||||
BOOST_TEST(r.position != c2.end());
|
||||
BOOST_TEST(boost::addressof(*r.position) == v_ptr);
|
||||
BOOST_TEST(boost::to_address(r.position) == v_ptr);
|
||||
BOOST_TEST(!r.node);
|
||||
} else {
|
||||
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count);
|
||||
@ -326,13 +324,13 @@ void insert_node_handle_unique2(Container1& c1, Container2& c2)
|
||||
template <typename Container1, typename Container2>
|
||||
void insert_node_handle_equiv(Container1& c1, Container2& c2)
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::node_type node_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(boost::is_same<node_type,
|
||||
BOOST_DEDUCED_TYPENAME Container2::node_type>::value);
|
||||
typedef typename Container1::node_type node_type;
|
||||
typedef typename Container1::value_type value_type;
|
||||
BOOST_STATIC_ASSERT(
|
||||
(boost::is_same<node_type, typename Container2::node_type>::value));
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME Container1::iterator iterator1;
|
||||
typedef BOOST_DEDUCED_TYPENAME Container2::iterator iterator2;
|
||||
typedef typename Container1::iterator iterator1;
|
||||
typedef typename Container2::iterator iterator2;
|
||||
|
||||
iterator1 r1 = c1.insert(node_type());
|
||||
iterator2 r2 = c2.insert(node_type());
|
||||
@ -341,12 +339,12 @@ void insert_node_handle_equiv(Container1& c1, Container2& c2)
|
||||
|
||||
while (!c1.empty()) {
|
||||
value_type v = *c1.begin();
|
||||
value_type const* v_ptr = boost::addressof(*c1.begin());
|
||||
value_type const* v_ptr = boost::to_address(c1.begin());
|
||||
std::size_t count = c2.count(test::get_key<Container1>(v));
|
||||
iterator2 r = c2.insert(c1.extract(c1.begin()));
|
||||
BOOST_TEST_EQ(c2.count(test::get_key<Container1>(v)), count + 1);
|
||||
BOOST_TEST(r != c2.end());
|
||||
BOOST_TEST(boost::addressof(*r) == v_ptr);
|
||||
BOOST_TEST(boost::to_address(r) == v_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,17 +12,31 @@
|
||||
|
||||
#include "../helpers/test.hpp"
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
// conditional expression is constant
|
||||
#pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
namespace noexcept_tests {
|
||||
// Test the noexcept is set correctly for the move constructor.
|
||||
|
||||
struct hash_possible_exception : boost::hash<int>
|
||||
{
|
||||
hash_possible_exception(hash_possible_exception const&) {}
|
||||
hash_possible_exception& operator=(hash_possible_exception const&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct equal_to_possible_exception : std::equal_to<int>
|
||||
{
|
||||
equal_to_possible_exception(equal_to_possible_exception const&) {}
|
||||
equal_to_possible_exception& operator=(equal_to_possible_exception const&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
// Test that the move constructor does actually move without throwing
|
||||
@ -42,25 +56,36 @@ namespace noexcept_tests {
|
||||
}
|
||||
}
|
||||
|
||||
class hash_nothrow_move : boost::hash<int>
|
||||
template <bool nothrow_move_construct, bool nothrow_move_assign,
|
||||
bool nothrow_swap>
|
||||
class hash_nothrow : boost::hash<int>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(hash_nothrow_move)
|
||||
BOOST_COPYABLE_AND_MOVABLE(hash_nothrow)
|
||||
|
||||
typedef boost::hash<int> base;
|
||||
|
||||
public:
|
||||
hash_nothrow_move(BOOST_RV_REF(hash_nothrow_move)) BOOST_NOEXCEPT {}
|
||||
hash_nothrow(BOOST_RV_REF(hash_nothrow))
|
||||
BOOST_NOEXCEPT_IF(nothrow_move_construct)
|
||||
{
|
||||
if (!nothrow_move_construct) {
|
||||
test_throw("Move Constructor");
|
||||
}
|
||||
}
|
||||
|
||||
hash_nothrow_move() { test_throw("Constructor"); }
|
||||
hash_nothrow_move(hash_nothrow_move const&) { test_throw("Copy"); }
|
||||
hash_nothrow_move& operator=(BOOST_COPY_ASSIGN_REF(hash_nothrow_move))
|
||||
hash_nothrow() { test_throw("Constructor"); }
|
||||
hash_nothrow(hash_nothrow const&) { test_throw("Copy"); }
|
||||
hash_nothrow& operator=(BOOST_COPY_ASSIGN_REF(hash_nothrow))
|
||||
{
|
||||
test_throw("Assign");
|
||||
return *this;
|
||||
}
|
||||
hash_nothrow_move& operator=(BOOST_RV_REF(hash_nothrow_move))
|
||||
hash_nothrow& operator=(BOOST_RV_REF(hash_nothrow))
|
||||
BOOST_NOEXCEPT_IF(nothrow_move_assign)
|
||||
{
|
||||
test_throw("Move Assign");
|
||||
if (!nothrow_move_assign) {
|
||||
test_throw("Move Assign");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
std::size_t operator()(int x) const
|
||||
@ -68,54 +93,109 @@ namespace noexcept_tests {
|
||||
test_throw("Operator");
|
||||
return static_cast<base const&>(*this)(x);
|
||||
}
|
||||
friend void swap(hash_nothrow&, hash_nothrow&)
|
||||
BOOST_NOEXCEPT_IF(nothrow_swap)
|
||||
{
|
||||
if (!nothrow_swap) {
|
||||
test_throw("Swap");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class equal_to_nothrow_move : std::equal_to<int>
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(equal_to_nothrow_move)
|
||||
typedef hash_nothrow<true, false, false> hash_nothrow_move_construct;
|
||||
typedef hash_nothrow<false, true, false> hash_nothrow_move_assign;
|
||||
typedef hash_nothrow<false, false, true> hash_nothrow_swap;
|
||||
|
||||
typedef std::equal_to<int> base;
|
||||
template <bool nothrow_move_construct, bool nothrow_move_assign,
|
||||
bool nothrow_swap>
|
||||
class equal_to_nothrow
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(equal_to_nothrow)
|
||||
|
||||
typedef boost::hash<int> base;
|
||||
|
||||
public:
|
||||
equal_to_nothrow_move(BOOST_RV_REF(equal_to_nothrow_move)) BOOST_NOEXCEPT {}
|
||||
equal_to_nothrow_move() { test_throw("Constructor"); }
|
||||
equal_to_nothrow_move(equal_to_nothrow_move const&) { test_throw("Copy"); }
|
||||
equal_to_nothrow_move& operator=(
|
||||
BOOST_COPY_ASSIGN_REF(equal_to_nothrow_move))
|
||||
equal_to_nothrow(BOOST_RV_REF(equal_to_nothrow))
|
||||
BOOST_NOEXCEPT_IF(nothrow_move_construct)
|
||||
{
|
||||
if (!nothrow_move_construct) {
|
||||
test_throw("Move Constructor");
|
||||
}
|
||||
}
|
||||
|
||||
equal_to_nothrow() { test_throw("Constructor"); }
|
||||
equal_to_nothrow(equal_to_nothrow const&) { test_throw("Copy"); }
|
||||
equal_to_nothrow& operator=(BOOST_COPY_ASSIGN_REF(equal_to_nothrow))
|
||||
{
|
||||
test_throw("Assign");
|
||||
return *this;
|
||||
}
|
||||
equal_to_nothrow_move& operator=(BOOST_RV_REF(equal_to_nothrow_move))
|
||||
equal_to_nothrow& operator=(BOOST_RV_REF(equal_to_nothrow))
|
||||
BOOST_NOEXCEPT_IF(nothrow_move_assign)
|
||||
{
|
||||
test_throw("Move Assign");
|
||||
if (!nothrow_move_assign) {
|
||||
test_throw("Move Assign");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
std::size_t operator()(int x, int y) const
|
||||
{
|
||||
test_throw("Operator");
|
||||
return static_cast<base const&>(*this)(x, y);
|
||||
return x == y;
|
||||
}
|
||||
friend void swap(equal_to_nothrow&, equal_to_nothrow&)
|
||||
BOOST_NOEXCEPT_IF(nothrow_swap)
|
||||
{
|
||||
if (!nothrow_swap) {
|
||||
test_throw("Swap");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef equal_to_nothrow<true, false, false> equal_to_nothrow_move_construct;
|
||||
typedef equal_to_nothrow<false, true, false> equal_to_nothrow_move_assign;
|
||||
typedef equal_to_nothrow<false, false, true> equal_to_nothrow_swap;
|
||||
|
||||
bool have_is_nothrow_move = false;
|
||||
bool have_is_nothrow_move_assign = false;
|
||||
bool have_is_nothrow_swap = false;
|
||||
|
||||
UNORDERED_AUTO_TEST (check_is_nothrow_move) {
|
||||
BOOST_TEST(
|
||||
!boost::is_nothrow_move_constructible<hash_possible_exception>::value);
|
||||
have_is_nothrow_move =
|
||||
boost::is_nothrow_move_constructible<hash_nothrow_move>::value;
|
||||
BOOST_TEST(
|
||||
!boost::is_nothrow_move_assignable<hash_possible_exception>::value);
|
||||
BOOST_TEST(!boost::is_nothrow_swappable<hash_possible_exception>::value);
|
||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||
equal_to_nothrow<false, false, false> >::value));
|
||||
BOOST_TEST((!boost::is_nothrow_move_assignable<
|
||||
equal_to_nothrow<false, false, false> >::value));
|
||||
BOOST_TEST((!boost::is_nothrow_swappable<
|
||||
equal_to_nothrow<false, false, false> >::value));
|
||||
|
||||
// Copied from boost::is_nothrow_move_constructible implementation
|
||||
// to make sure this does actually detect it when expected.
|
||||
//
|
||||
// The type trait is also available when BOOST_IS_NOTHROW_MOVE_CONSTRUCT
|
||||
// is defined (for some versions of Visual C++?) but detects 'throw()',
|
||||
// not noexcept.
|
||||
have_is_nothrow_move =
|
||||
boost::is_nothrow_move_constructible<hash_nothrow_move_construct>::value;
|
||||
have_is_nothrow_move_assign =
|
||||
boost::is_nothrow_move_assignable<hash_nothrow_move_assign>::value;
|
||||
have_is_nothrow_swap =
|
||||
boost::is_nothrow_swappable<hash_nothrow_swap>::value;
|
||||
|
||||
// Check that the traits work when expected.
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && \
|
||||
!BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
|
||||
BOOST_TEST(have_is_nothrow_move);
|
||||
BOOST_TEST(have_is_nothrow_move_assign);
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_NOEXCEPT) && \
|
||||
!defined(BOOST_NO_CXX11_DECLTYPE) && \
|
||||
!defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
||||
BOOST_TEST(have_is_nothrow_swap);
|
||||
#endif
|
||||
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< "have_is_nothrow_move: " << have_is_nothrow_move << std::endl
|
||||
<< "have_is_nothrow_swap: " << have_is_nothrow_swap << std::endl;
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_noexcept) {
|
||||
@ -137,32 +217,104 @@ namespace noexcept_tests {
|
||||
boost::hash<int>, equal_to_possible_exception> >::value));
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_no_throw_when_noexcept) {
|
||||
typedef boost::unordered_set<int, hash_nothrow_move, equal_to_nothrow_move>
|
||||
UNORDERED_AUTO_TEST (test_nothrow_move_when_noexcept) {
|
||||
typedef boost::unordered_set<int, hash_nothrow_move_construct,
|
||||
equal_to_nothrow_move_construct>
|
||||
throwing_set;
|
||||
|
||||
if (have_is_nothrow_move) {
|
||||
BOOST_TEST(boost::is_nothrow_move_constructible<throwing_set>::value);
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
throwing_set x2 = boost::move(x1);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
} catch (test_exception) {
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
throwing_set x2 = boost::move(x1);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
BOOST_TEST(have_is_nothrow_move);
|
||||
} catch (test_exception) {
|
||||
BOOST_TEST(!have_is_nothrow_move);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_nothrow_move_assign_when_noexcept) {
|
||||
typedef boost::unordered_set<int, hash_nothrow_move_assign,
|
||||
equal_to_nothrow_move_assign>
|
||||
throwing_set;
|
||||
|
||||
if (have_is_nothrow_move_assign) {
|
||||
BOOST_TEST(boost::is_nothrow_move_assignable<throwing_set>::value);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
throwing_set x2;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
x2.insert(i);
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
x2 = boost::move(x1);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
BOOST_TEST(have_is_nothrow_move_assign);
|
||||
} catch (test_exception) {
|
||||
BOOST_TEST(!have_is_nothrow_move_assign);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_nothrow_swap_when_noexcept) {
|
||||
typedef boost::unordered_set<int, hash_nothrow_swap, equal_to_nothrow_swap>
|
||||
throwing_set;
|
||||
|
||||
if (have_is_nothrow_swap) {
|
||||
BOOST_TEST(boost::is_nothrow_swappable<throwing_set>::value);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
throwing_set x2;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
x2.insert(i);
|
||||
}
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
x1.swap(x2);
|
||||
BOOST_TEST(x1.size() == 100);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
BOOST_TEST(have_is_nothrow_swap);
|
||||
} catch (test_exception) {
|
||||
BOOST_TEST(!have_is_nothrow_swap);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
RUN_TESTS()
|
||||
|
@ -20,8 +20,7 @@ namespace rehash_tests {
|
||||
|
||||
test::seed_t initialize_seed(2974);
|
||||
|
||||
template <class X>
|
||||
bool postcondition(X const& x, BOOST_DEDUCED_TYPENAME X::size_type n)
|
||||
template <class X> bool postcondition(X const& x, typename X::size_type n)
|
||||
{
|
||||
return static_cast<double>(x.bucket_count()) >=
|
||||
static_cast<double>(x.size()) / x.max_load_factor() &&
|
||||
|
@ -73,7 +73,7 @@ template <class X> void simple_test(X const& a)
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(a.size() == static_cast<BOOST_DEDUCED_TYPENAME X::size_type>(
|
||||
BOOST_TEST(a.size() == static_cast<typename X::size_type>(
|
||||
std::distance(a.begin(), a.end())));
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ namespace swap_tests {
|
||||
{
|
||||
swap_tests1(ptr, generator);
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME X::hasher hasher;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::key_equal key_equal;
|
||||
typedef BOOST_DEDUCED_TYPENAME X::allocator_type allocator_type;
|
||||
typedef typename X::hasher hasher;
|
||||
typedef typename X::key_equal key_equal;
|
||||
typedef typename X::allocator_type allocator_type;
|
||||
|
||||
{
|
||||
test::check_instances check_;
|
||||
|
@ -177,7 +177,7 @@ namespace unnecessary_copy_tests {
|
||||
template <class T> void unnecessary_copy_insert_test(T*)
|
||||
{
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
reset();
|
||||
x.insert(a);
|
||||
COPY_COUNT(1);
|
||||
@ -187,13 +187,13 @@ namespace unnecessary_copy_tests {
|
||||
template <class T> void unnecessary_copy_insert_rvalue_set_test(T*)
|
||||
{
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
reset();
|
||||
x.insert(boost::move(a));
|
||||
COPY_COUNT(0);
|
||||
MOVE_COUNT(1);
|
||||
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a2;
|
||||
typename T::value_type a2;
|
||||
reset();
|
||||
x.insert(boost::move(a));
|
||||
COPY_COUNT(0);
|
||||
@ -207,7 +207,7 @@ namespace unnecessary_copy_tests {
|
||||
// construct_from_args.
|
||||
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
reset();
|
||||
x.insert(boost::move(a));
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
@ -218,7 +218,7 @@ namespace unnecessary_copy_tests {
|
||||
MOVE_COUNT(1);
|
||||
#endif
|
||||
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a2;
|
||||
typename T::value_type a2;
|
||||
reset();
|
||||
x.insert(boost::move(a));
|
||||
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
@ -243,7 +243,7 @@ namespace unnecessary_copy_tests {
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
COPY_COUNT(1);
|
||||
x.emplace(a);
|
||||
COPY_COUNT(2);
|
||||
@ -253,7 +253,7 @@ namespace unnecessary_copy_tests {
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
|
||||
x.emplace(source<typename T::value_type>());
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
COPY_COUNT(1);
|
||||
#else
|
||||
@ -271,7 +271,7 @@ namespace unnecessary_copy_tests {
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
COPY_COUNT(1);
|
||||
MOVE_COUNT(0);
|
||||
x.emplace(std::move(a));
|
||||
@ -287,7 +287,7 @@ namespace unnecessary_copy_tests {
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
COPY_COUNT(1);
|
||||
MOVE_COUNT_EXTRA(0, 1);
|
||||
x.emplace(boost::move(a));
|
||||
@ -308,7 +308,7 @@ namespace unnecessary_copy_tests {
|
||||
{
|
||||
reset();
|
||||
T x;
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
COPY_COUNT(1);
|
||||
MOVE_COUNT(0);
|
||||
x.emplace(boost::move(a));
|
||||
@ -325,7 +325,7 @@ namespace unnecessary_copy_tests {
|
||||
T x;
|
||||
COPY_COUNT(0);
|
||||
MOVE_COUNT(0);
|
||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||
typename T::value_type a;
|
||||
COPY_COUNT(1);
|
||||
MOVE_COUNT_EXTRA(0, 1);
|
||||
x.emplace(boost::move(a));
|
||||
|
Reference in New Issue
Block a user