Removed the type trait alias wrappers
This completely removes the wrappers for aliases included in c++14. It also enables
use of the value alias wrappers, since we now have variable templates.
(cherry-picked from commit c1fcba17b7
)
This commit is contained in:
parent
4f1c4dcafd
commit
7785d711ed
12 changed files with 71 additions and 141 deletions
|
@ -28,7 +28,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <ctime>
|
||||
|
@ -172,7 +171,7 @@ public:
|
|||
config_attribute_value& operator=(const std::string &v);
|
||||
config_attribute_value& operator=(const t_string &v);
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, config_attribute_value&> operator=(const T &v)
|
||||
std::enable_if_t<std::is_base_of<enum_tag, T>::value, config_attribute_value&> operator=(const T &v)
|
||||
{
|
||||
return operator=(T::enum_to_string(v));
|
||||
}
|
||||
|
@ -196,7 +195,7 @@ public:
|
|||
TODO: Fix this in c++11 using constexpr types.
|
||||
*/
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, T> to_enum(const T &v) const
|
||||
std::enable_if_t<std::is_base_of<enum_tag, T>::value, T> to_enum(const T &v) const
|
||||
{
|
||||
return T::string_to_enum(this->str(), v);
|
||||
}
|
||||
|
@ -223,14 +222,14 @@ public:
|
|||
// These function prevent t_string creation in case of c["a"] == "b" comparisons.
|
||||
// The templates are needed to prevent using these function in case of c["a"] == 0 comparisons.
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<const std::string, utils::add_const_t<T>>::value, bool>
|
||||
std::enable_if_t<std::is_same<const std::string, std::add_const_t<T>>::value, bool>
|
||||
friend operator==(const config_attribute_value &val, const T &str)
|
||||
{
|
||||
return val.equals(str);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<const char*, T>::value, bool>
|
||||
std::enable_if_t<std::is_same<const char*, T>::value, bool>
|
||||
friend operator==(const config_attribute_value& val, T str)
|
||||
{
|
||||
return val.equals(std::string(str));
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "serialization/unicode_types.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <SDL_events.h>
|
||||
|
||||
|
@ -358,7 +357,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event, E>::value>
|
||||
std::enable_if_t<has_key<set_event, E>::value>
|
||||
connect_signal(const signal_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -376,7 +375,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event, E>::value>
|
||||
std::enable_if_t<has_key<set_event, E>::value>
|
||||
disconnect_signal(const signal_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -391,7 +390,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
std::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
connect_signal(const signal_mouse_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -409,7 +408,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
std::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
disconnect_signal(const signal_mouse_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -424,7 +423,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
std::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
connect_signal(const signal_keyboard_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -442,7 +441,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
std::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
disconnect_signal(const signal_keyboard_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -457,7 +456,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
std::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
connect_signal(const signal_touch_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -475,7 +474,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
std::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
disconnect_signal(const signal_touch_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -493,7 +492,7 @@ public:
|
|||
* and shouldn't be used.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
std::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
connect_signal(const signal_notification_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -516,7 +515,7 @@ public:
|
|||
* front_pre_child)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
std::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
disconnect_signal(const signal_notification_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -534,7 +533,7 @@ public:
|
|||
* and shouldn't be used.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_message, E>::value>
|
||||
std::enable_if_t<has_key<set_event_message, E>::value>
|
||||
connect_signal(const signal_message_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -557,7 +556,7 @@ public:
|
|||
* front_pre_child)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_message, E>::value>
|
||||
std::enable_if_t<has_key<set_event_message, E>::value>
|
||||
disconnect_signal(const signal_message_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -572,7 +571,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
std::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
connect_signal(const signal_raw_event_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -590,7 +589,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
std::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
disconnect_signal(const signal_raw_event_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -605,7 +604,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_text_input, E>::value>
|
||||
std::enable_if_t<has_key<set_event_text_input, E>::value>
|
||||
connect_signal(const signal_text_input_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -623,7 +622,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
utils::enable_if_t<has_key<set_event_text_input, E>::value>
|
||||
std::enable_if_t<has_key<set_event_text_input, E>::value>
|
||||
disconnect_signal(const signal_text_input_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "gui/core/event/dispatcher.hpp"
|
||||
|
||||
#include "gui/widgets/widget.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <SDL_events.h>
|
||||
|
||||
|
@ -61,7 +60,7 @@ struct dispatcher_implementation
|
|||
* dispatcher::signal_type<FUNCTION> \
|
||||
*/ \
|
||||
template<typename F> \
|
||||
static utils::enable_if_t<std::is_same<F, FUNCTION>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
static std::enable_if_t<std::is_same<F, FUNCTION>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
event_signal(dispatcher& dispatcher, const ui_event event) \
|
||||
{ \
|
||||
return dispatcher.QUEUE.queue[event]; \
|
||||
|
@ -81,7 +80,7 @@ struct dispatcher_implementation
|
|||
* dispatcher::signal_type<FUNCTION> \
|
||||
*/ \
|
||||
template<typename K> \
|
||||
static utils::enable_if_t<boost::mpl::has_key<SET, K>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
static std::enable_if_t<boost::mpl::has_key<SET, K>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
event_signal(dispatcher& dispatcher, const ui_event event) \
|
||||
{ \
|
||||
return dispatcher.QUEUE.queue[event]; \
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "gui/widgets/styled_widget.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
@ -28,7 +27,7 @@ namespace gui2
|
|||
* Default value getter for selectable widgets (like toggle buttons)
|
||||
*/
|
||||
template<typename T>
|
||||
static inline utils::enable_if_t<std::is_base_of<selectable_item, T>::value, std::string>
|
||||
static inline std::enable_if_t<std::is_base_of<selectable_item, T>::value, std::string>
|
||||
default_status_value_getter(T& w)
|
||||
{
|
||||
return w.get_value_bool() ? _("yes") : _("no");
|
||||
|
@ -38,7 +37,7 @@ default_status_value_getter(T& w)
|
|||
* Default value getter for integer-based widgets (like sliders)
|
||||
*/
|
||||
template<typename T>
|
||||
static inline utils::enable_if_t<std::is_base_of<integer_selector, T>::value, std::string>
|
||||
static inline std::enable_if_t<std::is_base_of<integer_selector, T>::value, std::string>
|
||||
default_status_value_getter(T& w)
|
||||
{
|
||||
return w.get_value_label();
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
@ -171,7 +169,7 @@ struct lexical_caster<
|
|||
std::string
|
||||
, From
|
||||
, void
|
||||
, utils::enable_if_t<std::is_integral<utils::remove_pointer_t<From>>::value>
|
||||
, std::enable_if_t<std::is_integral<std::remove_pointer_t<From>>::value>
|
||||
>
|
||||
{
|
||||
std::string operator()(From value, boost::optional<std::string>) const
|
||||
|
@ -196,7 +194,7 @@ struct lexical_caster<
|
|||
long long
|
||||
, From
|
||||
, void
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
, std::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
long long operator()(From value, boost::optional<long long> fallback) const
|
||||
|
@ -251,8 +249,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, utils::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
, std::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
, std::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -276,7 +274,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, utils::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
, std::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
@ -309,8 +307,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, utils::enable_if_t<std::is_floating_point<To>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
, std::enable_if_t<std::is_floating_point<To>::value>
|
||||
, std::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -334,7 +332,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, utils::enable_if_t<std::is_floating_point<To>::value>
|
||||
, std::enable_if_t<std::is_floating_point<To>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
@ -379,7 +377,7 @@ struct lexical_caster<
|
|||
unsigned long long
|
||||
, From
|
||||
, void
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
, std::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
unsigned long long operator()(From value, boost::optional<unsigned long long> fallback) const
|
||||
|
@ -435,8 +433,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, utils::enable_if_t<std::is_unsigned<To>::value && !std::is_same<To, unsigned long long>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
, std::enable_if_t<std::is_unsigned<To>::value && !std::is_same<To, unsigned long long>::value>
|
||||
, std::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -460,7 +458,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, utils::enable_if_t<std::is_unsigned<To>::value>
|
||||
, std::enable_if_t<std::is_unsigned<To>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "units/unit.hpp"
|
||||
#include "units/attack_type.hpp"
|
||||
#include "utils/const_clone.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include "lua/lauxlib.h"
|
||||
#include "lua/lua.h" // for lua_State, lua_settop, etc
|
||||
|
@ -90,7 +89,7 @@ attack_type& luaW_checkweapon(lua_State* L, int idx)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
using attack_ptr_in = std::shared_ptr<utils::const_clone_t<attack_type, utils::remove_pointer_t<T>>>;
|
||||
using attack_ptr_in = std::shared_ptr<utils::const_clone_t<attack_type, std::remove_pointer_t<T>>>;
|
||||
|
||||
// Note that these two templates are designed on the assumption that T is either unit or unit_type
|
||||
template<typename T>
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include "lua/lauxlib.h"
|
||||
#include "lua/lua.h"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
class enum_tag;
|
||||
|
@ -44,7 +42,7 @@ namespace lua_check_impl
|
|||
BOOST_MPL_HAS_XXX_TRAIT_DEF(second_type)
|
||||
}
|
||||
|
||||
template<typename T, typename T2 = utils::remove_reference_t<T>>
|
||||
template<typename T, typename T2 = std::remove_reference_t<T>>
|
||||
struct is_container
|
||||
: boost::mpl::bool_<
|
||||
detail::has_value_type<T2>::value &&
|
||||
|
@ -54,7 +52,7 @@ namespace lua_check_impl
|
|||
>
|
||||
{};
|
||||
|
||||
template<typename T, typename T2 = utils::remove_reference_t<T>>
|
||||
template<typename T, typename T2 = std::remove_reference_t<T>>
|
||||
struct is_map
|
||||
: boost::mpl::bool_<
|
||||
detail::has_key_type<T2>::value &&
|
||||
|
@ -62,7 +60,7 @@ namespace lua_check_impl
|
|||
>
|
||||
{};
|
||||
|
||||
template<typename T, typename T2 = utils::remove_reference_t<T>>
|
||||
template<typename T, typename T2 = std::remove_reference_t<T>>
|
||||
struct is_pair
|
||||
: boost::mpl::bool_<
|
||||
detail::has_first_type<T2>::value &&
|
||||
|
@ -71,17 +69,17 @@ namespace lua_check_impl
|
|||
{};
|
||||
|
||||
template<typename T>
|
||||
using remove_constref = utils::remove_const_t<utils::remove_reference_t<utils::remove_const_t<T>>>;
|
||||
using remove_constref = std::remove_const_t<std::remove_reference_t<std::remove_const_t<T>>>;
|
||||
|
||||
//std::string
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, std::string>::value, std::string>
|
||||
std::enable_if_t<std::is_same<T, std::string>::value, std::string>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checkstring(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, std::string>::value, void>
|
||||
std::enable_if_t<std::is_same<T, std::string>::value, void>
|
||||
lua_push(lua_State *L, const T& val)
|
||||
{
|
||||
lua_pushlstring(L, val.c_str(), val.size());
|
||||
|
@ -89,13 +87,13 @@ namespace lua_check_impl
|
|||
|
||||
//config
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, config>::value, config>
|
||||
std::enable_if_t<std::is_same<T, config>::value, config>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checkconfig(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, config>::value, void>
|
||||
std::enable_if_t<std::is_same<T, config>::value, void>
|
||||
lua_push(lua_State *L, const config& val)
|
||||
{
|
||||
luaW_pushconfig(L, val);
|
||||
|
@ -103,13 +101,13 @@ namespace lua_check_impl
|
|||
|
||||
//location
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, map_location>::value, map_location>
|
||||
std::enable_if_t<std::is_same<T, map_location>::value, map_location>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checklocation(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, map_location>::value, void>
|
||||
std::enable_if_t<std::is_same<T, map_location>::value, void>
|
||||
lua_push(lua_State *L, const map_location& val)
|
||||
{
|
||||
luaW_pushlocation(L, val);
|
||||
|
@ -117,7 +115,7 @@ namespace lua_check_impl
|
|||
|
||||
//enums generated by MAKE_ENUM
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, T>
|
||||
std::enable_if_t<std::is_base_of<enum_tag, T>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
T val;
|
||||
|
@ -129,7 +127,7 @@ namespace lua_check_impl
|
|||
return val;
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, void>
|
||||
std::enable_if_t<std::is_base_of<enum_tag, T>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_check_impl::lua_push(L, val.to_string());
|
||||
|
@ -137,13 +135,13 @@ namespace lua_check_impl
|
|||
|
||||
//t_string
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, t_string>::value, t_string>
|
||||
std::enable_if_t<std::is_same<T, t_string>::value, t_string>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checktstring(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, t_string>::value, void>
|
||||
std::enable_if_t<std::is_same<T, t_string>::value, void>
|
||||
lua_push(lua_State *L, const t_string& val)
|
||||
{
|
||||
luaW_pushtstring(L, val);
|
||||
|
@ -151,13 +149,13 @@ namespace lua_check_impl
|
|||
|
||||
//bool
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, bool>::value, bool>
|
||||
std::enable_if_t<std::is_same<T, bool>::value, bool>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_toboolean(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_same<T, bool>::value, void>
|
||||
std::enable_if_t<std::is_same<T, bool>::value, void>
|
||||
lua_push(lua_State *L, bool val)
|
||||
{
|
||||
lua_pushboolean(L, val);
|
||||
|
@ -165,13 +163,13 @@ namespace lua_check_impl
|
|||
|
||||
//double, float
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_floating_point<T>::value, T>
|
||||
std::enable_if_t<std::is_floating_point<T>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checknumber(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_floating_point<T>::value, void>
|
||||
std::enable_if_t<std::is_floating_point<T>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_pushnumber(L, val);
|
||||
|
@ -179,14 +177,14 @@ namespace lua_check_impl
|
|||
|
||||
//integer types
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>
|
||||
std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checkinteger(L, n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
utils::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, void>
|
||||
std::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_pushnumber(L, val);
|
||||
|
@ -195,7 +193,7 @@ namespace lua_check_impl
|
|||
//std::pair
|
||||
//Not sure if the not_<is_const> is required; only (maybe) if std::map matches is_container
|
||||
template<typename T>
|
||||
utils::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, T>
|
||||
std::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
T result;
|
||||
|
@ -209,7 +207,7 @@ namespace lua_check_impl
|
|||
return result;
|
||||
}
|
||||
template<typename T>
|
||||
utils::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, void>
|
||||
std::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, void>
|
||||
lua_push(lua_State *L, const T& val)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
@ -221,7 +219,7 @@ namespace lua_check_impl
|
|||
|
||||
//std::vector and similar but not std::string
|
||||
template<typename T>
|
||||
utils::enable_if_t<is_container<T>::value && !std::is_same<T, std::string>::value, T>
|
||||
std::enable_if_t<is_container<T>::value && !std::is_same<T, std::string>::value, T>
|
||||
lua_check(lua_State * L, int n)
|
||||
{
|
||||
if (lua_istable(L, n))
|
||||
|
@ -251,7 +249,7 @@ namespace lua_check_impl
|
|||
|
||||
//also accepts things like std::vector<int>() | std::adaptors::transformed(..)
|
||||
template<typename T>
|
||||
utils::enable_if_t<
|
||||
std::enable_if_t<
|
||||
is_container<T>::value && !std::is_same<T, std::string>::value && !is_map<T>::value
|
||||
, void
|
||||
>
|
||||
|
@ -270,7 +268,7 @@ namespace lua_check_impl
|
|||
|
||||
//accepts std::map TODO: add a check function for that
|
||||
template<typename T>
|
||||
utils::enable_if_t<is_map<T>::value, void>
|
||||
std::enable_if_t<is_map<T>::value, void>
|
||||
lua_push(lua_State * L, const T& map )
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "units/ptr.hpp"
|
||||
#include "units/types.hpp"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <bitset>
|
||||
#include <boost/dynamic_bitset_fwd.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
@ -1022,7 +1020,7 @@ public:
|
|||
struct upkeep_type_visitor : public boost::static_visitor<std::string>
|
||||
{
|
||||
template<typename T>
|
||||
utils::enable_if_t<!std::is_same<int, T>::value, std::string>
|
||||
std::enable_if_t<!std::is_same<int, T>::value, std::string>
|
||||
operator()(T&) const
|
||||
{
|
||||
// Any special upkeep type should have an associated @ref type getter in its helper struct.
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace utils
|
||||
|
@ -39,22 +37,22 @@ struct const_clone
|
|||
{
|
||||
static const bool is_source_const =
|
||||
std::is_const<
|
||||
utils::remove_pointer_t<
|
||||
utils::remove_reference_t<S>
|
||||
std::remove_pointer_t<
|
||||
std::remove_reference_t<S>
|
||||
>
|
||||
>::value;
|
||||
|
||||
/** The destination type, possibly const qualified. */
|
||||
using type =
|
||||
utils::conditional_t<is_source_const, const D, D>;
|
||||
std::conditional_t<is_source_const, const D, D>;
|
||||
|
||||
/** A reference to the destination type, possibly const qualified. */
|
||||
using reference =
|
||||
utils::conditional_t<is_source_const, const D&, D&>;
|
||||
std::conditional_t<is_source_const, const D&, D&>;
|
||||
|
||||
/** A pointer to the destination type, possibly const qualified. */
|
||||
using pointer =
|
||||
utils::conditional_t<is_source_const, const D*, D*>;
|
||||
std::conditional_t<is_source_const, const D*, D*>;
|
||||
};
|
||||
|
||||
template<typename D, typename S>
|
||||
|
|
|
@ -19,60 +19,6 @@
|
|||
|
||||
namespace utils
|
||||
{
|
||||
//
|
||||
// These aliases are part of the standard starting with C++14.
|
||||
// MSVC included them itself starting from VS2013 (our min supported version).
|
||||
// However, they can't be used via alias templates in VS2013 due to lack of
|
||||
// support for expression SFINAE.
|
||||
// Forward to their declarations as appropriate.
|
||||
//
|
||||
#if defined(HAVE_CXX14) || _MSC_VER >= 1900
|
||||
|
||||
template<typename T>
|
||||
using add_const_t = std::add_const_t<T>;
|
||||
template<bool B, typename T, typename F>
|
||||
using conditional_t = std::conditional_t<B, T, F>;
|
||||
template<bool B, typename T = void>
|
||||
using enable_if_t = std::enable_if_t<B, T>;
|
||||
template<typename T>
|
||||
using remove_const_t = std::remove_const_t<T>;
|
||||
template<typename T>
|
||||
using remove_reference_t = std::remove_reference_t<T>;
|
||||
template<typename T>
|
||||
using remove_pointer_t = std::remove_pointer_t<T>;
|
||||
|
||||
#else // We do not have C++14 or MSVC >= 2015
|
||||
|
||||
// add_const
|
||||
template<typename T>
|
||||
using add_const_t = typename std::add_const<T>::type;
|
||||
|
||||
// conditional
|
||||
template<bool B, typename T, typename F>
|
||||
using conditional_t = typename std::conditional<B, T, F>::type;
|
||||
|
||||
// enable_if
|
||||
template<bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
// remove_const
|
||||
template<typename T>
|
||||
using remove_const_t = typename std::remove_const<T>::type;
|
||||
|
||||
// remove_reference
|
||||
template<typename T>
|
||||
using remove_reference_t = typename std::remove_reference<T>::type;
|
||||
|
||||
// remove_pointer
|
||||
template<typename T>
|
||||
using remove_pointer_t = typename std::remove_pointer<T>::type;
|
||||
|
||||
#endif // defined(HAVE_CXX14) || _MSC_VER >= 1900
|
||||
|
||||
// Since there's really no way to implement these without variable templates, I've commented
|
||||
// this whole section out until we bump our min compiler support to VS 2015 and GCC 5.
|
||||
#if 0
|
||||
|
||||
//
|
||||
// These aliases are part of the standard starting with C++17.
|
||||
// However, MSVC includes them as of VS 2015 Update 2, and they can also be implemented
|
||||
|
@ -83,7 +29,7 @@ using remove_pointer_t = typename std::remove_pointer<T>::type;
|
|||
using std::is_base_of_v;
|
||||
using std::is_same_v;
|
||||
|
||||
#elif defined(HAVE_CXX14)
|
||||
#else
|
||||
|
||||
// is_base_of
|
||||
template<typename Base, typename Derived>
|
||||
|
@ -95,6 +41,4 @@ static constexpr bool is_same_v = std::is_same<T, U>::value;
|
|||
|
||||
#endif // HAVE_CXX17
|
||||
|
||||
#endif
|
||||
|
||||
} // end namespace utils
|
||||
|
|
|
@ -39,7 +39,7 @@ typename V::result_t apply_visitor(typename V::param_t state, T&&... args)
|
|||
static_assert(std::is_base_of<
|
||||
info_visitor_base<
|
||||
typename V::result_t,
|
||||
utils::remove_reference_t<typename V::param_t>>,
|
||||
std::remove_reference_t<typename V::param_t>>,
|
||||
V>::value, "Invalid visitor type.");
|
||||
|
||||
// Create the visitor.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "config.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
@ -100,7 +99,7 @@ public:
|
|||
: variable_info<V>(name, game_vars)
|
||||
{
|
||||
static_assert(!std::is_same<
|
||||
variable_info_implementation::vi_policy_const, utils::remove_const_t<V>>::value,
|
||||
variable_info_implementation::vi_policy_const, std::remove_const_t<V>>::value,
|
||||
"variable_info_mutable cannot be specialized with 'vi_policy_const'"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue