ISO C++ Standards meeting (Toronto)
Posted September 16th, 2007 . No Comments .
The ISO C++ committee met in Toronto on July 15-20. This is a list of features that was voted into the C++0x draft.
enum class (N2347)
- enumerators are in the scope of their enum
- enumerators and enums do not implicitly convert to int
- enums have a defined underlying type
- backward-compatible
The new enum type is declared using enum class, which does not conflict with existing enums:
enum class E{ E1, E2, E3 = 100, E4 /* = 101 */ };
There is no implicit conversion to or from an integer:
enum class E{ E1, E2, E3 = 100, E4 /* = 101 */ }; void f(E e) { if( e >= 100 ) // error: no E to int conversion ; } int i = E::E2; // error: no E to int conversion
Like a class, the new enum type introduces its own scope.
enum class E{ E1, E2, E3 = 100, E4 /* = 101 */ }; E e1 = E1; // error E e2 = E::E2; // ok
Document: N2347
Saving exceptions (N2179)
Adds language and library support for saving an exception.
//In: <exception> namespace std { typedef unspecified exception_ptr; exception_ptr current_exception(); void rethrow_exception( exception_ptr p ); template< class E > exception_ptr copy_exception( E e ); }
Document: N2179
constexpr (N2235 and N2349)
This language feature permits generalized constant expressions:
constexpr int add(int a, int b) { return a + b; }
Now if you call add() with two compile-time constants, then the result of calling add() is still a compile-time constant.
int arr[ add(1, 2) ];
