forked from boostorg/utility
Compare commits
132 Commits
boost-1.41
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
|
6cd1dd459e | ||
|
b02677375f | ||
|
61a6015b5a | ||
|
682032a340 | ||
|
67afd7e315 | ||
|
75cf20cace | ||
|
91385ac627 | ||
|
61e9b93f7c | ||
|
d97b303777 | ||
|
3900e8ece4 | ||
|
e27fc4a853 | ||
|
f7aa9a8935 | ||
|
0af1959b30 | ||
|
5f0cf4f5de | ||
|
0282c8a141 | ||
|
6725719bd9 | ||
|
97e11b024e | ||
|
118e473a3d | ||
|
d4b6193f94 | ||
|
d420c98a53 | ||
|
d153ab4daa | ||
|
561f83b991 | ||
|
57124703f9 | ||
|
53f6d10652 | ||
|
ebe853ff2f | ||
|
487a5c1ea5 | ||
|
c4338b1ce8 | ||
|
ddd8a58ae0 | ||
|
28061ba3a8 | ||
|
5d53e3f837 | ||
|
e86ce1cb1f | ||
|
f15c96ffb0 | ||
|
a487f72329 | ||
|
9f08ed6de0 | ||
|
2077d0dace | ||
|
7f2348269b | ||
|
6b6e1c3252 | ||
|
55f303baec | ||
|
d264005c11 | ||
|
2cde009bb1 | ||
|
7bfb7c8a61 | ||
|
5c42397244 | ||
|
782c132d99 | ||
|
36899afa3f | ||
|
7e3e326faf | ||
|
7019e18149 | ||
|
49faf23433 | ||
|
62836f2928 | ||
|
1ecf3ceb74 | ||
|
2aa48414c9 | ||
|
d215f2176c | ||
|
c286d62223 | ||
|
3fd0ea6e75 | ||
|
b050431638 | ||
|
b311fcefb2 | ||
|
899c92420c | ||
|
64a0e0cb20 | ||
|
ece6992540 | ||
|
6098304ea8 | ||
|
28fff2d821 | ||
|
0ce3885d59 | ||
|
1823481d96 | ||
|
cce5d77d2b | ||
|
3c5c2bc107 | ||
|
177ee78bbb | ||
|
f1ec0c4d04 | ||
|
4a564744fe | ||
|
67f3ca090a | ||
|
8efae71f4a | ||
|
ad0bcf4a00 | ||
|
f1c86c35c4 | ||
|
a5b85eda07 | ||
|
bafe37fdab | ||
|
be50b95508 | ||
|
96d573d6ca | ||
|
2412b864d6 | ||
|
94865eabe6 | ||
|
50268d1b29 | ||
|
ad9108c1dc | ||
|
691e4b6c34 | ||
|
28596e678d | ||
|
1beca24dd8 | ||
|
721764937f | ||
|
a511007d0f | ||
|
8ce58b1675 | ||
|
9ed68b8321 | ||
|
79bbf71d0d | ||
|
ac93de7c1b | ||
|
d731b8e1c5 | ||
|
ac1567b3fc | ||
|
c1fd670480 | ||
|
01274cf6ac | ||
|
8080673977 | ||
|
a470b591fb | ||
|
e1a63495b6 | ||
|
7300ac83f1 | ||
|
882d38c2c7 | ||
|
33041ad664 | ||
|
6a2aa822f8 | ||
|
09ab16bfc1 | ||
|
ec46e40809 | ||
|
b3a971e7e9 | ||
|
7ddb559887 | ||
|
ea8c99b1d5 | ||
|
56b0846099 | ||
|
42e0001370 | ||
|
cd8f85afee | ||
|
bddd52c4b9 | ||
|
8f03aeac4e | ||
|
3bb2568fad | ||
|
01e91a3799 | ||
|
55f3c351a3 | ||
|
3f72b10182 | ||
|
71cb8cb574 | ||
|
c950825ef4 | ||
|
66ca84a45d | ||
|
06404f7d39 | ||
|
2d860e2574 | ||
|
66514f61ff | ||
|
63cde4d3fd | ||
|
1950f292df | ||
|
92a0602190 | ||
|
c9a3ab1d04 | ||
|
0782034333 | ||
|
0808883f3c | ||
|
2f69501e55 | ||
|
5b83f641a8 | ||
|
c730ab4ffb | ||
|
e55610a0d0 | ||
|
bf968794c9 | ||
|
ce6e9c6698 | ||
|
7ac180ed54 |
31
CMakeLists.txt
Normal file
31
CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# This file was automatically generated from the original CMakeLists.txt file
|
||||||
|
# Add a variable to hold the headers for the library
|
||||||
|
set (lib_headers
|
||||||
|
assert.hpp
|
||||||
|
call_traits.hpp
|
||||||
|
checked_delete.hpp
|
||||||
|
compressed_pair.hpp
|
||||||
|
current_function.hpp
|
||||||
|
operators.hpp
|
||||||
|
throw_exception.hpp
|
||||||
|
utility.hpp
|
||||||
|
utility
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add a library target to the build system
|
||||||
|
boost_library_project(
|
||||||
|
utility
|
||||||
|
# SRCDIRS
|
||||||
|
TESTDIRS test
|
||||||
|
HEADERS ${lib_headers}
|
||||||
|
# DOCDIRS
|
||||||
|
DESCRIPTION "Various small utilities for C++ programming."
|
||||||
|
MODULARIZED
|
||||||
|
AUTHORS "David Abrahams <dave -at- boostpro.com>"
|
||||||
|
"Brad King"
|
||||||
|
"Douglas Gregor <doug.gregor -at- gmail.com>"
|
||||||
|
# MAINTAINERS
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@@ -6,8 +6,14 @@
|
|||||||
#ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492
|
#ifndef UUID_1D94A7C6054E11DB9804B622A1EF5492
|
||||||
#define UUID_1D94A7C6054E11DB9804B622A1EF5492
|
#define UUID_1D94A7C6054E11DB9804B622A1EF5492
|
||||||
|
|
||||||
//The header <boost/exception.hpp> has been deprecated.
|
#include <boost/exception/diagnostic_information.hpp>
|
||||||
//Please #include <boost/exception/all.hpp> instead.
|
#include <boost/exception/error_info.hpp>
|
||||||
#include <boost/exception/all.hpp>
|
#include <boost/exception/exception.hpp>
|
||||||
|
#include <boost/exception/get_error_info.hpp>
|
||||||
|
#include <boost/exception/info.hpp>
|
||||||
|
#include <boost/exception/info_tuple.hpp>
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
#include <boost/exception_ptr.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -10,6 +10,47 @@
|
|||||||
# error Boost result_of - do not include this file!
|
# error Boost result_of - do not include this file!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_HAS_DECLTYPE)
|
||||||
|
|
||||||
|
// As of N2588, C++0x result_of only supports function call
|
||||||
|
// expressions of the form f(x). This precludes support for member
|
||||||
|
// function pointers, which are invoked with expressions of the form
|
||||||
|
// o->*f(x). This implementation supports both.
|
||||||
|
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
|
struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
||||||
|
: mpl::if_<
|
||||||
|
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
|
||||||
|
, detail::result_of_impl<
|
||||||
|
typename remove_cv<F>::type,
|
||||||
|
typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
|
||||||
|
>
|
||||||
|
, detail::result_of_decltype_impl<
|
||||||
|
F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
|
||||||
|
>
|
||||||
|
>::type
|
||||||
|
{};
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \
|
||||||
|
static T ## n t ## n; \
|
||||||
|
/**/
|
||||||
|
|
||||||
|
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
|
class result_of_decltype_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
|
||||||
|
{
|
||||||
|
static F f;
|
||||||
|
BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _)
|
||||||
|
public:
|
||||||
|
typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
#else // defined(BOOST_HAS_DECLTYPE)
|
||||||
|
|
||||||
// CWPro8 requires an argument in a function type specialization
|
// CWPro8 requires an argument in a function type specialization
|
||||||
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
|
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
|
||||||
# define BOOST_RESULT_OF_ARGS void
|
# define BOOST_RESULT_OF_ARGS void
|
||||||
@@ -21,11 +62,22 @@
|
|||||||
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
|
||||||
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
struct result_of<F(BOOST_RESULT_OF_ARGS)>
|
||||||
: boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
|
: mpl::if_<
|
||||||
|
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
|
||||||
|
, boost::detail::result_of_impl<
|
||||||
|
typename remove_cv<F>::type,
|
||||||
|
typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
|
||||||
|
(boost::detail::has_result_type<F>::value)>
|
||||||
|
, boost::detail::result_of_impl<
|
||||||
|
F,
|
||||||
|
F(BOOST_RESULT_OF_ARGS),
|
||||||
|
(boost::detail::has_result_type<F>::value)> >::type { };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef BOOST_RESULT_OF_ARGS
|
#undef BOOST_RESULT_OF_ARGS
|
||||||
|
|
||||||
|
#endif // defined(BOOST_HAS_DECLTYPE)
|
||||||
|
|
||||||
#if BOOST_PP_ITERATION() >= 1
|
#if BOOST_PP_ITERATION() >= 1
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@@ -10,13 +10,18 @@
|
|||||||
#define BOOST_RESULT_OF_HPP
|
#define BOOST_RESULT_OF_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/type_traits/ice.hpp>
|
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
#include <boost/type.hpp>
|
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||||
#include <boost/preprocessor.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
|
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/mpl/bool.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
|
#include <boost/type_traits/is_pointer.hpp>
|
||||||
|
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||||
|
#include <boost/type_traits/remove_cv.hpp>
|
||||||
|
|
||||||
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
#ifndef BOOST_RESULT_OF_NUM_ARGS
|
||||||
# define BOOST_RESULT_OF_NUM_ARGS 10
|
# define BOOST_RESULT_OF_NUM_ARGS 10
|
||||||
@@ -32,6 +37,7 @@ namespace detail {
|
|||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
|
||||||
|
|
||||||
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
|
template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
|
||||||
|
template<typename F> struct result_of_decltype_impl;
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
struct result_of_void_impl
|
struct result_of_void_impl
|
||||||
@@ -51,6 +57,11 @@ struct result_of_void_impl<R (&)(void)>
|
|||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Determine the return type of a function pointer or pointer to member.
|
||||||
|
template<typename F, typename FArgs>
|
||||||
|
struct result_of_pointer
|
||||||
|
: result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
|
||||||
|
|
||||||
template<typename F, typename FArgs>
|
template<typename F, typename FArgs>
|
||||||
struct result_of_impl<F, FArgs, true>
|
struct result_of_impl<F, FArgs, true>
|
||||||
{
|
{
|
||||||
|
@@ -114,8 +114,6 @@ class value_initialized
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T const& get ( value_initialized<T> const& x )
|
T const& get ( value_initialized<T> const& x )
|
||||||
{
|
{
|
||||||
|
1
module.cmake
Normal file
1
module.cmake
Normal file
@@ -0,0 +1 @@
|
|||||||
|
boost_module(utility DEPENDS iterator exception detail )
|
43
ref_test.cpp
43
ref_test.cpp
@@ -68,11 +68,54 @@ struct ref_wrapper
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct copy_counter {
|
||||||
|
static int count_;
|
||||||
|
copy_counter(copy_counter const& other) {
|
||||||
|
++count_;
|
||||||
|
}
|
||||||
|
copy_counter() {}
|
||||||
|
static void reset() { count_ = 0; }
|
||||||
|
static int count() { return copy_counter::count_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
int copy_counter::count_ = 0;
|
||||||
|
|
||||||
} // namespace unnamed
|
} // namespace unnamed
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void do_unwrap(T t) {
|
||||||
|
|
||||||
|
/* typename unwrap_reference<T>::type& lt = */
|
||||||
|
unwrap_ref(t);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void unwrap_test() {
|
||||||
|
|
||||||
|
int i = 3;
|
||||||
|
const int ci = 2;
|
||||||
|
|
||||||
|
do_unwrap(i);
|
||||||
|
do_unwrap(ci);
|
||||||
|
do_unwrap(ref(i));
|
||||||
|
do_unwrap(cref(ci));
|
||||||
|
do_unwrap(ref(ci));
|
||||||
|
|
||||||
|
copy_counter cc;
|
||||||
|
BOOST_CHECK(cc.count() == 0);
|
||||||
|
|
||||||
|
do_unwrap(cc);
|
||||||
|
do_unwrap(ref(cc));
|
||||||
|
do_unwrap(cref(cc));
|
||||||
|
|
||||||
|
BOOST_CHECK(cc.count() == 1);
|
||||||
|
BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
int test_main(int, char * [])
|
int test_main(int, char * [])
|
||||||
{
|
{
|
||||||
ref_wrapper<int>::test(1);
|
ref_wrapper<int>::test(1);
|
||||||
ref_wrapper<int const>::test(1);
|
ref_wrapper<int const>::test(1);
|
||||||
|
unwrap_test();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Page header -->
|
<!-- Page header -->
|
||||||
<h2>
|
|
||||||
<img src="../../boost.png" alt="C++ Boost" align="middle" width="277" height="86"/>
|
<img src="../../boost.png" alt="C++ Boost" align="middle" width="277" height="86"/>
|
||||||
Header <<a href="../../boost/swap.hpp">boost/swap.hpp</a>>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<h1>Swap</h1>
|
<h1>Swap</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -88,9 +84,9 @@
|
|||||||
|
|
||||||
<!-- Copyright info -->
|
<!-- Copyright info -->
|
||||||
<hr/>
|
<hr/>
|
||||||
<p>Revised: 08 September 2009</p>
|
<p>Revised: 15 November 2008</p>
|
||||||
<p>
|
<p>
|
||||||
Copyright 2007 - 2009 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0.
|
Copyright 2007, 2008 Joseph Gauterin. Use, modification, and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
(See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)
|
(See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
38
test/CMakeLists.txt
Normal file
38
test/CMakeLists.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
boost_additional_test_dependencies(utility BOOST_DEPENDS test)
|
||||||
|
|
||||||
|
boost_test_run(addressof_test ../addressof_test.cpp)
|
||||||
|
boost_test_run(assert_test ../assert_test.cpp)
|
||||||
|
boost_test_run(base_from_member_test ../base_from_member_test.cpp)
|
||||||
|
boost_test_run(binary_search_test ../binary_search_test.cpp)
|
||||||
|
boost_test_run(call_traits_test ../call_traits_test.cpp ARGS -u)
|
||||||
|
boost_test_compile_fail(checked_delete_test ../checked_delete_test.cpp)
|
||||||
|
boost_test_run(compressed_pair_test
|
||||||
|
../compressed_pair_test
|
||||||
|
DEPENDS boost_test_exec_monitor)
|
||||||
|
boost_test_run(current_function_test ../current_function_test.cpp)
|
||||||
|
boost_test_run(iterators_test
|
||||||
|
../iterators_test.cpp
|
||||||
|
DEPENDS boost_test_exec_monitor)
|
||||||
|
boost_test_run(next_prior_test DEPENDS boost_test_exec_monitor)
|
||||||
|
boost_test_compile_fail(noncopyable_test ../noncopyable_test.cpp)
|
||||||
|
boost_test_run(numeric_traits_test ../numeric_traits_test.cpp)
|
||||||
|
if (${CMAKE_SYSTEM} MATCHES "FreeBSD-.*")
|
||||||
|
boost_test_compile_fail("operators_test_compilerbug")
|
||||||
|
elseif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*")
|
||||||
|
boost_test_run(operators_test
|
||||||
|
../operators_test.cpp
|
||||||
|
DEPENDS boost_test_exec_monitor)
|
||||||
|
endif(${CMAKE_SYSTEM} MATCHES "FreeBSD-.*")
|
||||||
|
boost_test_compile(ref_ct_test ../ref_ct_test.cpp)
|
||||||
|
boost_test_run(ref_test
|
||||||
|
../ref_test.cpp
|
||||||
|
DEPENDS boost_test_exec_monitor)
|
||||||
|
boost_test_compile(result_of_test)
|
||||||
|
boost_test_run(shared_iterator_test ../shared_iterator_test.cpp)
|
||||||
|
boost_test_run(value_init_test ../value_init_test.cpp)
|
||||||
|
boost_test_compile_fail(value_init_test_fail1
|
||||||
|
../value_init_test_fail1.cpp)
|
||||||
|
boost_test_compile_fail(value_init_test_fail2
|
||||||
|
../value_init_test_fail2.cpp)
|
||||||
|
boost_test_compile_fail(value_init_test_fail3
|
||||||
|
../value_init_test_fail3.cpp)
|
@@ -11,35 +11,101 @@
|
|||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
struct int_result_type { typedef int result_type; };
|
struct int_result_type
|
||||||
|
{
|
||||||
|
typedef int result_type;
|
||||||
|
result_type operator()(float);
|
||||||
|
};
|
||||||
|
|
||||||
struct int_result_of
|
struct int_result_of
|
||||||
{
|
{
|
||||||
template<typename F> struct result { typedef int type; };
|
template<typename F> struct result { typedef int type; };
|
||||||
|
result<int_result_of(double)>::type operator()(double);
|
||||||
|
result<const int_result_of(double)>::type operator()(double) const;
|
||||||
|
result<int_result_of()>::type operator()();
|
||||||
|
result<volatile int_result_of()>::type operator()() volatile;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct int_result_type_and_float_result_of
|
struct int_result_type_and_float_result_of_and_char_return
|
||||||
{
|
{
|
||||||
typedef int result_type;
|
typedef int result_type;
|
||||||
template<typename F> struct result { typedef float type; };
|
template<typename F> struct result { typedef float type; };
|
||||||
|
char operator()(char);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct int_result_type_template { typedef int result_type; };
|
struct int_result_type_template
|
||||||
|
{
|
||||||
|
typedef int result_type;
|
||||||
|
result_type operator()(float);
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct int_result_of_template
|
struct int_result_of_template
|
||||||
{
|
{
|
||||||
template<typename F> struct result;
|
template<typename F> struct result;
|
||||||
template<typename This, typename That> struct result<This(That)> { typedef int type; };
|
template<typename This, typename That> struct result<This(That)> { typedef int type; };
|
||||||
|
typename result<int_result_of_template<T>(double)>::type operator()(double);
|
||||||
|
typename result<const int_result_of_template<T>(double)>::type operator()(double) const;
|
||||||
|
typename result<int_result_of_template<T>(double)>::type operator()();
|
||||||
|
typename result<volatile int_result_of_template<T>(double)>::type operator()() volatile;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct int_result_type_and_float_result_of_template
|
struct int_result_type_and_float_result_of_and_char_return_template
|
||||||
{
|
{
|
||||||
typedef int result_type;
|
typedef int result_type;
|
||||||
template<typename F> struct result;
|
template<typename F> struct result;
|
||||||
template<typename This, typename That> struct result<This(That)> { typedef float type; };
|
template<typename This, typename That> struct result<This(That)> { typedef float type; };
|
||||||
|
char operator()(char);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct result_of_member_function_template
|
||||||
|
{
|
||||||
|
template<typename F> struct result;
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<This(That)> { typedef That type; };
|
||||||
|
template<class T> typename result<result_of_member_function_template(T)>::type operator()(T);
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<const This(That)> { typedef const That type; };
|
||||||
|
template<class T> typename result<const result_of_member_function_template(T)>::type operator()(T) const;
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<volatile This(That)> { typedef volatile That type; };
|
||||||
|
template<class T> typename result<volatile result_of_member_function_template(T)>::type operator()(T) volatile;
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<const volatile This(That)> { typedef const volatile That type; };
|
||||||
|
template<class T> typename result<const volatile result_of_member_function_template(T)>::type operator()(T) const volatile;
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<This(That &, That)> { typedef That & type; };
|
||||||
|
template<class T> typename result<result_of_member_function_template(T &, T)>::type operator()(T &, T);
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<This(That const &, That)> { typedef That const & type; };
|
||||||
|
template<class T> typename result<result_of_member_function_template(T const &, T)>::type operator()(T const &, T);
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<This(That volatile &, That)> { typedef That volatile & type; };
|
||||||
|
template<class T> typename result<result_of_member_function_template(T volatile &, T)>::type operator()(T volatile &, T);
|
||||||
|
|
||||||
|
template<typename This, typename That> struct result<This(That const volatile &, That)> { typedef That const volatile & type; };
|
||||||
|
template<class T> typename result<result_of_member_function_template(T const volatile &, T)>::type operator()(T const volatile &, T);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct no_result_type_or_result_of
|
||||||
|
{
|
||||||
|
int operator()(double);
|
||||||
|
short operator()(double) const;
|
||||||
|
unsigned int operator()();
|
||||||
|
unsigned short operator()() volatile;
|
||||||
|
const unsigned short operator()() const volatile;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct no_result_type_or_result_of_template
|
||||||
|
{
|
||||||
|
int operator()(double);
|
||||||
|
short operator()(double) const;
|
||||||
|
unsigned int operator()();
|
||||||
|
unsigned short operator()() volatile;
|
||||||
|
const unsigned short operator()() const volatile;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct X {};
|
struct X {};
|
||||||
@@ -60,16 +126,37 @@ int main()
|
|||||||
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
|
||||||
|
|
||||||
|
// Prior to decltype, result_of could not deduce the return type
|
||||||
|
// nullary function objects unless they exposed a result_type.
|
||||||
|
#if defined(BOOST_HAS_DECLTYPE)
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, int>::value));
|
||||||
|
#else
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value));
|
#endif
|
||||||
|
|
||||||
|
// Prior to decltype, result_of ignored a nested result<> if
|
||||||
|
// result_type was defined. After decltype, result_of deduces the
|
||||||
|
// actual return type of the function object, ignoring both
|
||||||
|
// result<> and result_type.
|
||||||
|
#if defined(BOOST_HAS_DECLTYPE)
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, char>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, char>::value));
|
||||||
|
#else
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, int>::value));
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
|
||||||
@@ -81,5 +168,31 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
|
||||||
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(double)>::type, double>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const result_of_member_function_template(double)>::type, const double>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile result_of_member_function_template(double)>::type, volatile double>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const volatile result_of_member_function_template(double)>::type, const volatile double>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int &, int)>::type, int &>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const &, int)>::type, int const &>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int volatile &, int)>::type, int volatile &>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const volatile &, int)>::type, int const volatile &>::value));
|
||||||
|
|
||||||
|
typedef int (*pf_t)(int);
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<pf_t(int)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<pf_t const(int)>::type,int>::value));
|
||||||
|
|
||||||
|
#if defined(BOOST_HAS_DECLTYPE)
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(double)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(void)>::type, unsigned int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of(double)>::type, short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of(void)>::type, unsigned short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of(void)>::type, const unsigned short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(double)>::type, int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(void)>::type, unsigned int>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
|
||||||
|
BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -154,11 +154,13 @@ void f() {
|
|||||||
...,t<em>N</em>)</code>. The implementation permits
|
...,t<em>N</em>)</code>. The implementation permits
|
||||||
the type <code>F</code> to be a function pointer,
|
the type <code>F</code> to be a function pointer,
|
||||||
function reference, member function pointer, or class
|
function reference, member function pointer, or class
|
||||||
type. When <code>F</code> is a class type with a
|
type.</p> <p>If your compiler does not support
|
||||||
member type <code>result_type</code>,
|
<code>decltype</code>, then when <code>F</code> is a
|
||||||
|
class type with a member type <code>result_type</code>,
|
||||||
<code>result_of<F(T1, T2, ...,
|
<code>result_of<F(T1, T2, ...,
|
||||||
T<em>N</em>)></code> is
|
T<em>N</em>)></code> is
|
||||||
<code>F::result_type</code>. Otherwise,
|
<code>F::result_type</code>. When <code>F</code>
|
||||||
|
does not contain <code>result_type</code>,
|
||||||
<code>result_of<F(T1, T2, ...,
|
<code>result_of<F(T1, T2, ...,
|
||||||
T<em>N</em>)></code> is <code>F::result<F(T1,
|
T<em>N</em>)></code> is <code>F::result<F(T1,
|
||||||
T2, ..., T<em>N</em>)>::type</code> when
|
T2, ..., T<em>N</em>)>::type</code> when
|
||||||
|
@@ -313,7 +313,7 @@ non-member function <code>get()</code>: </p>
|
|||||||
|
|
||||||
<h3>Warning:</h3>
|
<h3>Warning:</h3>
|
||||||
|
|
||||||
<p>The <code>value_initialized</code> implementation of Boost version 1.40.0 and older
|
<p>The <code>value_initialized</code> implementation of Boost version 1.38.0 and older
|
||||||
allowed <i>non-const</i> access to the wrapped object, from a constant wrapper,
|
allowed <i>non-const</i> access to the wrapped object, from a constant wrapper,
|
||||||
both by its conversion operator and its <code>data()</code> member function. For example:</p>
|
both by its conversion operator and its <code>data()</code> member function. For example:</p>
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ for Boost release version 1.35 (2008), offering a workaround to various compiler
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<p>Revised 03 October 2009</p>
|
<p>Revised 20 February 2009</p>
|
||||||
|
|
||||||
<p>© Copyright Fernando Cacciola, 2002, 2009.</p>
|
<p>© Copyright Fernando Cacciola, 2002, 2009.</p>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user