Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
is-streamable.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Pawel Kubik (p.kubik@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 
25 #ifndef CARGO_IS_STREAMABLE_HPP
26 #define CARGO_IS_STREAMABLE_HPP
27 
28 #include <sstream>
29 
30 namespace cargo {
31 
32 template<typename T>
34  static std::istream stream;
35 
36  template <typename C> static std::true_type
37  test(decltype(stream >> (*(static_cast<C*>(nullptr)))));
38 
39  template <typename C> static std::false_type
40  test(...);
41 
42  static constexpr bool value = std::is_same<decltype(test<T>(stream)), std::true_type>::value;
43 };
44 
45 template<typename T>
47  static std::ostream stream;
48 
49  template <typename C> static std::true_type
50  test(decltype(stream << (*(static_cast<C*>(nullptr)))));
51 
52  template <typename C> static std::false_type
53  test(...);
54 
55  static constexpr bool value = std::is_same<decltype(test<T>(stream)), std::true_type>::value;
56 };
57 
58 } // namespace cargo
59 
60 #endif // CARGO_IS_STREAMABLE_HPP
61 
static std::true_type test(decltype(stream >>(*(static_cast< C * >(nullptr)))))
Definition: is-streamable.hpp:33
static constexpr bool value
Definition: is-streamable.hpp:42
static constexpr bool value
Definition: is-streamable.hpp:55
Definition: is-streamable.hpp:46
static std::true_type test(decltype(stream<< (*(static_cast< C * >(nullptr)))))
static std::istream stream
Definition: is-streamable.hpp:34
static std::ostream stream
Definition: is-streamable.hpp:47