Compare commits

..

5 Commits

Author SHA1 Message Date
nobody 1eb3551a92 This commit was manufactured by cvs2svn to create tag
'Version_1_33_1'.

[SVN r31916]
2005-12-05 14:04:06 +00:00
John Maddock 3b484a6aae Reconfigure lexical_cast to work with wide character strings and VC++ even when not using /Zc:wchar_t.
[SVN r30725]
2005-08-29 12:45:35 +00:00
John Maddock cb041dd66c Reconfigure lexical_cast to work wide character strings and VC++ when not using /Zc:wchar_t.
[SVN r30724]
2005-08-29 12:44:09 +00:00
Jonathan Turkanis f587f50366 fixed broken links
[SVN r30386]
2005-08-02 20:47:34 +00:00
nobody 166924ca12 This commit was manufactured by cvs2svn to create branch 'RC_1_33_0'.
[SVN r30300]
2005-07-28 18:22:24 +00:00
7 changed files with 67 additions and 25 deletions
+6 -8
View File
@@ -44,7 +44,7 @@
#define BOOST_CAST_HPP
# include <boost/config.hpp>
# include <boost/assert.hpp>
# include <cassert>
# include <typeinfo>
# include <boost/type.hpp>
# include <boost/limits.hpp>
@@ -55,7 +55,7 @@
// appear in the function's argument list.
//
// TODO: Add this to config.hpp?
# if defined(BOOST_MSVC) && BOOST_MSVC < 1300
# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 // 1200 = VC6
# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type<Target>* = 0
# else
# define BOOST_EXPLICIT_DEFAULT_TARGET
@@ -82,19 +82,17 @@ namespace boost
// polymorphic_downcast ----------------------------------------------------//
// BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited.
// assert() checked polymorphic downcast. Crosscasts prohibited.
// WARNING: Because this cast uses BOOST_ASSERT(), it violates
// the One Definition Rule if used in multiple translation units
// where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER
// NDEBUG are defined inconsistently.
// WARNING: Because this cast uses assert(), it violates the One Definition
// Rule if NDEBUG is inconsistently defined across translation units.
// Contributed by Dave Abrahams
template <class Target, class Source>
inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
{
BOOST_ASSERT( dynamic_cast<Target>(x) == x ); // detect logic error
assert( dynamic_cast<Target>(x) == x ); // detect logic error
return static_cast<Target>(x);
}
+6
View File
@@ -23,6 +23,12 @@ inline T implicit_cast (typename mpl::identity<T>::type x) {
//template <typename T>
//void implicit_cast (...);
// Macro for when you need a constant expression (Gennaro Prota)
#define BOOST_IMPLICIT_CAST(dst_type, expr) \
( sizeof( implicit_cast<dst_type>(expr) ) \
, \
static_cast<dst_type>(expr) \
)
} // namespace boost
+14 -9
View File
@@ -4,7 +4,7 @@
<head>
<title>lexical_cast</title>
<meta name="author" content="Kevlin Henney, mailto:kevlin@curbralan.com">
<meta name="generator" content="Microsoft FrontPage 5.0">
<meta name="generator" content="Microsoft FrontPage 4.0">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../boost.png" alt="boost.png (6897 bytes)" align="center" width="277" height="86">Header
@@ -89,7 +89,8 @@
<h2><a name="examples">Examples</a></h2>
The following example treats command line arguments as a sequence of numeric
data: <blockquote>
<pre>int main(int argc, char * argv[])
<pre>
int main(int argc, char * argv[])
{
using boost::lexical_cast;
using boost::bad_lexical_cast;
@@ -111,7 +112,8 @@
}
</pre>
</blockquote>The following example uses numeric data in a string expression: <blockquote>
<pre>void log_message(const std::string &amp;);
<pre>
void log_message(const std::string &amp;);
void log_errno(int yoko)
{
@@ -123,11 +125,12 @@ void log_errno(int yoko)
<h2><a name="synopsis">Synopsis</a></h2>
Library features defined in <a href="../../boost/lexical_cast.hpp"><code>&quot;boost/lexical_cast.hpp&quot;</code></a>:
<blockquote>
<pre>namespace boost
<pre>
namespace boost
{
class <a href="#bad_lexical_cast">bad_lexical_cast</a>;
template&lt;typename Target, typename Source&gt;
Target <a href="#lexical_cast">lexical_cast</a>(const Source&amp; arg);
Target <a href="#lexical_cast">lexical_cast</a>(Source arg);
}
</pre>
</blockquote>Unit test defined in <a href="lexical_cast_test.cpp"><code>&quot;lexical_cast_test.cpp&quot;</code></a>.
@@ -135,8 +138,9 @@ void log_errno(int yoko)
<hr>
<h2><a name="lexical_cast"><code>lexical_cast</code></a></h2>
<blockquote>
<pre>template&lt;typename Target, typename Source&gt;
Target lexical_cast(const Source&amp; arg);
<pre>
template&lt;typename Target, typename Source&gt;
Target lexical_cast(Source arg);
</pre>
</blockquote>Returns the result of streaming <code>arg</code> into a
standard library string-based stream and then out as a <code>Target</code> object.
@@ -182,7 +186,8 @@ void log_errno(int yoko)
<hr>
<h2><a name="bad_lexical_cast"><code>bad_lexical_cast</code></a></h2>
<blockquote>
<pre>class bad_lexical_cast : public std::bad_cast
<pre>
class bad_lexical_cast : public std::bad_cast
{
public:
... // <i>same member function interface as</i> std::exception
@@ -231,4 +236,4 @@ public:
<div align="right"><small><i>&copy; Copyright Kevlin Henney, 2000&#150;2005</i></small></div>
</body>
</html>
</html>
+2 -3
View File
@@ -19,9 +19,8 @@
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/test/included/unit_test_framework.hpp>
#if defined(BOOST_NO_STRINGSTREAM) || \
defined(BOOST_NO_STD_WSTRING) || \
@@ -45,7 +44,7 @@ void test_conversion_to_wstring();
void test_bad_lexical_cast();
void test_no_whitespace_stripping();
unit_test::test_suite *init_unit_test_suite(int, char *[])
unit_test_framework::test_suite *init_unit_test_suite(int, char **)
{
unit_test_framework::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
+33
View File
@@ -0,0 +1,33 @@
# Signals library
# Copyright (C) 2001-2003 Douglas Gregor
# Permission to copy, use, sell and distribute this software is granted
# provided this copyright notice appears in all copies. Permission to modify
# the code and to distribute modified code is granted provided this copyright
# notice appears in all copies, and a notice that the code was modified is
# included with the copyright notice. This software is provided "as is"
# without express or implied warranty, and with no claim as to its suitability
# for any purpose.
# For more information, see http://www.boost.org/
# Testing Jamfile autogenerated from XML source
subproject libs/conversion/test ;
# bring in rules for testing
import testing ;
# Make tests run by default.
DEPENDS all : test ;
{
test-suite conversion
: [ run implicit_cast.cpp ]
[ compile-fail implicit_cast_fail.cpp ]
[ run ../cast_test.cpp ]
[ run ../lexical_cast_test.cpp ]
;
}
+2 -2
View File
@@ -20,7 +20,7 @@ test-suite conversion
[ compile-fail implicit_cast_fail.cpp ]
[ run ../cast_test.cpp ]
[ run ../numeric_cast_test.cpp ]
[ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run ../lexical_cast_test.cpp ]
;
+4 -3
View File
@@ -4,8 +4,9 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/implicit_cast.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <cassert>
#include <boost/type.hpp>
using boost::implicit_cast;
using boost::type;
@@ -24,9 +25,9 @@ typedef type<foo> foo_type;
int main()
{
type<long> x = check_return(boost::implicit_cast<long>(1));
BOOST_TEST(boost::implicit_cast<long>(1) == 1L);
assert(boost::implicit_cast<long>(1) == 1L);
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
return boost::report_errors();
return 0;
}