mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 12:51:13 +08:00
Remove detail::enable_if_t and move void_t to compat
We have it in the compat/type_traits.h already. void_t is borrowed from c++17
This commit is contained in:
parent
892583582b
commit
f5416f2581
@ -34,7 +34,7 @@
|
|||||||
#define CXX_STD_VER __cplusplus
|
#define CXX_STD_VER __cplusplus
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CXX_STD_VER >= 201703L
|
#if CXX_STD_VER >= 201402L
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
using ::std::enable_if_t;
|
using ::std::enable_if_t;
|
||||||
@ -49,3 +49,31 @@ namespace sqlpp
|
|||||||
} // namespace sqlpp
|
} // namespace sqlpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CXX_STD_VER >= 201703L
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
using std::void_t;
|
||||||
|
} // namespace sqlpp
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace sqlpp
|
||||||
|
{
|
||||||
|
// See https://en.cppreference.com/w/cpp/types/void_t:
|
||||||
|
// "Until the resolution of CWG issue 1558 (a C++11 defect), unused parameters in alias templates were not guaranteed
|
||||||
|
// to ensure SFINAE and could be ignored [...].
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename... T>
|
||||||
|
struct void_impl
|
||||||
|
{
|
||||||
|
using type = void;
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
using void_t = typename detail::void_impl<T...>::type;
|
||||||
|
} // namespace sqlpp
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -49,6 +49,7 @@ namespace sqlpp
|
|||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
|
// index_sequence & make_index_sequence
|
||||||
template <std::size_t... Ints>
|
template <std::size_t... Ints>
|
||||||
class index_sequence
|
class index_sequence
|
||||||
{
|
{
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2013-2015, Roland Bock
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
* other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace sqlpp
|
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <bool B, typename T = void>
|
|
||||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace sqlpp
|
|
@ -31,7 +31,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <sqlpp11/core/detail/enable_if.h>
|
#include <sqlpp11/core/compat/type_traits.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
@ -48,7 +48,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct float_safe_ostringstream_implementation<T, enable_if_t<std::is_floating_point<T>::value>>
|
struct float_safe_ostringstream_implementation<T, ::sqlpp::enable_if_t<std::is_floating_point<T>::value>>
|
||||||
{
|
{
|
||||||
template <typename U>
|
template <typename U>
|
||||||
void operator()(std::ostringstream& os, U&& x) const
|
void operator()(std::ostringstream& os, U&& x) const
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2013-2015, Roland Bock
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer in the documentation and/or
|
|
||||||
* other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace sqlpp
|
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
template <typename T>
|
|
||||||
struct void_impl
|
|
||||||
{
|
|
||||||
using type = void;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using void_t = typename void_impl<T>::type;
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace sqlpp
|
|
@ -30,6 +30,8 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <sqlpp11/core/compat/type_traits.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
{
|
{
|
||||||
template <typename>
|
template <typename>
|
||||||
@ -44,14 +46,14 @@ namespace sqlpp
|
|||||||
struct result_has_size : std::false_type {};
|
struct result_has_size : std::false_type {};
|
||||||
|
|
||||||
template<class DbResult>
|
template<class DbResult>
|
||||||
struct result_has_size<DbResult, void_t<decltype(std::declval<DbResult>().size())>>
|
struct result_has_size<DbResult, ::sqlpp::void_t<decltype(std::declval<DbResult>().size())>>
|
||||||
: std::true_type {};
|
: std::true_type {};
|
||||||
|
|
||||||
template<class DbResult, class = void>
|
template<class DbResult, class = void>
|
||||||
struct result_size_type { using type = void; };
|
struct result_size_type { using type = void; };
|
||||||
|
|
||||||
template<class DbResult>
|
template<class DbResult>
|
||||||
struct result_size_type<DbResult, void_t<decltype(std::declval<DbResult>().size())>>
|
struct result_size_type<DbResult, ::sqlpp::void_t<decltype(std::declval<DbResult>().size())>>
|
||||||
{
|
{
|
||||||
using type = decltype(std::declval<DbResult>().size());
|
using type = decltype(std::declval<DbResult>().size());
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include <sqlpp11/core/portable_static_assert.h>
|
#include <sqlpp11/core/portable_static_assert.h>
|
||||||
#include <sqlpp11/core/detail/type_vector.h>
|
#include <sqlpp11/core/detail/type_vector.h>
|
||||||
#include <sqlpp11/core/detail/type_set.h>
|
#include <sqlpp11/core/detail/type_set.h>
|
||||||
#include <sqlpp11/core/detail/void.h>
|
|
||||||
#include <sqlpp11/core/detail/get_first.h>
|
#include <sqlpp11/core/detail/get_first.h>
|
||||||
|
|
||||||
namespace sqlpp
|
namespace sqlpp
|
||||||
@ -522,7 +521,7 @@ namespace sqlpp
|
|||||||
using type = typename trait##_of_impl<nodes_of_t<T>>::type; \
|
using type = typename trait##_of_impl<nodes_of_t<T>>::type; \
|
||||||
}; \
|
}; \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
struct trait##_of_impl<T, detail::void_t<typename T::_##trait>> \
|
struct trait##_of_impl<T, ::sqlpp::void_t<typename T::_##trait>> \
|
||||||
{ \
|
{ \
|
||||||
using type = typename T::_##trait; \
|
using type = typename T::_##trait; \
|
||||||
}; \
|
}; \
|
||||||
@ -550,7 +549,7 @@ namespace sqlpp
|
|||||||
using type = typename trait##_impl<nodes_of_t<T>>::type; \
|
using type = typename trait##_impl<nodes_of_t<T>>::type; \
|
||||||
}; \
|
}; \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
struct trait##_impl<T, detail::void_t<typename T::_##trait>> \
|
struct trait##_impl<T, ::sqlpp::void_t<typename T::_##trait>> \
|
||||||
{ \
|
{ \
|
||||||
using type = typename T::_##trait; \
|
using type = typename T::_##trait; \
|
||||||
}; \
|
}; \
|
||||||
@ -746,7 +745,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct consistency_check<T, detail::void_t<typename T::_consistency_check>>
|
struct consistency_check<T, ::sqlpp::void_t<typename T::_consistency_check>>
|
||||||
{
|
{
|
||||||
using type = typename T::_consistency_check;
|
using type = typename T::_consistency_check;
|
||||||
};
|
};
|
||||||
@ -854,7 +853,7 @@ namespace sqlpp
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename Db>
|
template <typename Db>
|
||||||
struct serializer_context_of_impl<Db, detail::void_t<typename Db::_serializer_context_t>>
|
struct serializer_context_of_impl<Db, ::sqlpp::void_t<typename Db::_serializer_context_t>>
|
||||||
{
|
{
|
||||||
using type = typename Db::_serializer_context_t;
|
using type = typename Db::_serializer_context_t;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user