C++98 Mapping for Constants

Slice constant definitions map to corresponding C++ constant definitions.  For example:

Slice
const bool      AppendByDefault = true;
const byte      LowerNibble = 0x0f;
const string    Advice = "Don't Panic!";
const short     TheAnswer = 42;
const double    PI = 3.1416;

enum Fruit { Apple, Orange, Pear }
const Fruit     FavoriteFruit = Pear;

Here are the generated definitions for these constants:

C++
const bool          AppendByDefault = true;
const Ice::Byte     LowerNibble =     15;
const std::string   Advice =          "Don't Panic!";
const Ice::Short    TheAnswer =       42;
const Ice::Double   PI =              3.1416;

enum Fruit { Apple, Orange, Pear };
const Fruit         FavoriteFruit =   Pear;

All constants are initialized directly in the header file, so they are compile-time constants and can be used in contexts where a compile-time constant expression is required, such as to dimension an array or as the case label of a switch statement.

Non-ASCII characters and universal character names in string literals are mapped to octal escapes in narrow C++ strings, and to universal character names in wide strings (except for characters in the range \u0000 to \u009f that are mapped to octal escapes). For example:

Slice
const string Egg = "œuf"; 
const ["cpp:type:wstring"] string LargeEgg = "gros œuf"; 

const string Heart = "c\u0153ur";
const ["cpp:type:wstring"] string BigHeart = "grand c\u0153ur"; 
const ["cpp:type:wstring"] string Banana = "\U0001F34C";
 
const string DoubleTilde = "~\u007e";
const ["cpp:type:wstring"] string WDoubleTilde = "~\u007e";

is mapped to:

C++
const std::string Egg = "\305\223uf";
const std::wstring LargeEgg = L"gros \u0153uf";
 
const std::string Heart = "c\305\223ur";
const std::wstring BigHeart = L"grand c\u0153ur";
const std::wstring Banana = L"\U0001F34C";
 
const std::string DoubleTilde = "~\176";
const std::string WDoubleTilde = L"~\176";

See Also