ct_gcd_lcm - Compile-Time GCD and LCMIntroductiondetail/ct_gcd_lcm.hpp provides two compile-time algorithms: greatest common divisor and least common multiple. Synopsisnamespace details { namespace pool { template <unsigned A, unsigned B> struct ct_gcd { static const unsigned value = ...; }; template <unsigned A, unsigned B> struct ct_lcm { static const unsigned value = ...; }; } // namespace pool } // namespace details Semantics
NotesSince these are compile-time algorithms, violation of the preconditions will result in a compile-time error. Dependencies
Selected Quotations from the Standard5.19/1: Expressions: Constant Expressions: ". . . An integral constant expression can involve only literals (2.13), enumerators, const variables or static data members of integral or enumeration types initialized with constant expressions (8.5), non-type template parameters of integral or enumeration types, and sizeof expressions. Floating literals (2.13.3) can appear only if they are cast to integral or enumeration types. Only type conversions to integral or enumeration types can be used. In particular, except in sizeof expressions, functions, class objects, pointers, or references shall not be used, and assignment, increment, decrement, function-call, or comma operators shall not be used." Future DirectionsThis header may be replaced by a Boost compile-time algorithms library. Revised 05 December, 2006 Copyright © 2000, 2001 Stephen Cleary (scleary AT jerviswebb DOT com) 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) |