mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 19:37:14 +02:00
Forward headers for the unordered containers.
[SVN r48802]
This commit is contained in:
53
include/boost/unordered/unordered_map_fwd.hpp
Normal file
53
include/boost/unordered/unordered_map_fwd.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
// Copyright (C) 2008 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)
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED
|
||||||
|
#define BOOST_UNORDERED_MAP_FWD_HPP_INCLUDED
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <boost/functional/hash_fwd.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template <class Key,
|
||||||
|
class T,
|
||||||
|
class Hash = hash<Key>,
|
||||||
|
class Pred = std::equal_to<Key>,
|
||||||
|
class Alloc = std::allocator<std::pair<const Key, T> > >
|
||||||
|
class unordered_map;
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
bool operator==(unordered_map<K, T, H, P, A> const&,
|
||||||
|
unordered_map<K, T, H, P, A> const&);
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
bool operator!=(unordered_map<K, T, H, P, A> const&,
|
||||||
|
unordered_map<K, T, H, P, A> const&);
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
void swap(unordered_map<K, T, H, P, A>&,
|
||||||
|
unordered_map<K, T, H, P, A>&);
|
||||||
|
|
||||||
|
template <class Key,
|
||||||
|
class T,
|
||||||
|
class Hash = hash<Key>,
|
||||||
|
class Pred = std::equal_to<Key>,
|
||||||
|
class Alloc = std::allocator<std::pair<const Key, T> > >
|
||||||
|
class unordered_multimap;
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
bool operator==(unordered_multimap<K, T, H, P, A> const&,
|
||||||
|
unordered_multimap<K, T, H, P, A> const&);
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
bool operator!=(unordered_multimap<K, T, H, P, A> const&,
|
||||||
|
unordered_multimap<K, T, H, P, A> const&);
|
||||||
|
template <class K, class T, class H, class P, class A>
|
||||||
|
void swap(unordered_multimap<K, T, H, P, A>&,
|
||||||
|
unordered_multimap<K, T, H, P, A>&);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
include/boost/unordered/unordered_set_fwd.hpp
Normal file
51
include/boost/unordered/unordered_set_fwd.hpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
// Copyright (C) 2008 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)
|
||||||
|
|
||||||
|
#ifndef BOOST_UNORDERED_SET_FWD_HPP_INCLUDED
|
||||||
|
#define BOOST_UNORDERED_SET_FWD_HPP_INCLUDED
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <boost/functional/hash_fwd.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template <class Value,
|
||||||
|
class Hash = hash<Value>,
|
||||||
|
class Pred = std::equal_to<Value>,
|
||||||
|
class Alloc = std::allocator<Value> >
|
||||||
|
class unordered_set;
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
bool operator==(unordered_set<T, H, P, A> const&,
|
||||||
|
unordered_set<T, H, P, A> const&);
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
bool operator!=(unordered_set<T, H, P, A> const&,
|
||||||
|
unordered_set<T, H, P, A> const&);
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
void swap(unordered_set<T, H, P, A> &m1,
|
||||||
|
unordered_set<T, H, P, A> &m2);
|
||||||
|
|
||||||
|
template <class Value,
|
||||||
|
class Hash = hash<Value>,
|
||||||
|
class Pred = std::equal_to<Value>,
|
||||||
|
class Alloc = std::allocator<Value> >
|
||||||
|
class unordered_multiset;
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
bool operator==(unordered_multiset<T, H, P, A> const&,
|
||||||
|
unordered_multiset<T, H, P, A> const&);
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
bool operator!=(unordered_multiset<T, H, P, A> const&,
|
||||||
|
unordered_multiset<T, H, P, A> const&);
|
||||||
|
template <class T, class H, class P, class A>
|
||||||
|
void swap(unordered_multiset<T, H, P, A> &m1,
|
||||||
|
unordered_multiset<T, H, P, A> &m2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -13,11 +13,7 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/unordered/unordered_map_fwd.hpp>
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <boost/unordered/detail/hash_table.hpp>
|
#include <boost/unordered/detail/hash_table.hpp>
|
||||||
|
|
||||||
@ -27,38 +23,6 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template <class Key,
|
|
||||||
class T,
|
|
||||||
class Hash = hash<Key>,
|
|
||||||
class Pred = std::equal_to<Key>,
|
|
||||||
class Alloc = std::allocator<std::pair<const Key, T> > >
|
|
||||||
class unordered_map;
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
bool operator==(unordered_map<K, T, H, P, A> const&,
|
|
||||||
unordered_map<K, T, H, P, A> const&);
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
bool operator!=(unordered_map<K, T, H, P, A> const&,
|
|
||||||
unordered_map<K, T, H, P, A> const&);
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
void swap(unordered_map<K, T, H, P, A>&,
|
|
||||||
unordered_map<K, T, H, P, A>&);
|
|
||||||
|
|
||||||
template <class Key,
|
|
||||||
class T,
|
|
||||||
class Hash = hash<Key>,
|
|
||||||
class Pred = std::equal_to<Key>,
|
|
||||||
class Alloc = std::allocator<std::pair<const Key, T> > >
|
|
||||||
class unordered_multimap;
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
bool operator==(unordered_multimap<K, T, H, P, A> const&,
|
|
||||||
unordered_multimap<K, T, H, P, A> const&);
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
bool operator!=(unordered_multimap<K, T, H, P, A> const&,
|
|
||||||
unordered_multimap<K, T, H, P, A> const&);
|
|
||||||
template <class K, class T, class H, class P, class A>
|
|
||||||
void swap(unordered_multimap<K, T, H, P, A>&,
|
|
||||||
unordered_multimap<K, T, H, P, A>&);
|
|
||||||
|
|
||||||
template <class Key, class T, class Hash, class Pred, class Alloc>
|
template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||||
class unordered_map
|
class unordered_map
|
||||||
{
|
{
|
||||||
|
@ -13,11 +13,7 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/unordered/unordered_set_fwd.hpp>
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
#include <boost/unordered/detail/hash_table.hpp>
|
#include <boost/unordered/detail/hash_table.hpp>
|
||||||
|
|
||||||
@ -27,36 +23,6 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template <class Value,
|
|
||||||
class Hash = hash<Value>,
|
|
||||||
class Pred = std::equal_to<Value>,
|
|
||||||
class Alloc = std::allocator<Value> >
|
|
||||||
class unordered_set;
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
bool operator==(unordered_set<T, H, P, A> const&,
|
|
||||||
unordered_set<T, H, P, A> const&);
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
bool operator!=(unordered_set<T, H, P, A> const&,
|
|
||||||
unordered_set<T, H, P, A> const&);
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
void swap(unordered_set<T, H, P, A> &m1,
|
|
||||||
unordered_set<T, H, P, A> &m2);
|
|
||||||
|
|
||||||
template <class Value,
|
|
||||||
class Hash = hash<Value>,
|
|
||||||
class Pred = std::equal_to<Value>,
|
|
||||||
class Alloc = std::allocator<Value> >
|
|
||||||
class unordered_multiset;
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
bool operator==(unordered_multiset<T, H, P, A> const&,
|
|
||||||
unordered_multiset<T, H, P, A> const&);
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
bool operator!=(unordered_multiset<T, H, P, A> const&,
|
|
||||||
unordered_multiset<T, H, P, A> const&);
|
|
||||||
template <class T, class H, class P, class A>
|
|
||||||
void swap(unordered_multiset<T, H, P, A> &m1,
|
|
||||||
unordered_multiset<T, H, P, A> &m2);
|
|
||||||
|
|
||||||
template <class Value, class Hash, class Pred, class Alloc>
|
template <class Value, class Hash, class Pred, class Alloc>
|
||||||
class unordered_set
|
class unordered_set
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,8 @@ project unordered-test/unordered
|
|||||||
|
|
||||||
test-suite unordered
|
test-suite unordered
|
||||||
:
|
:
|
||||||
|
[ run fwd_set_test.cpp ]
|
||||||
|
[ run fwd_map_test.cpp ]
|
||||||
[ run compile_set.cpp ]
|
[ run compile_set.cpp ]
|
||||||
[ run compile_map.cpp ]
|
[ run compile_map.cpp ]
|
||||||
[ run link_test_1.cpp link_test_2.cpp ]
|
[ run link_test_1.cpp link_test_2.cpp ]
|
||||||
|
62
test/unordered/fwd_map_test.cpp
Normal file
62
test/unordered/fwd_map_test.cpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
// Copyright 2008 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/unordered_map_fwd.hpp>
|
||||||
|
|
||||||
|
typedef boost::unordered_map<int, int> int_map;
|
||||||
|
|
||||||
|
void call_swap(int_map& x, int_map& y) {
|
||||||
|
swap(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_equals(int_map& x, int_map& y) {
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_not_equals(int_map& x, int_map& y) {
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef boost::unordered_multimap<int, int> int_multimap;
|
||||||
|
|
||||||
|
void call_swap(int_multimap& x, int_multimap& y) {
|
||||||
|
swap(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_equals(int_multimap& x, int_multimap& y) {
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_not_equals(int_multimap& x, int_multimap& y) {
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/unordered_map.hpp>
|
||||||
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_map_fwd_declared_function) {
|
||||||
|
int_map x, y;
|
||||||
|
x[1] = 2;
|
||||||
|
y[2] = 1;
|
||||||
|
call_swap(x, y);
|
||||||
|
|
||||||
|
BOOST_CHECK(y.find(1) != y.end() && y.find(1)->second == 2);
|
||||||
|
BOOST_CHECK(y.find(2) == y.end());
|
||||||
|
|
||||||
|
BOOST_CHECK(x.find(1) == x.end());
|
||||||
|
BOOST_CHECK(x.find(2) != x.end() && x.find(2)->second == 1);
|
||||||
|
|
||||||
|
BOOST_CHECK(!call_equals(x, y));
|
||||||
|
BOOST_CHECK(call_not_equals(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_multimap_fwd_declared_function) {
|
||||||
|
int_multimap x, y;
|
||||||
|
call_swap(x, y);
|
||||||
|
BOOST_CHECK(call_equals(x, y));
|
||||||
|
BOOST_CHECK(!call_not_equals(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
84
test/unordered/fwd_set_test.cpp
Normal file
84
test/unordered/fwd_set_test.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
// Copyright 2008 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/unordered_set_fwd.hpp>
|
||||||
|
|
||||||
|
struct true_type { char x[100]; };
|
||||||
|
struct false_type { char x; };
|
||||||
|
|
||||||
|
false_type is_unordered_set_impl(void*);
|
||||||
|
|
||||||
|
template <class Value, class Hash, class Pred, class Alloc>
|
||||||
|
true_type is_unordered_set_impl(
|
||||||
|
boost::unordered_set<Value, Hash, Pred, Alloc>*);
|
||||||
|
|
||||||
|
typedef boost::unordered_set<int> int_set;
|
||||||
|
|
||||||
|
void call_swap(int_set& x, int_set& y) {
|
||||||
|
swap(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_equals(int_set& x, int_set& y) {
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_not_equals(int_set& x, int_set& y) {
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef boost::unordered_multiset<int> int_multiset;
|
||||||
|
|
||||||
|
void call_swap(int_multiset& x, int_multiset& y) {
|
||||||
|
swap(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_equals(int_multiset& x, int_multiset& y) {
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool call_not_equals(int_multiset& x, int_multiset& y) {
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "../helpers/test.hpp"
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_fwd_declared_trait_without_definition) {
|
||||||
|
BOOST_CHECK(sizeof(is_unordered_set_impl((int_set*) 0)) == sizeof(true_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <boost/unordered_set.hpp>
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_fwd_declared_trait) {
|
||||||
|
boost::unordered_set<int> x;
|
||||||
|
BOOST_CHECK(sizeof(is_unordered_set_impl(&x)) == sizeof(true_type));
|
||||||
|
|
||||||
|
int dummy;
|
||||||
|
BOOST_CHECK(sizeof(is_unordered_set_impl(&dummy)) == sizeof(false_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_set_fwd_declared_function) {
|
||||||
|
int_set x, y;
|
||||||
|
x.insert(1);
|
||||||
|
y.insert(2);
|
||||||
|
call_swap(x, y);
|
||||||
|
|
||||||
|
BOOST_CHECK(y.find(1) != y.end());
|
||||||
|
BOOST_CHECK(y.find(2) == y.end());
|
||||||
|
|
||||||
|
BOOST_CHECK(x.find(1) == x.end());
|
||||||
|
BOOST_CHECK(x.find(2) != x.end());
|
||||||
|
|
||||||
|
BOOST_CHECK(!call_equals(x, y));
|
||||||
|
BOOST_CHECK(call_not_equals(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(use_multiset_fwd_declared_function) {
|
||||||
|
int_multiset x, y;
|
||||||
|
call_swap(x, y);
|
||||||
|
BOOST_CHECK(call_equals(x, y));
|
||||||
|
BOOST_CHECK(!call_not_equals(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
RUN_TESTS()
|
Reference in New Issue
Block a user