]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*-----------------------------------------------------------------------------+ |
2 | Copyright (c) 2008-2010: Joachim Faulhaber | |
3 | +------------------------------------------------------------------------------+ | |
4 | Distributed under the Boost Software License, Version 1.0. | |
5 | (See accompanying file LICENCE.txt or copy at | |
6 | http://www.boost.org/LICENSE_1_0.txt) | |
7 | +-----------------------------------------------------------------------------*/ | |
8 | #ifndef BOOST_ICL_TYPE_TRAITS_UNIT_ELEMENT_HPP_JOFA_080912 | |
9 | #define BOOST_ICL_TYPE_TRAITS_UNIT_ELEMENT_HPP_JOFA_080912 | |
10 | ||
11 | #include <string> | |
12 | #include <boost/icl/type_traits/identity_element.hpp> | |
13 | #include <boost/icl/type_traits/succ_pred.hpp> | |
14 | ||
15 | namespace boost{ namespace icl | |
16 | { | |
17 | template <class Type> struct unit_element{ static Type value(); }; | |
18 | ||
19 | template<> inline bool unit_element<bool>::value() { return true;} | |
20 | template<> inline float unit_element<float>::value() { return 1.0; } | |
21 | template<> inline double unit_element<double>::value() { return 1.0; } | |
22 | template<> inline long double unit_element<long double>::value() | |
23 | { return 1.0; } | |
24 | ||
25 | // Smallest 'visible' string that is greater than the empty string. | |
26 | template <> | |
27 | inline std::string unit_element<std::string>::value() | |
28 | { return std::string(" "); } | |
29 | ||
30 | template <class Type> | |
31 | inline Type unit_element<Type>::value() | |
32 | { return icl::succ(identity_element<Type>::value()); } | |
33 | ||
34 | }} // namespace boost icl | |
35 | ||
36 | #endif | |
37 | ||
38 |