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:
bemandawes
2009-03-12 15:35:35 +00:00
parent 7c671f857c
commit f0e141f087
13 changed files with 895 additions and 41 deletions

View File

@@ -12,6 +12,8 @@
// then a smaller number of cover operations are needed. Define the macro
// BOOST_MINIMAL_INTEGER_COVER_OPERATORS to indicate this.
// Define BOOST_NO_IO_COVER_OPERATORS if I/O cover operations are not desired.
//----------------------------------------------------------------------------//
#ifndef BOOST_INTEGER_COVER_OPERATORS_HPP
@@ -87,6 +89,7 @@ namespace boost
}
# endif
# ifndef BOOST_NO_IO_COVER_OPERATORS
// TODO: stream I/O needs to be templatized on the stream type, so will
// work with wide streams, etc.
@@ -100,6 +103,7 @@ namespace boost
x = i;
return s;
}
# endif
};
} // namespace integer
} // namespace boost

View File

@@ -1,43 +1,37 @@
// Boost endian.hpp header file ---------------------------------------------//
// Boost endian.hpp header file -------------------------------------------------------//
// (C) Copyright Darin Adler 2000
// (C) Copyright Beman Dawes 2006
// (C) Copyright Beman Dawes 2006, 2009
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Original design developed by Darin Adler based on classes developed by Mark
// Borgerding. Four original class templates combined into a single endian
// Borgerding. Four original class templates were combined into a single endian
// class template by Beman Dawes, who also added the unrolled_byte_loops sign
// partial specialization to correctly extend the sign when cover integer size
// differs from endian representation size.
// TODO:
// * Use C++0x scoped enums if available
// * Use C++0x defaulted default constructor if available
// * Propose, use, BOOST_CONSTEXPR.
// * Propose BOOST_EXPLICIT, apply if needed
// * Should there be a conversion to bool?
// TODO: When a compiler supporting constexpr becomes available, try possible uses.
#ifndef BOOST_ENDIAN_HPP
#define BOOST_ENDIAN_HPP
// Pending updates to boost/config.hpp for C++0x, assume that the C++0x feature
// we care about is not present:
#define BOOST_NO_DEFAULTED_FUNCTIONS
#include <boost/config.hpp>
#include <boost/detail/endian.hpp>
#define BOOST_MINIMAL_INTEGER_COVER_OPERATORS
#define BOOST_NO_IO_COVER_OPERATORS
#include <boost/integer/cover_operators.hpp>
#undef BOOST_NO_IO_COVER_OPERATORS
#undef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
#include <boost/type_traits/is_signed.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
#include <iosfwd>
#include <climits>
@@ -154,14 +148,13 @@ namespace boost
# endif
// endian class template and specializations -----------------------------//
// endian class template and specializations ---------------------------------------//
// simulate C++0x scoped enums
namespace endianness { enum enum_t { big, little, native }; }
namespace alignment { enum enum_t { unaligned, aligned }; }
BOOST_SCOPED_ENUM_START(endianness) { big, little, native }; BOOST_SCOPED_ENUM_END
BOOST_SCOPED_ENUM_START(alignment) { unaligned, aligned }; BOOST_SCOPED_ENUM_END
template <endianness::enum_t E, typename T, std::size_t n_bits,
alignment::enum_t A = alignment::unaligned>
template <BOOST_SCOPED_ENUM(endianness) E, typename T, std::size_t n_bits,
BOOST_SCOPED_ENUM(alignment) A = alignment::unaligned>
class endian;
// Specializations that represent unaligned bytes.
@@ -319,7 +312,7 @@ namespace boost
T m_value;
};
// naming convention typedefs --------------------------------------------//
// naming convention typedefs ------------------------------------------------------//
// unaligned big endian signed integer types
typedef endian< endianness::big, int_least8_t, 8 > big8_t;

116
boost/integer/endian_io.hpp Normal file
View File

@@ -0,0 +1,116 @@
// boost/integer/endian_io.hpp -------------------------------------------------------//
// Copyright Beman Dawes, 2009
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
#ifndef BOOST_ENDIAN_IO_HPP
#define BOOST_ENDIAN_IO_HPP
#include <boost/integer/endian.hpp>
#include <boost/utility/enable_if.hpp>
#include <ostream>
#include <istream>
namespace boost
{
namespace integer
{
template< class T > struct is_endian { static const bool value = false; };
template<> struct is_endian<big8_t> { static const bool value = true; };
template<> struct is_endian<big16_t> { static const bool value = true; };
template<> struct is_endian<big24_t> { static const bool value = true; };
template<> struct is_endian<big32_t> { static const bool value = true; };
template<> struct is_endian<big40_t> { static const bool value = true; };
template<> struct is_endian<big48_t> { static const bool value = true; };
template<> struct is_endian<big56_t> { static const bool value = true; };
template<> struct is_endian<big64_t> { static const bool value = true; };
template<> struct is_endian<ubig8_t> { static const bool value = true; };
template<> struct is_endian<ubig16_t> { static const bool value = true; };
template<> struct is_endian<ubig24_t> { static const bool value = true; };
template<> struct is_endian<ubig32_t> { static const bool value = true; };
template<> struct is_endian<ubig40_t> { static const bool value = true; };
template<> struct is_endian<ubig48_t> { static const bool value = true; };
template<> struct is_endian<ubig56_t> { static const bool value = true; };
template<> struct is_endian<ubig64_t> { static const bool value = true; };
template<> struct is_endian<little8_t> { static const bool value = true; };
template<> struct is_endian<little16_t> { static const bool value = true; };
template<> struct is_endian<little24_t> { static const bool value = true; };
template<> struct is_endian<little32_t> { static const bool value = true; };
template<> struct is_endian<little40_t> { static const bool value = true; };
template<> struct is_endian<little48_t> { static const bool value = true; };
template<> struct is_endian<little56_t> { static const bool value = true; };
template<> struct is_endian<little64_t> { static const bool value = true; };
template<> struct is_endian<ulittle8_t> { static const bool value = true; };
template<> struct is_endian<ulittle16_t> { static const bool value = true; };
template<> struct is_endian<ulittle24_t> { static const bool value = true; };
template<> struct is_endian<ulittle32_t> { static const bool value = true; };
template<> struct is_endian<ulittle40_t> { static const bool value = true; };
template<> struct is_endian<ulittle48_t> { static const bool value = true; };
template<> struct is_endian<ulittle56_t> { static const bool value = true; };
template<> struct is_endian<ulittle64_t> { static const bool value = true; };
template<> struct is_endian<native8_t> { static const bool value = true; };
template<> struct is_endian<native16_t> { static const bool value = true; };
template<> struct is_endian<native24_t> { static const bool value = true; };
template<> struct is_endian<native32_t> { static const bool value = true; };
template<> struct is_endian<native40_t> { static const bool value = true; };
template<> struct is_endian<native48_t> { static const bool value = true; };
template<> struct is_endian<native56_t> { static const bool value = true; };
template<> struct is_endian<native64_t> { static const bool value = true; };
template<> struct is_endian<unative8_t> { static const bool value = true; };
template<> struct is_endian<unative16_t> { static const bool value = true; };
template<> struct is_endian<unative24_t> { static const bool value = true; };
template<> struct is_endian<unative32_t> { static const bool value = true; };
template<> struct is_endian<unative40_t> { static const bool value = true; };
template<> struct is_endian<unative48_t> { static const bool value = true; };
template<> struct is_endian<unative56_t> { static const bool value = true; };
template<> struct is_endian<unative64_t> { static const bool value = true; };
# if defined(BOOST_HAS_INT16_T)
template<> struct is_endian<aligned_big16_t> { static const bool value = true; };
template<> struct is_endian<aligned_ubig16_t> { static const bool value = true; };
template<> struct is_endian<aligned_little16_t> { static const bool value = true; };
template<> struct is_endian<aligned_ulittle16_t> { static const bool value = true; };
# endif
# if defined(BOOST_HAS_INT32_T)
template<> struct is_endian<aligned_big32_t> { static const bool value = true; };
template<> struct is_endian<aligned_ubig32_t> { static const bool value = true; };
template<> struct is_endian<aligned_little32_t> { static const bool value = true; };
template<> struct is_endian<aligned_ulittle32_t> { static const bool value = true; };
# endif
# if defined(BOOST_HAS_INT64_T)
template<> struct is_endian<aligned_big64_t> { static const bool value = true; };
template<> struct is_endian<aligned_ubig64_t> { static const bool value = true; };
template<> struct is_endian<aligned_little64_t> { static const bool value = true; };
template<> struct is_endian<aligned_ulittle64_t> { static const bool value = true; };
# endif
template < class Endian >
inline typename boost::enable_if< is_endian<Endian>, std::ostream & >::type
operator<<( std::ostream & os, const Endian & e )
{
return os.write( reinterpret_cast<const char*>(&e), sizeof(e) );
}
template < class Endian >
inline typename boost::enable_if< is_endian<Endian>, std::ostream & >::type
operator>>( std::ostream & os, const Endian & e )
{
return os.read( reinterpret_cast<const char*>(&e), sizeof(e) );
}
} // namespace integer
} // namespace boost
#endif // BOOST_ENDIAN_IO_HPP

29
doc/html/minimal.css Normal file
View File

@@ -0,0 +1,29 @@
/*
<20> Copyright Beman Dawes, 2007
Distributed under the Boost Software License, Version 1.0.
See www.boost.org/LICENSE_1_0.txt
*/
/*******************************************************************************
Body
*******************************************************************************/
body { font-family: sans-serif; margin: 1em; }
/*******************************************************************************
Table
*******************************************************************************/
table { margin: 0.5em; }
/*******************************************************************************
Font sizes
*******************************************************************************/
p, td, li, blockquote { font-size: 10pt; }
pre { font-size: 9pt; }
/*** end ***/

View File

@@ -6,26 +6,61 @@
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Boost Endian Integers</title>
<link rel="stylesheet" type="text/css" href="../../../doc/html/minimal.css">
</head>
<body>
<h1>Boost Endian Integers (<a href="../../../boost/integer/endian.hpp">boost/integer/endian.hpp</a>)</h1>
<p><a href="#Introduction">Introduction</a><br>
<a href="#Limitations">Limitations</a><br>
<a href="#Feature-set">Feature set</a><br>
<a href="#Types">Typedefs</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Comment-on-naming">Comment on naming</a><br>
<a href="#Class_template_endian">Class template <code>endian</code></a><br>
&nbsp;&nbsp;&nbsp;
<a href="#Synopsis">Synopsis</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Members">Members</a><br>
<a href="#FAQ">FAQ</a><br>
<a href="#Example">Example</a><br>
<a href="#Design">Design</a><br>
<a href="#Experience">Experience</a><br>
<a href="#Acknowledgements">Acknowledgements</a></p>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="277">
<a href="../../../index.html">
<img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="277" height="86" border="0"></a></td>
<td width="337" align="middle">
<font size="7">Endian Integers</font>
</td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="100%">
<tr>
<td><a href="../../../index.htm">Boost Home</a>&nbsp; Tutorial</td>
</tr>
</table>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" align="right">
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<i><b>Contents</b></i></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
<a href="#Limitations">Limitations</a><br>
<a href="#Feature-set">Feature set</a><br>
<a href="#Types">Typedefs</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Comment-on-naming">Comment on naming</a><br>
<a href="#Class_template_endian">Class template <code>endian</code></a><br>
&nbsp;&nbsp;&nbsp;
<a href="#Synopsis">Synopsis</a><br>
&nbsp;&nbsp;&nbsp; <a href="#Members">Members</a><br>
<a href="#FAQ">FAQ</a><br>
<a href="#Example">Example</a><br>
<a href="#Design">Design</a><br>
<a href="#Experience">Experience</a><br>
<a href="#Acknowledgements">Acknowledgements</a>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#D7EEFF" align="center">
<b><i>Headers</i></b></td>
</tr>
<tr>
<td width="100%" bgcolor="#E8F5FF">
<a href="../../../boost/integer/endian.hpp">&lt;boost/integer/endian.hpp&gt;</a></td>
</tr>
</table>
<h2><a name="Introduction">Introduction</a></h2>
<p>The <a href="../../../boost/integer/endian.hpp">boost/integer/endian.hpp</a> header provides
integer-like byte-holder binary types with explicit control over
@@ -514,7 +549,7 @@ Tomas Puverle, and
Yuval Ronen.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->06 August, 2008<!--webbot bot="Timestamp" endspan i-checksum="34800" --></p>
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->11 March, 2009<!--webbot bot="Timestamp" endspan i-checksum="29023" --></p>
<p><EFBFBD> Copyright Beman Dawes, 2006</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at

View File

@@ -0,0 +1,24 @@
// endian_io_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 library home page at http://www.boost.org/libs/endian
#include <boost/integer/endian_io.hpp>
#include <iostream>
using namespace boost;
using namespace boost::integer;
int main()
{
long value = 3224115L; // integer value of ASCII { '1', '2', '3' }
big24_t big( value );
little24_t little( value );
std::cout << "Hello, endian world "<< value << ' ' << big << ' ' << little << '\n';
}

View File

@@ -7,7 +7,10 @@
# See library home page at http://www.boost.org/libs/endian
import testing ;
test-suite "endian"
: [ run libs/integer/test/endian_test.cpp ]
: [ run endian_test.cpp ]
# [ run endian_operations_test.cpp ]
# [ run endian_in_union_test.cpp ]
;

View File

@@ -10,4 +10,9 @@
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(BOOST_SANDBOX)\endian&quot;;&quot;$(BOOST_TRUNK)&quot;"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Executing test $(TargetName).exe..."
CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot;"
/>
</VisualStudioPropertySheet>

View File

@@ -7,6 +7,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "end
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_operations_test", "endian_operations_test\endian_operations_test.vcproj", "{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_enum_emulation_test", "scoped_enum_emulation_test\scoped_enum_emulation_test.vcproj", "{8420E151-B23B-4651-B526-6AB11EF1E278}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_example", "endian_example\endian_example.vcproj", "{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_hello_world", "endian_hello_world\endian_hello_world.vcproj", "{1AAEBB4E-501E-417E-9531-04469AF5DD8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -25,6 +31,18 @@ Global
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.Build.0 = Debug|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.ActiveCfg = Release|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.Build.0 = Release|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.ActiveCfg = Debug|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.Build.0 = Debug|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.ActiveCfg = Release|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.Build.0 = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.Build.0 = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.ActiveCfg = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.Build.0 = Release|Win32
{1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Debug|Win32.ActiveCfg = Debug|Win32
{1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Debug|Win32.Build.0 = Debug|Win32
{1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Release|Win32.ActiveCfg = Release|Win32
{1AAEBB4E-501E-417E-9531-04469AF5DD8B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="endian_example"
ProjectGUID="{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}"
RootNamespace="endian_example"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\example\endian_example.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="endian_hello_world"
ProjectGUID="{1AAEBB4E-501E-417E-9531-04469AF5DD8B}"
RootNamespace="endian_hello_world"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\example\endian_hello_world.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="scoped_enum_emulation_test"
ProjectGUID="{8420E151-B23B-4651-B526-6AB11EF1E278}"
RootNamespace="scoped_enum_emulation_test"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\scoped_enum_emulation_test.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -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;
}