forked from boostorg/endian
Endian: add endian_io.hpp, endian_hello_world.cpp, scoped_enum_emulation_test.cpp
git-svn-id: http://svn.boost.org/svn/boost/sandbox/endian@51735 b8fc166d-592f-0410-95f2-cb63ce0dd405
This commit is contained in:
1 parent
7c671f857c
commit
f0e141f087
13 files changed
+895
-41
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// scoped_enum_emulation_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes, 2009
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// See documentation at http://www.boost.org/libs/utility/scoped_enum_emulation.html
|
||||
|
||||
#include <boost/detail/scoped_enum_emulation.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
BOOST_SCOPED_ENUM_START(traffic_light) { red=0, yellow, green }; BOOST_SCOPED_ENUM_END
|
||||
|
||||
BOOST_SCOPED_ENUM_START(algae) { green=0, red, cyan }; BOOST_SCOPED_ENUM_END
|
||||
|
||||
struct color
|
||||
{
|
||||
BOOST_SCOPED_ENUM_START(value_t) { red, green, blue }; BOOST_SCOPED_ENUM_END
|
||||
BOOST_SCOPED_ENUM(value_t) value;
|
||||
};
|
||||
|
||||
void foo( BOOST_SCOPED_ENUM(algae) arg )
|
||||
{
|
||||
BOOST_ASSERT( arg == algae::cyan );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_SCOPED_ENUM(traffic_light) signal( traffic_light::red );
|
||||
BOOST_SCOPED_ENUM(algae) sample( algae::red );
|
||||
|
||||
BOOST_ASSERT( signal == traffic_light::red );
|
||||
BOOST_ASSERT( sample == algae::red );
|
||||
|
||||
foo( algae::cyan );
|
||||
|
||||
color tracker;
|
||||
tracker.value = color::value_t::blue;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user