]> git.lyx.org Git - lyx.git/blob - src/support/tostr.h
tostr -> convert and some bformat work
[lyx.git] / src / support / tostr.h
1 // -*- C++ -*-
2 /**
3  * \file tostr.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * A collection of string helper functions that works with string.
13  * Some of these would certainly benefit from a rewrite/optimization.
14  */
15
16 #ifndef TOSTR_H
17 #define TOSTR_H
18
19 #include <boost/static_assert.hpp>
20
21 #include <string>
22
23 template <class Target, class Source>
24 Target convert(Source arg)
25 {
26         // We use a static assert here since we want all instances of
27         // this template to be specializations.
28         BOOST_STATIC_ASSERT(sizeof(bool) == 0);
29         return Target();
30 }
31
32 template<>
33 std::string convert<std::string>(bool);
34
35 template<>
36 std::string convert<std::string>(char);
37
38 template<>
39 std::string convert<std::string>(unsigned short);
40
41 template<>
42 std::string convert<std::string>(int);
43
44 template<>
45 std::string convert<std::string>(unsigned int);
46
47 template<>
48 std::string convert<std::string>(float);
49
50 template<>
51 std::string convert<std::string>(double);
52
53 template<>
54 std::string convert<std::string>(std::string);
55
56 #endif