- _to_index which return value 0... size-1
(even if enums are note sequential)
- _from_index used for other way around
- _from_index_nothrow no throw version
- _from_index_unchecked returns invalid enum
in case arg>=size
Code and test cases added.
No documentation updates (my English is too poor for that)
Until recently, CMake reported VS2015 as not supporting constexpr.
However, constexpr support was added in the VS2015 release, and CMake
now reports accordingly.
The constexpr support in VS2015 is too buggy to build Better Enums.
This change disables testing on VS2015 with constexpr support, because
those tests will fail.
Also adapted to a change in the Cygwin path prefix in AppVeyor and
fixed an issue in the Travis build with wget being unable to retrieve
from www.cmake.org's new redirect to cmake.org.
GCC 5.2 is a "bugfix" release over GCC 5.1 - not sure why the GCC team
updated the minor version number. Package managers seem to have dropped
GCC 5.1 and replaced it with 5.2, and I'm guessing usage of 5.1 is
discouraged. The testing code has been updated accordingly.
Travis is still distributing GCC 5.1 as of the time of this writing.
The user-supplied constant names are used to declare an internal enum
type. They end up sharing a namespace with some internal library
values. Those internal values had names not prefixed with underscores.
As a result, it was impossible to declare enum constants with these
names.
Prefixed the internal names with underscores.
Also improved the documentation Makefile not to re-generate the samples
unless the source Markdown files are newer. This should make samples
development easier.
Also reordered compilers so that the very first tested are the ones
that support the most configurations, then immediately followed by
those which are the most likely to fail. Typically, this would be the
oldest ones, or the compiler versions that were the first to support
some major features.
To run tests with the system compiler, execute
make
To run tests with the system compiler in all configurations,
make default-all
To re-generate the examples from the documentation Markdown, and then
test all configurations,
make default-thorough
Other Makefile targets are for exhaustive testing with multiple
locally-installed compilers, or for use on CI servers, and are not for
general use.
Python and CxxTest are still required. On Windows, it is helpful to
have a Cygwin environment with a non-Cygwin CMake, and MSBuild.exe
should be in PATH.
Better Enums is now tested in fewer configurations. C++11 features are
no longer tested on clang 3.3, gcc 4.3-4.6, because CMake claims
(apparently falsely, in some cases) that those compilers don't support
constexpr and enum class.
The so called 'cygwin_fix_command' replaces all instances of '/home'
with 'C:/cygwin/home'. This will cause the tests to fail on linux as
this directory does not exist there.
An alternative constant _size_constant is provided for use in C++98,
for example for declaring arrays.
Also renamed underlying_traits to integral_mapping.
Removed the function are_equal. Comparison is now done by converting
operands to their integral representation, and comparing those. Also
restored ordering of enum values along the same lines (according to
integral representation).
To avoid paying the huge penalty of including iostream and string for
users that don't need those headers, and to avoid creating a second,
optional header file, I resorted to defining the operators as templates
to prevent type checking until the user tries to actually use them. The
stream types and strings are wrapped in a metafunction that depends on
the template parameter. This is basically a hack, but it seems to work.
With this change, the underlying type can be a non-integral type that
provides conversions to and from an integral type. See the test at
test/cxxtest/underlying.h for some examples - though they are more
verbose than strictly necessary, for testing needs.
Move constructors in underlying types are not supported. It has been
difficult so far to get constexpr code not to select the move
constructor, which is generally not constexpr, for various operations.
support to VC++.
The unit test is currently not being run on VC++ due to a problem with CxxTest,
Cygwin, and paths. However, the examples are being compiled and having their
output checked, and the multiple translation unit test is being run.
Running "(cd test ; ./test.py)" should now run tests only using the default
compiler, on a Unix-like system. test.py --all runs tests on the full array of
compilers that I have installed and symlinked on my development machines.
The documentation is now generated from markdown. Samples are generated from the
tutorial pages. Testing is done by a Python script which runs the tests for a
large number of compilers.
This version is not very developer-friendly - the Python scripts need ways of
limiting what compilers they try to run. If you don't have 15 compilers
installed, you won't be able to run the tests in this commit. Fix coming soon.
These modifications ensure enum.h can be used in a wider
selection of end user projects without triggering warnings.
GCC 4.9.2 was used with the following warning flags set:
-Wall -Wextra -Wshadow -Weffc++ -Wno-unused-parameter
-Wno-unused-local-typedefs -Wno-long-long -Wstrict-aliasing
-Werror -pedantic -std=c++1y -Wformat=2 -Wmissing-include-dirs
-Wsync-nand -Wuninitialized -Wconditionally-supported -Wconversion
-Wuseless-cast -Wzero-as-null-pointer-constant
This commit includes the modifications required to enable successful
use of enum.h via both the "test" and "example" directories.
enum.h tries to automatically detect whether it is running with C++11 support.
If not, it emits alternative code that is supposed to work on compilers
supporting C++98 and variadic macros. This code is largely interface-compatible
with the C++11 code, with the following semantic differences:
- No compile-time stringization. This is done upon first use of a function other
than to_integral.
- Implicit conversion to integral types. This is due to the lack of enum class
support.
- The values _name, _names, _values are replaced with functions _name_, _names_,
_values_.
Each Better Enum now has an internal enum class type to which it is convertible,
instead of being convertible to the regular enum that defines its constants.
switch statements are compiled at the enum class type. This comes at the price
of the user having to type +Enum::Constant instead of Enum::Constant in cases,
in order to trigger an explicit promotion of the pre-C++11 enum to Better Enum,
so it can then be implicitly converted to the enum class.
The remaining "hole" is that direct references to constants (Enum::Constant) are
still implicitly convertible to integral types, because they have naked
pre-C++11 enum type.