//****************************************************************************// // Copyright (C) 2016 Florent Hivert <Florent.Hivert@lri.fr>, // // // // Distributed under the terms of the GNU General Public License (GPL) // // // // This code is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // // General Public License for more details. // // // // The full text of the GPL is available at: // // // // http://www.gnu.org/licenses/ // //****************************************************************************// /** @file *@briefGenericcompiletimepower * *Thegoalofthisfileistobeabletowriteexpressionssuchas@c *pow<23>(2.5)or@cpow<n>(x)wherethefirstexpressionisentirely *computedascompiletimeandthesecondoneisexpandedalsoascompile *timetoaO(logn)longsequenceofmultiplication.Furthermoresuch *expressionnotonlyworksfornumbersforforanytypewherethereisa *neutralelementandanassociative(nonnecessarilycommutative)product, *namelywhatmathematiciancallsa\emonoid.Thisincludeforexample, *stringswheretheneutralelementistheemptystringandtheproductis *theconcatenation. * *seeHPCombi::power_helper::Monoid<std::string> * *@examplestringmonoid.cpp *ThisisanexampleofhowtousepowwithanonnumericalMonoid.
*/
/** Algebraic monoid structure used by default for type T by the pow *functionandprodfunction * *@detailsAMonoidstructureisrequiredtodefinetwostaticmembers *-T#one():theunitofthemonoid *-T#prod(T,T):theproductoftwoelementsinthemonoid * *Bydefaultforanytype\cT,#oneisconstructedfromthelitteral1and *#prodcallstheoperator*.Onecanchangethesedefaultbyspecializing *thetemplateforsomespecifictype\cT.
*/ template <typename T> struct Monoid {
/// The one of type T staticconst T one() { return1; }
/** the product of two elements of type T *@paramathefirstelementtobemultiplied *@parambthesecondelementtobemultiplied *@returntheproducta*b
*/ staticconst T prod(T a, T b) { return a * b; }
};
} // namespace power_helper
} // namespace HPCombi
#endif// HPCOMBI_POWER_HPP_INCLUDED
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-17)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.