X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstrings%2Flexicalcast.h;h=c6a17da3491d053b6460399fddea6473ea1ca839;hp=b41654d1537a822f8a13af2d1a0616a4761d0e2f;hb=42ff7c629b2aa7411963bdcc2259a06b1d1de6d3;hpb=4a38eb20402936497cbb75527dd7a7b321f51415 diff --git a/source/strings/lexicalcast.h b/source/strings/lexicalcast.h index b41654d..c6a17da 100644 --- a/source/strings/lexicalcast.h +++ b/source/strings/lexicalcast.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2006-2008 Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_STRINGS_LEXICALCAST_H_ #define MSP_STRINGS_LEXICALCAST_H_ @@ -113,23 +106,51 @@ void operator>>(const LexicalConverter &c, T &v) throw lexical_error("conversion failure"); } -// The main interface to the lexical conversion machinery +// Helper struct to provide partial template specialization + +template +struct LexicalCast; template -inline T lexical_cast(const std::string &s, const Fmt &f = Fmt()) +struct LexicalCast { - LexicalConverter conv(s, f); - T result; - conv>>result; - return result; -} + static T cast(const std::string &s, const Fmt &f = Fmt()) + { + LexicalConverter conv(s, f); + T result; + conv>>result; + return result; + } +}; -template -inline std::string lexical_cast(const T &v, const Fmt &f = Fmt()) +template +struct LexicalCast +{ + static std::string cast(const F &v, const Fmt &f = Fmt()) + { + LexicalConverter conv(f); + conv< +struct LexicalCast +{ + static std::string cast(const std::string &v, const Fmt &f = Fmt()) + { + LexicalConverter conv(f); + conv< +inline T lexical_cast(const F &v, const Fmt &f = Fmt()) { - LexicalConverter conv(f); - conv<::cast(v, f); } } // namespace Msp