From daf7829ffa8b8c8e816dd6b767fe010d0e52763e Mon Sep 17 00:00:00 2001
From: John Maddock
Date: Wed, 2 Aug 2000 10:58:59 +0000
Subject: [PATCH] type traits update [added is_convertible and alignment_of]
[SVN r7675]
---
call_traits_test.cpp | 39 ++-----
compressed_pair_test.cpp | 32 +-----
include/boost/detail/call_traits.hpp | 3 +
include/boost/detail/compressed_pair.hpp | 2 +
include/boost/detail/ob_call_traits.hpp | 1 +
include/boost/detail/ob_compressed_pair.hpp | 1 +
type_traits.htm | 88 +++++++++++-----
type_traits_test.cpp | 111 +++++++++++++++-----
type_traits_test.hpp | 106 +++++++++++++++++++
9 files changed, 271 insertions(+), 112 deletions(-)
create mode 100644 type_traits_test.hpp
diff --git a/call_traits_test.cpp b/call_traits_test.cpp
index d0db895..4bb66b6 100644
--- a/call_traits_test.cpp
+++ b/call_traits_test.cpp
@@ -1,3 +1,11 @@
+ // boost::compressed_pair test program
+
+ // (C) Copyright John Maddock 2000. Permission to copy, use, modify, sell and
+ // distribute this software is granted provided this copyright notice appears
+ // in all copies. This software is provided "as is" without express or implied
+ // warranty, and with no claim as to its suitability for any purpose.
+
+// standalone test program for
#include
#include
@@ -6,12 +14,7 @@
#include
#include
-#ifdef __BORLANDC__
-// turn off some warnings, the way we do the tests will generate a *lot* of these
-// this is a result of the tests not call_traits itself....
-#pragma option -w-8004 -w-ccc -w-rch -w-eff -w-aus
-#endif
-
+#include "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:
@@ -178,30 +181,6 @@ struct UDT
bool operator == (const UDT& v){ return v.i_ == i_; }
};
-//
-// define tests here
-unsigned failures = 0;
-unsigned test_count = 0;
-
-#define value_test(v, x) ++test_count;\
- if(v != x){++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;}
-
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-#define type_test(v, x) ++test_count;\
- if(boost::is_same::value == false){\
- ++failures; \
- std::cout << "checking type of " << #x << "...failed" << std::endl; \
- std::cout << " expected type was " << #v << std::endl; \
- std::cout << " " << typeid(boost::is_same).name() << "::value is false" << std::endl; }
-#else
-#define type_test(v, x) ++test_count;\
- if(typeid(v) != typeid(x)){\
- ++failures; \
- std::cout << "checking type of " << #x << "...failed" << std::endl; \
- std::cout << " expected type was " << #v << std::endl; \
- std::cout << " " << "typeid(" #v ") != typeid(" #x ")" << std::endl; }
-#endif
-
int main()
{
checker c1;
diff --git a/compressed_pair_test.cpp b/compressed_pair_test.cpp
index c34aa17..ba6d81d 100644
--- a/compressed_pair_test.cpp
+++ b/compressed_pair_test.cpp
@@ -5,43 +5,17 @@
// in all copies. This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
+// standalone test program for
+
#include
#include
#include
#include
+#include "type_traits_test.hpp"
using namespace boost;
-#ifdef __BORLANDC__
-#pragma option -w-ccc -w-rch -w-eff -w-aus
-#endif
-
-//
-// define tests here
-unsigned failures = 0;
-unsigned test_count = 0;
-
-#define value_test(v, x) ++test_count;\
- if(v != x){++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;}
-#define value_fail(v, x) ++test_count; ++failures; std::cout << "checking value of " << #x << "...failed" << std::endl;
-
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
-#define type_test(v, x) ++test_count;\
- if(boost::is_same::value == false){\
- ++failures; \
- std::cout << "checking type of " << #x << "...failed" << std::endl; \
- std::cout << " expected type was " << #v << std::endl; \
- std::cout << " " << typeid(boost::is_same).name() << "::value is false" << std::endl; }
-#else
-#define type_test(v, x) ++test_count;\
- if(typeid(v) != typeid(x)){\
- ++failures; \
- std::cout << "checking type of " << #x << "...failed" << std::endl; \
- std::cout << " expected type was " << #v << std::endl; \
- std::cout << " " << "typeid(" #v ") != typeid(" #x ")" << std::endl; }
-#endif
-
struct empty_POD_UDT{};
struct empty_UDT
{
diff --git a/include/boost/detail/call_traits.hpp b/include/boost/detail/call_traits.hpp
index 93dc7b1..8d02eca 100644
--- a/include/boost/detail/call_traits.hpp
+++ b/include/boost/detail/call_traits.hpp
@@ -6,6 +6,9 @@
// See http://www.boost.org for most recent version including documentation.
+// call_traits: defines typedefs for function usage
+// (see libs/utility/call_traits.htm)
+
/* Release notes:
23rd July 2000:
Fixed array specialization. (JM)
diff --git a/include/boost/detail/compressed_pair.hpp b/include/boost/detail/compressed_pair.hpp
index a4b3390..87c2449 100644
--- a/include/boost/detail/compressed_pair.hpp
+++ b/include/boost/detail/compressed_pair.hpp
@@ -6,6 +6,8 @@
// See http://www.boost.org for most recent version including documentation.
+// compressed_pair: pair that "compresses" empty members
+// (see libs/utility/compressed_pair.htm)
//
// JM changes 25 Jan 2000:
// Removed default arguments from compressed_pair_switch to get
diff --git a/include/boost/detail/ob_call_traits.hpp b/include/boost/detail/ob_call_traits.hpp
index 332931e..54f2739 100644
--- a/include/boost/detail/ob_call_traits.hpp
+++ b/include/boost/detail/ob_call_traits.hpp
@@ -7,6 +7,7 @@
// See http://www.boost.org for most recent version including documentation.
//
// Crippled version for crippled compilers:
+// see libs/utility/call_traits.htm
//
#ifndef BOOST_OB_CALL_TRAITS_HPP
#define BOOST_OB_CALL_TRAITS_HPP
diff --git a/include/boost/detail/ob_compressed_pair.hpp b/include/boost/detail/ob_compressed_pair.hpp
index ce7e064..994c974 100644
--- a/include/boost/detail/ob_compressed_pair.hpp
+++ b/include/boost/detail/ob_compressed_pair.hpp
@@ -5,6 +5,7 @@
// warranty, and with no claim as to its suitability for any purpose.
// See http://www.boost.org for most recent version including documentation.
+// see libs/utility/compressed_pair.hpp
//
/* Release notes:
23rd July 2000:
diff --git a/type_traits.htm b/type_traits.htm
index dae21d7..66c5370 100644
--- a/type_traits.htm
+++ b/type_traits.htm
@@ -25,6 +25,7 @@ divided up into the following sections:
Fundamental type operations
Fundamental type properties
+ Miscellaneous
cv-Qualifiers
Fundamental Types
Compound Types
@@ -37,7 +38,7 @@ divided up into the following sections:
Usage: "class_name<T>::type" performs
indicated transformation on type T.
-
+
Expression.
|
@@ -108,39 +109,75 @@ indicated transformation on type T.
indicated property is true, false otherwise. (Note that class_name<T>::value
is always defined as a compile time constant).
+Miscellaneous
+
+
+
+ Expression
+ |
+ Description
+ |
+ Compiler
+ |
+
+
+ |
+ True if T and U are the
+ same type.
+ |
+ P
+ |
+
+
+ is_convertible<T,U>::value
+ |
+ True if type T is
+ convertible to type U.
+ |
+ |
+
+
+ |
+ An integral value
+ representing the minimum alignment requirements of type T
+ (strictly speaking defines a multiple of the type's
+ alignment requirement; for all compilers tested so far
+ however it does return the actual alignment).
+ |
+ |
+
+
+
+
+
cv-Qualifiers
The following classes determine what cv-qualifiers are present
on a type (see 3.93).
-
+
- Expression.
+ | Expression.
|
- Description.
+ | Description.
|
- Compiler.
+ | Compiler.
|
- is_const<T>::value |
- True if type T is top-level
+ | is_const<T>::value |
+ True if type T is top-level
const qualified. |
- P
+ | P
|
- is_volatile<T>::value |
- True if type T is top-level
+ | is_volatile<T>::value |
+ True if type T is top-level
volatile qualified. |
- P
- |
-
-
- is_same<T,U>::value |
- True if T and U are the same
- type. |
- P
+ | P
|
@@ -152,7 +189,7 @@ on a type (see 3.93).
The following will only ever be true for cv-unqualified types;
these are closely based on the section 3.9 of the C++ Standard.
-
+
Expression.
|
@@ -291,7 +328,7 @@ these are closely based on the section 3.9 of the C++ Standard.
The following will only ever be true for cv-unqualified types,
as defined by the Standard.
-
+
Expression
|
@@ -365,7 +402,7 @@ as defined by the Standard.
is true then class_name<cv-qualified-T>::value
will also be true.
-
+
Expression
|
@@ -420,9 +457,10 @@ will also be true.
or class. If the compiler implements the "zero sized
empty base classes" optimisation, then is_empty will
correctly guess whether T is empty. Relies upon is_class
- to determine whether T is a class type - as a result will
- not compile when passed an enumerated type unless there
- is compiler support for is_enum.
+ to determine whether T is a class type. Screens out enum
+ types by using is_convertible<T,int>, this means
+ that empty classes that overload operator int(), will not
+ be classified as empty.
PCD
|
@@ -582,7 +620,7 @@ Hinnant and John Maddock.
Maintained by John
Maddock, the latest version of this file can be found at www.boost.org, and the boost
+href="http://www.boost.org/">www.boost.org, and the boost
discussion list at www.egroups.com/list/boost.