整理
This commit is contained in:
38
include/boost/nowide/detail/is_path.hpp
Normal file
38
include/boost/nowide/detail/is_path.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Copyright (c) 2020 Alexander Grund
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
|
||||
#define BOOST_NOWIDE_DETAIL_IS_PATH_HPP_INCLUDED
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace nowide {
|
||||
namespace detail {
|
||||
|
||||
/// Trait to heuristically check for a *\::filesystem::path
|
||||
/// Done by checking for make_preferred and filename member functions with correct signature
|
||||
template<typename T>
|
||||
struct is_path
|
||||
{
|
||||
template<typename U, U& (U::*)(), U (U::*)() const>
|
||||
struct Check;
|
||||
template<typename U>
|
||||
static std::true_type test(Check<U, &U::make_preferred, &U::filename>*);
|
||||
template<typename U>
|
||||
static std::false_type test(...);
|
||||
|
||||
static constexpr bool value = decltype(test<T>(0))::value;
|
||||
};
|
||||
/// SFINAE trait/alias which resolves to Result if the Path is a *\::filesystem::path
|
||||
template<typename Path, typename Result>
|
||||
using enable_if_path_t = typename std::enable_if<is_path<Path>::value, Result>::type;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace nowide
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user