Boost.Nowide
is_path.hpp
1 //
2 // Copyright (c) 2020 Alexander Grund
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
9 #define BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
10 
11 #include <type_traits>
12 
13 namespace boost {
14 namespace nowide {
15  namespace detail {
16 
19  template<typename T>
20  struct is_path
21  {
22  template<typename U, U& (U::*)(), U (U::*)() const>
23  struct Check;
24  template<typename U>
25  static std::true_type test(Check<U, &U::make_preferred, &U::filename>*);
26  template<typename U>
27  static std::false_type test(...);
28 
29  static constexpr bool value = decltype(test<T>(0))::value;
30  };
32  template<typename Path, typename Result>
33  using enable_if_path_t = typename std::enable_if<is_path<Path>::value, Result>::type;
34 
35  } // namespace detail
36 } // namespace nowide
37 } // namespace boost
38 
39 #endif