mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-25 21:35:41 +00:00
support for GCC4.7: optional in-place constructor
This commit is contained in:
parent
05a1ebfa85
commit
9ca88083ac
2 changed files with 16 additions and 6 deletions
|
@ -42,6 +42,11 @@ namespace sprout {
|
||||||
typedef typename holder_type::reference_const_type reference_const_type;
|
typedef typename holder_type::reference_const_type reference_const_type;
|
||||||
typedef typename holder_type::pointer_type pointer_type;
|
typedef typename holder_type::pointer_type pointer_type;
|
||||||
typedef typename holder_type::pointer_const_type pointer_const_type;
|
typedef typename holder_type::pointer_const_type pointer_const_type;
|
||||||
|
public:
|
||||||
|
template<typename... Args>
|
||||||
|
struct is_constructible_args
|
||||||
|
: public std::is_constructible<T, Args&&...>
|
||||||
|
{};
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR reference_type get(optional& t) SPROUT_NOEXCEPT {
|
static SPROUT_CONSTEXPR reference_type get(optional& t) SPROUT_NOEXCEPT {
|
||||||
return sprout::get(t.val);
|
return sprout::get(t.val);
|
||||||
|
@ -108,7 +113,7 @@ namespace sprout {
|
||||||
{}
|
{}
|
||||||
template<
|
template<
|
||||||
typename... Args,
|
typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<Args...>::value>::type
|
||||||
>
|
>
|
||||||
explicit SPROUT_CONSTEXPR optional(sprout::in_place_t, Args&&... args)
|
explicit SPROUT_CONSTEXPR optional(sprout::in_place_t, Args&&... args)
|
||||||
: init(true)
|
: init(true)
|
||||||
|
@ -116,7 +121,7 @@ namespace sprout {
|
||||||
{}
|
{}
|
||||||
template<
|
template<
|
||||||
typename U, typename... Args,
|
typename U, typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<std::initializer_list<U>&, Args...>::value>::type
|
||||||
>
|
>
|
||||||
explicit SPROUT_CONSTEXPR optional(sprout::in_place_t, std::initializer_list<U> il, Args&&... args)
|
explicit SPROUT_CONSTEXPR optional(sprout::in_place_t, std::initializer_list<U> il, Args&&... args)
|
||||||
: init(true)
|
: init(true)
|
||||||
|
@ -177,7 +182,7 @@ namespace sprout {
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename... Args,
|
typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<Args...>::value>::type
|
||||||
>
|
>
|
||||||
void emplace(Args&&... args) {
|
void emplace(Args&&... args) {
|
||||||
optional temp(sprout::in_place, sprout::forward<Args>(args)...);
|
optional temp(sprout::in_place, sprout::forward<Args>(args)...);
|
||||||
|
@ -185,7 +190,7 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
template<
|
template<
|
||||||
typename U, typename... Args,
|
typename U, typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<std::initializer_list<U>&, Args...>::value>::type
|
||||||
>
|
>
|
||||||
void emplace(std::initializer_list<U> il, Args&&... args) {
|
void emplace(std::initializer_list<U> il, Args&&... args) {
|
||||||
optional temp(sprout::in_place, il, sprout::forward<Args>(args)...);
|
optional temp(sprout::in_place, il, sprout::forward<Args>(args)...);
|
||||||
|
|
|
@ -174,6 +174,11 @@ namespace sprout {
|
||||||
typedef mutable_or_const_pointer pointer_const_type;
|
typedef mutable_or_const_pointer pointer_const_type;
|
||||||
typedef param_type argument_type;
|
typedef param_type argument_type;
|
||||||
typedef movable_param_type movable_argument_type;
|
typedef movable_param_type movable_argument_type;
|
||||||
|
public:
|
||||||
|
template<typename... Args>
|
||||||
|
struct is_constructible_args
|
||||||
|
: public std::is_constructible<T, Args&&...>
|
||||||
|
{};
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR reference get(value_holder& t) SPROUT_NOEXCEPT {
|
static SPROUT_CONSTEXPR reference get(value_holder& t) SPROUT_NOEXCEPT {
|
||||||
return helper_type::ref(t.holder_);
|
return helper_type::ref(t.holder_);
|
||||||
|
@ -209,14 +214,14 @@ namespace sprout {
|
||||||
{}
|
{}
|
||||||
template<
|
template<
|
||||||
typename... Args,
|
typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<Args...>::value>::type
|
||||||
>
|
>
|
||||||
explicit SPROUT_CONSTEXPR value_holder(sprout::in_place_t, Args&&... args)
|
explicit SPROUT_CONSTEXPR value_holder(sprout::in_place_t, Args&&... args)
|
||||||
: holder_(sprout::forward<Args>(args)...)
|
: holder_(sprout::forward<Args>(args)...)
|
||||||
{}
|
{}
|
||||||
template<
|
template<
|
||||||
typename U, typename... Args,
|
typename U, typename... Args,
|
||||||
typename = typename std::enable_if<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value>::type
|
typename = typename std::enable_if<is_constructible_args<std::initializer_list<U>&, Args...>::value>::type
|
||||||
>
|
>
|
||||||
explicit SPROUT_CONSTEXPR value_holder(sprout::in_place_t, std::initializer_list<U> il, Args&&... args)
|
explicit SPROUT_CONSTEXPR value_holder(sprout::in_place_t, std::initializer_list<U> il, Args&&... args)
|
||||||
: holder_(il, sprout::forward<Args>(args)...)
|
: holder_(il, sprout::forward<Args>(args)...)
|
||||||
|
|
Loading…
Reference in a new issue