1 /*-----------------------------------------------------------------------------+ 2 Author: Joachim Faulhaber 3 Copyright (c) 2009-2009: Joachim Faulhaber 4 +------------------------------------------------------------------------------+ 5 Distributed under the Boost Software License, Version 1.0. 6 (See accompanying file LICENCE.txt or copy at 7 http://www.boost.org/LICENSE_1_0.txt) 8 +-----------------------------------------------------------------------------*/ 9 10 namespace mini // minimal implementations for example projects 11 { 12 // A meta implementation of an the logarithm function on integrals 13 template <size_t Argument, size_t Base=2> 14 struct log_{ enum { value = 1 + log_<Argument/Base, Base>::value }; }; 15 16 template <size_t Base>struct log_<1, Base>{ enum { value = 0 }; }; 17 template <size_t Base>struct log_<0, Base>{ enum { value = 0 }; }; 18 19 template <size_t Argument> 20 struct log2_{ enum { value = log_<Argument, 2>::value }; }; 21 22 template <size_t Argument> 23 struct power2_{ enum { value = 1 << Argument }; }; 24 25 } // namespace mini 26 27