2015-10-09 13:24:05 +08:00
|
|
|
/*
|
2016-09-01 03:15:54 +08:00
|
|
|
* Copyright (c) 2015-2016, Roland Bock
|
2015-10-09 13:24:05 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SQLPP_PORTABLE_STATIC_ASSERT_H
|
|
|
|
#define SQLPP_PORTABLE_STATIC_ASSERT_H
|
|
|
|
|
2015-12-25 17:38:13 +08:00
|
|
|
#include <sqlpp11/consistent.h>
|
2016-09-02 17:17:30 +08:00
|
|
|
#include <sqlpp11/inconsistent.h>
|
2015-12-25 17:38:13 +08:00
|
|
|
|
2015-10-09 13:24:05 +08:00
|
|
|
namespace sqlpp
|
|
|
|
{
|
|
|
|
#define SQLPP_PORTABLE_STATIC_ASSERT(name, message) \
|
2015-12-25 04:11:00 +08:00
|
|
|
struct name : std::false_type \
|
2015-10-09 13:24:05 +08:00
|
|
|
{ \
|
2016-09-01 03:15:54 +08:00
|
|
|
template <typename... T> \
|
|
|
|
name(T&&...) \
|
2015-10-09 13:24:05 +08:00
|
|
|
{ \
|
2016-09-01 03:15:54 +08:00
|
|
|
static_assert(wrong_t<T...>::value, message); \
|
2015-10-09 13:24:05 +08:00
|
|
|
} \
|
2016-09-03 18:35:40 +08:00
|
|
|
auto begin() const -> void; \
|
|
|
|
auto end() const -> void; \
|
2015-10-09 13:24:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
template <bool Consistent, typename Assert>
|
|
|
|
struct static_check_impl
|
|
|
|
{
|
|
|
|
using type = Assert;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Assert>
|
|
|
|
struct static_check_impl<true, Assert>
|
|
|
|
{
|
|
|
|
using type = consistent_t;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
template <bool Consistent, typename Assert>
|
|
|
|
using static_check_t = typename detail::static_check_impl<Consistent, Assert>::type;
|
|
|
|
|
|
|
|
namespace detail
|
|
|
|
{
|
2015-12-24 22:28:07 +08:00
|
|
|
template <typename... StaticChecks>
|
2015-10-09 13:24:05 +08:00
|
|
|
struct static_combined_check_impl;
|
|
|
|
|
2015-12-24 22:28:07 +08:00
|
|
|
template <typename StaticCheck, typename... Rest>
|
|
|
|
struct static_combined_check_impl<StaticCheck, Rest...>
|
2015-10-09 13:24:05 +08:00
|
|
|
{
|
2015-12-24 22:28:07 +08:00
|
|
|
using type = StaticCheck;
|
2015-10-09 13:24:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename... Rest>
|
|
|
|
struct static_combined_check_impl<consistent_t, Rest...>
|
|
|
|
{
|
|
|
|
using type = typename static_combined_check_impl<Rest...>::type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct static_combined_check_impl<>
|
|
|
|
{
|
|
|
|
using type = consistent_t;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-12-24 22:28:07 +08:00
|
|
|
template <typename... StaticChecks>
|
|
|
|
using static_combined_check_t = typename detail::static_combined_check_impl<StaticChecks...>::type;
|
2015-10-09 13:24:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|