]> git.lyx.org Git - features.git/blob - src/support/convert.h
missed some tostr.h -> convert.h places
[features.git] / src / support / convert.h
1 // -*- C++ -*-
2 /**
3  * \file convert.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 CONVERT_H
17 #define CONVERT_H
18
19 #include <boost/static_assert.hpp>
20
21 #include <string>
22
23
24 #if 0
25 // Commented out since BOOST_STATIC_ASSERT does not work with gcc 4.0
26 template <class Target, class Source>
27 Target convert(Source arg)
28 {
29         // We use a static assert here since we want all instances of
30         // this template to be specializations.
31         BOOST_STATIC_ASSERT(sizeof(bool) == 0);
32         return Target();
33 }
34 #else
35 template <class Target, class Source>
36 Target convert(Source arg);
37 #endif
38
39
40 template<>
41 std::string convert<std::string>(bool);
42
43 template<>
44 std::string convert<std::string>(char);
45
46 template<>
47 std::string convert<std::string>(unsigned short);
48
49 template<>
50 std::string convert<std::string>(int);
51
52 template<>
53 std::string convert<std::string>(unsigned int);
54
55 template<>
56 std::string convert<std::string>(float);
57
58 template<>
59 std::string convert<std::string>(double);
60
61 template<>
62 std::string convert<std::string>(std::string);
63
64 #endif