Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
is-visitable.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Piotr Bartosiewicz (p.bartosiewi@partner.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_VISITABLE_HPP
26 #define CARGO_IS_VISITABLE_HPP
27 
28 #include <type_traits>
29 
30 namespace cargo {
31 
32 template <typename T>
34  struct Visitor {};
35 
36  template <typename C> static std::true_type
37  test(decltype(std::declval<C>().template accept(Visitor()))*);
38 
39  template <typename C> static std::false_type
40  test(...);
41 
42  static constexpr bool value = std::is_same<decltype(test<T>(0)), std::true_type>::value;
43 };
44 
48 template <typename T>
49 struct isVisitable : public std::integral_constant<bool, isVisitableHelper__<T>::value> {};
50 
51 } // namespace cargo
52 
53 #endif // CARGO_IS_VISITABLE_HPP
Definition: is-visitable.hpp:33
Definition: is-visitable.hpp:34
static constexpr bool value
Definition: is-visitable.hpp:42
static std::true_type test(decltype(std::declval< C >().template accept(Visitor()))*)
Helper for compile-time checking against existance of template method 'accept'.
Definition: is-visitable.hpp:49