Читаем Thinking In C++. Volume 2: Practical Programming полностью

  static T epsilon() throw();

  static T round_error() throw();

  static const int min_exponent = 0;

  static const int min_exponent10 = 0;

  static const int max_exponent = 0;

  static const int max_exponent10 = 0;

  static const bool has_infinity = false;

  static const bool has_quiet_NaN = false;

  static const bool has_signaling_NaN = false;

  static const float_denorm_style has_denorm =

                   denorm_absent;

  static const bool has_denorm_loss = false;

  static T infinity() throw();

  static T quiet_NaN() throw();

  static T signaling_NaN() throw();

  static T denorm_min() throw();

  static const bool is_iec559 = false;

  static const bool is_bounded = false;

  static const bool is_modulo = false;

  static const bool traps = false;

  static const bool tinyness_before = false;

  static const float_round_style round_style =

                  round_toward_zero;

};

The header defines specializations for all fundamental, numeric types (in which case the member is_specialized is set to true). To obtain the base for the double version of your floating-point number system, for example, you can use the expression numeric_limits::radix. To find the smallest integer value available, you can use numeric_limits::min( ). Not all members of numeric_limits apply to all fundamental types, of course. (For example, epsilon( ) is only for floating-point types.).

The values that will always be integral are static data members of numeric_limits; those that may not be integral, such as the minimum value for float, are implemented as static inline member functions. This is because C++ allows only integral static data member constants to be initialized inside a class definition. Other members, such as floating-point values, must be initialized at file scope outside the class definition, which is not appropriate in a header file. Since the needed value in that case will be placed in an implementation (.cpp) file, the value will not be available for compile-time optimization. Inline member functions of a class template, on the other hand, can be included in a header file, and thus facilitate compile-time optimization.

In Chapter 3 you saw how traits are used to control the character-processing functionality used by the string classes. The classes std::string and std::wstring are specializations of the std::basic_string template, which is defined as follows:

Перейти на страницу:

Похожие книги

3ds Max 2008
3ds Max 2008

Одни уверены, что нет лучшего способа обучения 3ds Мах, чем прочитать хорошую книгу. Другие склоняются к тому, что эффективнее учиться у преподавателя, который показывает, что и как нужно делать. Данное издание объединяет оба подхода. Его цель – сделать освоение 3ds Мах 2008 максимально быстрым и результативным. Часто после изучения книги у читателя возникают вопросы, почему не получился тот или иной пример. Видеокурс – это гарантия, что такие вопросы не возникнут: ведь автор не только рассказывает, но и показывает, как нужно работать в 3ds Мах.В отличие от большинства интерактивных курсов, где работа в 3ds Мах иллюстрируется на кубиках-шариках, данный видеокурс полностью практический. Все приемы работы с инструментами 3ds Мах 2008 показаны на конкретных примерах, благодаря чему после просмотра курса читатель сможет самостоятельно выполнять даже сложные проекты.

Владимир Антонович Верстак , Владимир Верстак

Программирование, программы, базы данных / Программное обеспечение / Книги по IT