|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73275 - in sandbox/enums/libs/enums/test: . enum_class enum_class/cons enum_class/conversion enum_set enum_type/cons enum_type/conversion
From: vicente.botet_at_[hidden]
Date: 2011-07-21 10:46:22
Author: viboes
Date: 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
New Revision: 73275
URL: http://svn.boost.org/trac/boost/changeset/73275
Log:
Enums: replace convert_to by explicit_convert_to
Text files modified:
sandbox/enums/libs/enums/test/EnumClass.cpp | 10 +++++-----
sandbox/enums/libs/enums/test/EnumClass.hpp | 38 +++++++++++++++++++-------------------
sandbox/enums/libs/enums/test/EnumType.hpp | 14 +++++++-------
sandbox/enums/libs/enums/test/Ex.hpp | 10 +++++-----
sandbox/enums/libs/enums/test/Jamfile.v2 | 2 ++
sandbox/enums/libs/enums/test/constructible_from_enum.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp | 10 +++++-----
sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp | 2 +-
sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp | 23 ++++++++++++++++++++++-
sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp | 24 +++++++++++++++++++++++-
14 files changed, 94 insertions(+), 49 deletions(-)
Modified: sandbox/enums/libs/enums/test/EnumClass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumClass.cpp (original)
+++ sandbox/enums/libs/enums/test/EnumClass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -31,7 +31,7 @@
std::cout << __LINE__ << std::endl;
{ // The wrapper can be constructed from a valid const char* representation
- EnumClass e = convert_to<EnumClass>("Enum2");
+ EnumClass e = explicit_convert_to<EnumClass>("Enum2");
BOOST_TEST(e==EnumClass::Enum2);
}
#ifdef COMPILE_TIME2
@@ -42,13 +42,13 @@
#endif
#ifdef RUN_TIME2
{ // The wrapper can not be constructed from an invalid const char* representation
- EnumClass e = convert_to<EnumClass>("CHASSE");
+ EnumClass e = explicit_convert_to<EnumClass>("CHASSE");
// ... fail
}
#endif
{ // The wrapper can be constructed from a valid std::string representation
std::string str = "Enum2";
- EnumClass e = convert_to<EnumClass>(str);
+ EnumClass e = explicit_convert_to<EnumClass>(str);
BOOST_TEST(e==EnumClass::Enum2);
BOOST_TEST(strcmp(c_str(e),"Enum2")==0);
}
@@ -62,14 +62,14 @@
#ifdef RUN_TIME2
{ // The wrapper can not be constructed from an invalid std::string representation
std::string str = "CHASSE";
- EnumClass e = convert_to<EnumClass>(str);
+ EnumClass e = explicit_convert_to<EnumClass>(str);
// ... fail
BOOST_TEST(e==EnumClass::Enum2);
BOOST_TEST(strcmp(c_str(e), "CHASSE")==0);
}
#endif
{ // Construction of the wrapper with an invalid ints results in run-time error (undefined behavior)
-// EnumClass e(convert_to<EnumClass>((unsigned char)(6)));
+// EnumClass e(explicit_convert_to<EnumClass>((unsigned char)(6)));
BOOST_TEST((unsigned char)(enums::native_type<EnumClass>::type(6))==(unsigned char)(6));
// BOOST_TEST(native_value(e)==(unsigned char)(6));
}
Modified: sandbox/enums/libs/enums/test/EnumClass.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumClass.hpp (original)
+++ sandbox/enums/libs/enums/test/EnumClass.hpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -23,7 +23,7 @@
#include <boost/enums/ordinal/last.hpp>
#include <boost/enums/ordinal/size.hpp>
#include <boost/enums/ordinal/traits.hpp>
-#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/explicit_convert_to.hpp>
#include <boost/enums/ordinal/linear_traiter.hpp>
#include <boost/enums/scoped/emulation.hpp>
#include <cassert>
@@ -59,22 +59,22 @@
BOOST_ENUMS_SPECIALIZATIONS(EnumClass, unsigned char)
//! conversion from c-string.
-inline EnumClass convert_to(const char* str
+inline EnumClass explicit_convert_to(const char* str
, boost::conversion::dummy::type_tag<EnumClass> const&
)
{
- if (strcmp(str, "Default") ==0) { return boost::convert_to<EnumClass>(EnumClass::Default); }
- if (strcmp(str, "Enum1") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum1); }
- if (strcmp(str, "Enum2") ==0) { return boost::convert_to<EnumClass>(EnumClass::Enum2); }
+ if (strcmp(str, "Default") ==0) { return boost::explicit_convert_to<EnumClass>(EnumClass::Default); }
+ if (strcmp(str, "Enum1") ==0) { return boost::explicit_convert_to<EnumClass>(EnumClass::Enum1); }
+ if (strcmp(str, "Enum2") ==0) { return boost::explicit_convert_to<EnumClass>(EnumClass::Enum2); }
throw "invalid string for EnumClass";
}
//! conversion from std::string.
-inline EnumClass convert_to(const std::string& str
+inline EnumClass explicit_convert_to(const std::string& str
, boost::conversion::dummy::type_tag<EnumClass> const&
)
{
- return boost::convert_to<EnumClass>(str.c_str());
+ return boost::explicit_convert_to<EnumClass>(str.c_str());
}
//!explicit conversion to c-string.
@@ -165,16 +165,16 @@
class EnumClass {
public:
enum type { Default = 3 , Enum1 , Enum2 };
- inline friend EnumClass convert_to( const char* str, boost::conversion::dummy::type_tag<EnumClass> const& )
+ inline friend EnumClass explicit_convert_to( const char* str, boost::conversion::dummy::type_tag<EnumClass> const& )
{
- if (strcmp( str, "Default" ) == 0) { return boost::convert_to<EnumClass>( EnumClass::Default ); }
- if (strcmp( str, "Enum1" ) == 0) { return boost::convert_to<EnumClass>( EnumClass::Enum1 ); }
- if (strcmp( str, "Enum2" ) == 0) { return boost::convert_to<EnumClass>( EnumClass::Enum2 ); }
+ if (strcmp( str, "Default" ) == 0) { return boost::explicit_convert_to<EnumClass>( EnumClass::Default ); }
+ if (strcmp( str, "Enum1" ) == 0) { return boost::explicit_convert_to<EnumClass>( EnumClass::Enum1 ); }
+ if (strcmp( str, "Enum2" ) == 0) { return boost::explicit_convert_to<EnumClass>( EnumClass::Enum2 ); }
throw "invalid string for " "EnumClass";
}
- inline friend EnumClass convert_to( const std::string& str, boost::conversion::dummy::type_tag<EnumClass> const& )
+ inline friend EnumClass explicit_convert_to( const std::string& str, boost::conversion::dummy::type_tag<EnumClass> const& )
{
- return boost::convert_to<EnumClass>( str.c_str() );
+ return boost::explicit_convert_to<EnumClass>( str.c_str() );
}
inline friend const char* c_str(EnumClass e)
{
@@ -196,14 +196,14 @@
explicit EnumClass(underlying_type v) : val_(v) { }
EnumClass& operator =(type rhs) { val_=static_cast<underlying_type>(rhs); return *this; }
static EnumClass default_value() { EnumClass res; res.val_=static_cast<underlying_type>(EnumClass::type()); return res; }
- static EnumClass convert_to(underlying_type v) { EnumClass res; res.val_=v; return res; }
- static EnumClass convert_to(type v) { EnumClass res; res.val_=static_cast<underlying_type>(v); return res; }
+ static EnumClass explicit_convert_to(underlying_type v) { EnumClass res; res.val_=v; return res; }
+ static EnumClass explicit_convert_to(type v) { EnumClass res; res.val_=static_cast<underlying_type>(v); return res; }
type native_value() const { return type(val_); }
underlying_type underlying_value() const { return val_; }
- inline friend EnumClass convert_to(int v , boost::conversion::dummy::type_tag<EnumClass> const& ) { return EnumClass::convert_to(v); }
- inline friend EnumClass convert_to(boost::enums::native_type<EnumClass>::type v , boost::conversion::dummy::type_tag<EnumClass> const& ) { return EnumClass::convert_to(v); }
- inline friend int convert_to(EnumClass v , boost::conversion::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
- inline friend boost::enums::native_type<EnumClass>::type convert_to(EnumClass v , boost::conversion::dummy::type_tag<boost::enums::native_type<EnumClass>::type> const& ) {
+ inline friend EnumClass explicit_convert_to(int v , boost::conversion::dummy::type_tag<EnumClass> const& ) { return EnumClass::explicit_convert_to(v); }
+ inline friend EnumClass explicit_convert_to(boost::enums::native_type<EnumClass>::type v , boost::conversion::dummy::type_tag<EnumClass> const& ) { return EnumClass::explicit_convert_to(v); }
+ inline friend int explicit_convert_to(EnumClass v , boost::conversion::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
+ inline friend boost::enums::native_type<EnumClass>::type explicit_convert_to(EnumClass v , boost::conversion::dummy::type_tag<boost::enums::native_type<EnumClass>::type> const& ) {
return boost::enums::native_value(v);
}
friend inline bool operator ==(EnumClass lhs, EnumClass rhs) { return lhs.native_value() == rhs.native_value(); }
Modified: sandbox/enums/libs/enums/test/EnumType.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/EnumType.hpp (original)
+++ sandbox/enums/libs/enums/test/EnumType.hpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -23,7 +23,7 @@
#include <boost/enums/ordinal/last.hpp>
#include <boost/enums/ordinal/size.hpp>
#include <boost/enums/ordinal/traits.hpp>
-#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/explicit_convert_to.hpp>
#include <boost/enums/ordinal/linear_traiter.hpp>
#include <boost/enums/scoped/emulation.hpp>
#include <cassert>
@@ -55,22 +55,22 @@
BOOST_ENUMS_SPECIALIZATIONS(EnumClass, unsigned char)
//! conversion from c-string.
-inline EnumClass convert_to(const char* str
+inline EnumClass explicit_convert_to(const char* str
, boost::conversion::dummy::type_tag<EnumClass> const&
)
{
- if (strcmp(str, "Default") ==0) { return boost::conversion::convert_to<EnumClass>(EnumClass::Default); }
- if (strcmp(str, "Enum1") ==0) { return boost::conversion::convert_to<EnumClass>(EnumClass::Enum1); }
- if (strcmp(str, "Enum2") ==0) { return boost::conversion::convert_to<EnumClass>(EnumClass::Enum2); }
+ if (strcmp(str, "Default") ==0) { return boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Default); }
+ if (strcmp(str, "Enum1") ==0) { return boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Enum1); }
+ if (strcmp(str, "Enum2") ==0) { return boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Enum2); }
throw "invalid string for EnumClass";
}
//! conversion from std::string.
-inline EnumClass convert_to(const std::string& str
+inline EnumClass explicit_convert_to(const std::string& str
, boost::conversion::dummy::type_tag<EnumClass> const&
)
{
- return boost::conversion::convert_to<EnumClass>(str.c_str());
+ return boost::conversion::explicit_convert_to<EnumClass>(str.c_str());
}
//!explicit conversion to c-string.
Modified: sandbox/enums/libs/enums/test/Ex.hpp
==============================================================================
--- sandbox/enums/libs/enums/test/Ex.hpp (original)
+++ sandbox/enums/libs/enums/test/Ex.hpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -37,9 +37,9 @@
//~ namespace boost { namespace enums { namespace meta {
//~ template <> struct underlying_type<EC3> { typedef int type; };
//~ } } }
- //~ inline EC3 convert_to(int v , boost::dummy::type_tag<EC3> const& ) { return EC3(v); }
- //~ inline EC3 convert_to(boost::enums::native_type<EC3>::type v , boost::dummy::type_tag<EC3> const& ) { return v; }
- //~ inline int convert_to(EC3 v , boost::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
+ //~ inline EC3 explicit_convert_to(int v , boost::dummy::type_tag<EC3> const& ) { return EC3(v); }
+ //~ inline EC3 explicit_convert_to(boost::enums::native_type<EC3>::type v , boost::dummy::type_tag<EC3> const& ) { return v; }
+ //~ inline int explicit_convert_to(EC3 v , boost::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
//~ namespace boost { namespace enums { namespace meta {
//~ template <> struct size< EC3> { static const std::size_t value=3; };
//~ template <> struct pos<EC3, EC3 :: Enum0> { static const std::size_t value = 0; };
@@ -50,8 +50,8 @@
//~ template <> struct val<EC3, 2> { static const boost::enums::native_type<EC3>::type value = EC3::Enum2; };
//~ template <> struct enum_traits< EC3> : linear_enum_traiter< EC3> {};
//~ } } }
- //~ inline EC3 convert_to( const char* str, boost::dummy::type_tag<EC3> const& ) { if (strcmp( str, "Enum0" ) == 0) { return boost::convert_to<EC3>( EC3::Enum0 ); } if (strcmp( str, "Enum1" ) == 0) { return boost::convert_to<EC3>( EC3::Enum1 ); } if (strcmp( str, "Enum2" ) == 0) { return boost::convert_to<EC3>( EC3::Enum2 ); } throw "invalid string for " "EC3"; }
- //~ inline EC3 convert_to( const std::string& str, boost::dummy::type_tag<EC3> const& ) { return boost::convert_to<EC3>( str.c_str() ); }
+ //~ inline EC3 explicit_convert_to( const char* str, boost::dummy::type_tag<EC3> const& ) { if (strcmp( str, "Enum0" ) == 0) { return boost::explicit_convert_to<EC3>( EC3::Enum0 ); } if (strcmp( str, "Enum1" ) == 0) { return boost::explicit_convert_to<EC3>( EC3::Enum1 ); } if (strcmp( str, "Enum2" ) == 0) { return boost::explicit_convert_to<EC3>( EC3::Enum2 ); } throw "invalid string for " "EC3"; }
+ //~ inline EC3 explicit_convert_to( const std::string& str, boost::dummy::type_tag<EC3> const& ) { return boost::explicit_convert_to<EC3>( str.c_str() ); }
//~ inline const char* c_str(EC3 e) {
//~ switch (boost::enums::native_value(e)) { case EC3::Enum0 : return("Enum0"); case EC3::Enum1 : return("Enum1"); case EC3::Enum2 : return("Enum2"); default: throw "invalid value for " "EC3"; } }
Modified: sandbox/enums/libs/enums/test/Jamfile.v2
==============================================================================
--- sandbox/enums/libs/enums/test/Jamfile.v2 (original)
+++ sandbox/enums/libs/enums/test/Jamfile.v2 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -37,6 +37,8 @@
<toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
<toolset>msvc:<cxxflags>/wd4127
+ #<define>BOOST_OPAQUE_NOT_DEPENDS_ON_CONVERSION
+ <define>BOOST_CONVERSION_DOUBLE_CP
;
test-suite "enum_class"
Modified: sandbox/enums/libs/enums/test/constructible_from_enum.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/constructible_from_enum.cpp (original)
+++ sandbox/enums/libs/enums/test/constructible_from_enum.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -21,7 +21,7 @@
BOOST_TEST(e==EnumClass::Enum2);
}
{ // copy constructor emulation
- EnumClass e1=boost::convert_to<EnumClass>(EnumClass::Enum2);
+ EnumClass e1=boost::explicit_convert_to<EnumClass>(EnumClass::Enum2);
EnumClass e2=e1;
BOOST_TEST(e2==EnumClass::Enum2);
}
Modified: sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/cons/from_enum_pass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -21,7 +21,7 @@
BOOST_TEST(e==EnumClass::Enum2);
}
{ // copy constructor emulation
- EnumClass e1=boost::conversion::convert_to<EnumClass>(EnumClass::Enum2);
+ EnumClass e1=boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Enum2);
EnumClass e2=e1;
BOOST_TEST(e2==EnumClass::Enum2);
}
Modified: sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_invalid_int_fail.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -17,7 +17,7 @@
using namespace boost::enums;
{ // Explicit conversion from invalid int results in run-time error (undefined behavior)
- EnumClass e(boost::conversion::convert_to<EnumClass>((unsigned char)(6)));
+ EnumClass e(boost::conversion::explicit_convert_to<EnumClass>((unsigned char)(6)));
BOOST_TEST((unsigned char)(native_value(e))==(unsigned char)(6));
}
Modified: sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/conversion/explicit_conversion_from_valid_int_pass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -17,7 +17,7 @@
using namespace boost::enums;
{ // Explicit conversion from valid int works
- EnumClass e(boost::conversion::convert_to<EnumClass>((unsigned char)(4)));
+ EnumClass e(boost::conversion::explicit_convert_to<EnumClass>((unsigned char)(4)));
BOOST_TEST(e==EnumClass::Enum1);
}
Modified: sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_class/enum_inside_union_cons.pass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -125,9 +125,9 @@
//~ }
//~ }
//~ namespace Ex {
- //~ inline EC_Cons convert_to(int v , boost::conversion::dummy::type_tag<EC_Cons> const& ) { return EC_Cons(v); }
- //~ inline EC_Cons convert_to(boost::enums::native_type<EC_Cons>::type v , boost::conversion::dummy::type_tag<EC_Cons> const& ) { return v; }
- //~ inline int convert_to(EC_Cons v , boost::conversion::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
+ //~ inline EC_Cons explicit_convert_to(int v , boost::conversion::dummy::type_tag<EC_Cons> const& ) { return EC_Cons(v); }
+ //~ inline EC_Cons explicit_convert_to(boost::enums::native_type<EC_Cons>::type v , boost::conversion::dummy::type_tag<EC_Cons> const& ) { return v; }
+ //~ inline int explicit_convert_to(EC_Cons v , boost::conversion::dummy::type_tag<int> const& ) { return boost::enums::underlying_value(v); }
//~ }
//~ namespace boost {
//~ namespace enums {
@@ -144,8 +144,8 @@
//~ }
//~ }
//~ namespace Ex {
- //~ inline EC_Cons convert_to( const char* str, boost::conversion::dummy::type_tag<EC_Cons> const& ) { if (strcmp( str, "E0" ) == 0) { return boost::conversion::convert_to<EC_Cons>( EC_Cons::E0 ); } if (strcmp( str, "E1" ) == 0) { return boost::conversion::convert_to<EC_Cons>( EC_Cons::E1 ); } if (strcmp( str, "E2" ) == 0) { return boost::conversion::convert_to<EC_Cons>( EC_Cons::E2 ); } throw "invalid string for " "EC_Cons"; }
- //~ inline EC_Cons convert_to( const std::string& str, boost::conversion::dummy::type_tag<EC_Cons> const& ) { return boost::conversion::convert_to<EC_Cons>( str.c_str() ); }
+ //~ inline EC_Cons explicit_convert_to( const char* str, boost::conversion::dummy::type_tag<EC_Cons> const& ) { if (strcmp( str, "E0" ) == 0) { return boost::conversion::explicit_convert_to<EC_Cons>( EC_Cons::E0 ); } if (strcmp( str, "E1" ) == 0) { return boost::conversion::explicit_convert_to<EC_Cons>( EC_Cons::E1 ); } if (strcmp( str, "E2" ) == 0) { return boost::conversion::explicit_convert_to<EC_Cons>( EC_Cons::E2 ); } throw "invalid string for " "EC_Cons"; }
+ //~ inline EC_Cons explicit_convert_to( const std::string& str, boost::conversion::dummy::type_tag<EC_Cons> const& ) { return boost::conversion::explicit_convert_to<EC_Cons>( str.c_str() ); }
//~ inline const char* c_str(EC_Cons e) {
//~ switch (boost::enums::native_value(e)) {
//~ case EC_Cons::E0 : return("E0");
Modified: sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_set/constructible_from_enum.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -21,7 +21,7 @@
BOOST_TEST(e==EnumClass::Enum2);
}
{ // copy constructor emulation
- EnumClass e1=boost::conversion::convert_to<EnumClass>(EnumClass::Enum2);
+ EnumClass e1=boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Enum2);
EnumClass e2=e1;
BOOST_TEST(e2==EnumClass::Enum2);
}
Modified: sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_type/cons/from_enum_pass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -21,7 +21,7 @@
BOOST_TEST(e==EnumClass::Enum2);
}
{ // copy constructor emulation
- EnumClass e1=boost::conversion::convert_to<EnumClass>(EnumClass::Enum2);
+ EnumClass e1=boost::conversion::explicit_convert_to<EnumClass>(EnumClass::Enum2);
EnumClass e2=e1;
BOOST_TEST(e2==EnumClass::Enum2);
}
Modified: sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_invalid_int_fail.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -13,11 +13,32 @@
#include "./EnumType.hpp"
#include <boost/detail/lightweight_test.hpp>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
int main() {
using namespace boost::enums;
{ // Explicit conversion from invalid int results in run-time error (undefined behavior)
- EnumClass e(boost::conversion::convert_to<EnumClass>((unsigned char)(6)));
+ EnumClass e((unsigned char)(6));
+ //EnumClass e(boost::conversion::explicit_convert_to<EnumClass>((unsigned char)(6)));
BOOST_TEST((unsigned char)(native_value(e))==(unsigned char)(6));
}
Modified: sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp
==============================================================================
--- sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp (original)
+++ sandbox/enums/libs/enums/test/enum_type/conversion/explicit_conversion_from_valid_int_pass.cpp 2011-07-21 10:46:18 EDT (Thu, 21 Jul 2011)
@@ -13,11 +13,33 @@
#include "./EnumType.hpp"
#include <boost/detail/lightweight_test.hpp>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
int main() {
using namespace boost::enums;
{ // Explicit conversion from valid int works
- EnumClass e(boost::conversion::convert_to<EnumClass>((unsigned char)(4)));
+ EnumClass e((unsigned char)(4));
+ //EnumClass e(boost::conversion::explicit_convert_to<EnumClass>((unsigned char)(4)));
BOOST_TEST(e==EnumClass::Enum1);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk