mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 02:44:10 +00:00
type_traits: regression failure fixes from type traits changes...
[SVN r9249]
This commit is contained in:
parent
20d804afc4
commit
91078b7f7a
@ -16,7 +16,7 @@
|
||||
#include <typeinfo>
|
||||
#include <boost/call_traits.hpp>
|
||||
|
||||
#include "type_traits_test.hpp"
|
||||
#include <boost/type_traits/type_traits_test.hpp>
|
||||
//
|
||||
// struct contained models a type that contains a type (for example std::pair)
|
||||
// arrays are contained by value, and have to be treated as a special case:
|
||||
@ -98,18 +98,18 @@ std::pair<
|
||||
using namespace std;
|
||||
|
||||
//
|
||||
// struct checker:
|
||||
// struct call_traits_checker:
|
||||
// verifies behaviour of contained example:
|
||||
//
|
||||
template <class T>
|
||||
struct checker
|
||||
struct call_traits_checker
|
||||
{
|
||||
typedef typename boost::call_traits<T>::param_type param_type;
|
||||
void operator()(param_type);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void checker<T>::operator()(param_type p)
|
||||
void call_traits_checker<T>::operator()(param_type p)
|
||||
{
|
||||
T t(p);
|
||||
contained<T> c(t);
|
||||
@ -128,7 +128,7 @@ void checker<T>::operator()(param_type p)
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <class T, std::size_t N>
|
||||
struct checker<T[N]>
|
||||
struct call_traits_checker<T[N]>
|
||||
{
|
||||
typedef typename boost::call_traits<T[N]>::param_type param_type;
|
||||
void operator()(param_type t)
|
||||
@ -176,32 +176,32 @@ void check_make_pair(T c, U u, V v)
|
||||
}
|
||||
|
||||
|
||||
struct UDT
|
||||
struct comparible_UDT
|
||||
{
|
||||
int i_;
|
||||
UDT() : i_(2){}
|
||||
bool operator == (const UDT& v){ return v.i_ == i_; }
|
||||
comparible_UDT() : i_(2){}
|
||||
bool operator == (const comparible_UDT& v){ return v.i_ == i_; }
|
||||
};
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[ ])
|
||||
{
|
||||
checker<UDT> c1;
|
||||
UDT u;
|
||||
call_traits_checker<comparible_UDT> c1;
|
||||
comparible_UDT u;
|
||||
c1(u);
|
||||
checker<int> c2;
|
||||
call_traits_checker<int> c2;
|
||||
int i = 2;
|
||||
c2(i);
|
||||
int* pi = &i;
|
||||
#if defined(BOOST_MSVC6_MEMBER_TEMPLATES) || !defined(BOOST_NO_MEMBER_TEMPLATES)
|
||||
checker<int*> c3;
|
||||
call_traits_checker<int*> c3;
|
||||
c3(pi);
|
||||
checker<int&> c4;
|
||||
call_traits_checker<int&> c4;
|
||||
c4(i);
|
||||
checker<const int&> c5;
|
||||
call_traits_checker<const int&> c5;
|
||||
c5(i);
|
||||
#if !defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
int a[2] = {1,2};
|
||||
checker<int[2]> c6;
|
||||
call_traits_checker<int[2]> c6;
|
||||
c6(a);
|
||||
#endif
|
||||
#endif
|
||||
@ -220,10 +220,10 @@ int main()
|
||||
typedef int& r_type;
|
||||
typedef const r_type cr_type;
|
||||
|
||||
type_test(UDT, boost::call_traits<UDT>::value_type)
|
||||
type_test(UDT&, boost::call_traits<UDT>::reference)
|
||||
type_test(const UDT&, boost::call_traits<UDT>::const_reference)
|
||||
type_test(const UDT&, boost::call_traits<UDT>::param_type)
|
||||
type_test(comparible_UDT, boost::call_traits<comparible_UDT>::value_type)
|
||||
type_test(comparible_UDT&, boost::call_traits<comparible_UDT>::reference)
|
||||
type_test(const comparible_UDT&, boost::call_traits<comparible_UDT>::const_reference)
|
||||
type_test(const comparible_UDT&, boost::call_traits<comparible_UDT>::param_type)
|
||||
type_test(int, boost::call_traits<int>::value_type)
|
||||
type_test(int&, boost::call_traits<int>::reference)
|
||||
type_test(const int&, boost::call_traits<int>::const_reference)
|
||||
@ -271,9 +271,7 @@ int main()
|
||||
test_count += 20;
|
||||
#endif
|
||||
|
||||
std::cout << std::endl << test_count << " tests completed (" << failures << " failures)... press any key to exit";
|
||||
std::cin.get();
|
||||
return failures;
|
||||
return check_result(argc, argv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -364,3 +362,11 @@ template struct call_traits_test<int[2], true>;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
unsigned int expected_failures = 10;
|
||||
#elif defined(__BORLANDC__)
|
||||
unsigned int expected_failures = 2;
|
||||
#else
|
||||
unsigned int expected_failures = 0;
|
||||
#endif
|
||||
|
||||
|
@ -14,15 +14,10 @@
|
||||
#include <cassert>
|
||||
|
||||
#include <boost/compressed_pair.hpp>
|
||||
#include "type_traits_test.hpp"
|
||||
#include <boost/type_traits/type_traits_test.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
struct empty_POD_UDT{};
|
||||
struct empty_UDT
|
||||
{
|
||||
~empty_UDT(){};
|
||||
};
|
||||
namespace boost {
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
template <> struct is_empty<empty_UDT>
|
||||
@ -59,7 +54,7 @@ struct non_empty2
|
||||
{ return a.i == b.i; }
|
||||
};
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[ ])
|
||||
{
|
||||
compressed_pair<int, double> cp1(1, 1.3);
|
||||
assert(cp1.first() == 1);
|
||||
@ -107,9 +102,7 @@ int main()
|
||||
value_test(true, (sizeof(compressed_pair<empty_UDT, empty_POD_UDT>) < sizeof(std::pair<empty_UDT, empty_POD_UDT>)))
|
||||
value_test(true, (sizeof(compressed_pair<empty_UDT, compressed_pair<empty_POD_UDT, int> >) < sizeof(std::pair<empty_UDT, std::pair<empty_POD_UDT, int> >)))
|
||||
|
||||
std::cout << std::endl << test_count << " tests completed (" << failures << " failures)... press any key to exit";
|
||||
std::cin.get();
|
||||
return failures;
|
||||
return check_result(argc, argv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -154,6 +147,15 @@ template compressed_pair<double, int[2]>::compressed_pair();
|
||||
#endif // __MWERKS__
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// can't handle both types empty:
|
||||
unsigned int expected_failures = 1;
|
||||
#elif defined(__GNUC__)
|
||||
// no zero sized base classes:
|
||||
unsigned int expected_failures = 4;
|
||||
#else
|
||||
unsigned int expected_failures = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -23,8 +23,11 @@
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits.hpp>
|
||||
#ifndef ARITHMETIC_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/arithmetic_traits.hpp>
|
||||
#endif
|
||||
#ifndef COMPOSITE_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/composite_traits.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
@ -19,8 +19,8 @@
|
||||
#define BOOST_DETAIL_COMPRESSED_PAIR_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#ifndef BOOST_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits.hpp>
|
||||
#ifndef OBJECT_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/object_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_CALL_TRAITS_HPP
|
||||
#include <boost/call_traits.hpp>
|
||||
|
@ -24,8 +24,11 @@
|
||||
#include <boost/config.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits.hpp>
|
||||
#ifndef ARITHMETIC_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/arithmetic_traits.hpp>
|
||||
#endif
|
||||
#ifndef COMPOSITE_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/composite_traits.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
@ -26,8 +26,8 @@
|
||||
#define BOOST_OB_COMPRESSED_PAIR_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#ifndef BOOST_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits.hpp>
|
||||
#ifndef OBJECT_TYPE_TRAITS_HPP
|
||||
#include <boost/type_traits/object_traits.hpp>
|
||||
#endif
|
||||
#ifndef BOOST_CALL_TRAITS_HPP
|
||||
#include <boost/call_traits.hpp>
|
||||
|
Loading…
x
Reference in New Issue
Block a user