Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed heterogeneous lookup for side collections #42

Merged
merged 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 33 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,123 +18,126 @@ jobs:
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
cxxstd: "11,14,17"
os: ubuntu-20.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
cxxstd: "11,14,17,20"
os: ubuntu-20.04
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "03,11,14,17,20,2b"
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17"
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxstd: "11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
os: macos-11
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
cxxstd: "11,14,17,20,2b"
os: macos-12

runs-on: ${{matrix.os}}
Expand All @@ -151,7 +154,7 @@ jobs:
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python git g++
apt-get -y install sudo python3 git g++

- name: Install packages
if: matrix.install
Expand All @@ -175,7 +178,7 @@ jobs:
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py -I example --git_args "--jobs 3" $LIBRARY
python3 tools/boostdep/depinst/depinst.py -I example --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers

Expand Down Expand Up @@ -212,7 +215,7 @@ jobs:
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019

Expand Down
9 changes: 3 additions & 6 deletions doc/reference/set_of.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ look at it as a whole, you will be using a set view.

iterator ``[link reference_set_of_erase_iterator erase]``(iterator position);

template< class CompatibleKey >
size_type ``[link reference_set_of_erase_key erase]``(const CompatibleKey & x);
size_type ``[link reference_set_of_erase_key erase]``(const key_type & x);

iterator ``[link reference_set_of_erase_iterator_iterator erase]``(iterator first, iterator last);

Expand Down Expand Up @@ -472,10 +471,8 @@ the one that was deleted, or `end()` if no such element exists.

[#reference_set_of_erase_key]

template< class CompatibleKey >
size_type erase(const CompatibleKey & x);
size_type erase(const key_type & x);

* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
* [*Effects:] Deletes the elements with key equivalent to `x`.
* [*Returns:] Number of elements deleted.
* [link set_of_complexity_signature
Expand Down Expand Up @@ -826,7 +823,7 @@ They are only provided if the other collection type is mutable
template< class CompatibleKey >
mapped_type & operator[](const CompatibleKey & k);

* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. `key_type` is constructible from `const CompatibleKey &`.
* [*Effects: ] `return insert(value_type(k,mapped_type()))->second;`
* [*Complexity:] O(log(n)).
* [*Note:] Only provided when `set_of` is used and the other collection
Expand Down
8 changes: 3 additions & 5 deletions doc/reference/unordered_set_of.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ do not exactly conform to the requirements for unordered associative containers.

iterator ``[link reference_unordered_set_of_erase_iterator erase]``(iterator position);

template< class CompatibleKey >
size_type ``[link reference_unordered_set_of_erase_key erase]``(const CompatibleKey & x);
size_type ``[link reference_unordered_set_of_erase_key erase]``(const key_type & x);

iterator ``[link reference_unordered_set_of_erase_iterator_iterator erase]``(iterator first, iterator last);

Expand Down Expand Up @@ -447,8 +446,7 @@ that was deleted, or `end()` if no such element exists.

[#reference_unordered_set_of_erase_key]

template< class CompatibleKey >
size_type erase(const CompatibleKey & x);
size_type erase(const key_type & x);

* [*Effects:] Deletes the elements with key equivalent to `x`.
* [*Returns:] Number of elements deleted.
Expand Down Expand Up @@ -704,7 +702,7 @@ They are only provided if the other collection type is mutable
template< class CompatibleKey >
mapped_type & operator[](const CompatibleKey & k);

* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
* [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`. `key_type` is constructible from `const CompatibleKey &`.
* [*Effects: ] `return insert(value_type(k,mapped_type()))->second;`
* [*Complexity:] If the insertion is performed O(I(n)), else: Average case
O(1) (constant), worst case O(n).
Expand Down
4 changes: 4 additions & 0 deletions doc/release_notes.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ http://www.boost.org/LICENSE_1_0.txt)

[section Release notes]

[heading Boost 1.85 release]

* Fixed heterogeneous lookup for side collections ([@https://github.com/boostorg/bimap/pull/42 PR#42]).

[heading Boost 1.53 release]

* Refactor map_view_iterator to improve error messages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Boost.Bimap
//
// Copyright (c) 2006-2007 Matias Capeletto
// Copyright (c) 2024 Joaquin M Lopez Munoz
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -166,7 +167,7 @@ struct key_to_base_identity
#ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES

template< class Key >
struct key_to_base_identity< Key, Key >
struct key_to_base_identity< Key, const Key >
{
// As default accept any type as key in order to allow container
// adaptors to work with compatible key types
Expand Down
63 changes: 63 additions & 0 deletions test/strong_type.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Boost.Bimap
//
// Copyright (c) 2024 Joaquin M Lopez Munoz
//
// 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)

#ifndef LIBS_BIMAP_TEST_STRONG_TYPE_HPP
#define LIBS_BIMAP_TEST_STRONG_TYPE_HPP

#if defined(_MSC_VER)
#pragma once
#endif

#include <boost/container_hash/hash.hpp>

// std
#include <cstddef>
#include <stdexcept>

template< class T >
struct strong
{
template< class Q >
strong(const Q& x_):x(x_){}

T x;
};

template< class T >
bool operator<(const strong<T>& x,const strong<T>& y)
{
return x.x<y.x;
}

template< class T >
bool operator==(const strong<T>& x,const strong<T>& y)
{
return x.x==y.x;
}

template< class T >
std::size_t hash_value(const strong<T>& x)
{
return boost::hash<T>()(x.x);
}

template< class T >
struct semistrong: strong<T>
{
using strong<T>::strong;

// semistrong<T> is formally convertible to T but throws when
// conversion actually called

operator const T&() const
{
throw std::runtime_error("semistrong<T> -> T conversion called");
}
};

#endif // LIBS_BIMAP_TEST_STRONG_TYPE_HPP