Skip to content

Commit

Permalink
use more aggressive way
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaishaonvjituizi committed Apr 26, 2022
1 parent ad8ceda commit 178dd27
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions paddle/utils/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

#pragma once

#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
#endif

/*
variant synopsis
Expand Down Expand Up @@ -1823,20 +1828,6 @@ struct dtor {
template <typename Traits, Trait = Traits::destructible_trait>
class destructor;

// gcc >= 9 has a bug that creates a false positive warning
// Reference:
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92145
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89381
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9
#define USING_SUPER_ASSIGNMENT_OPERATOR \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-copy\"") \
using super::operator=; \
_Pragma("GCC diagnostic pop")
#else
#define USING_SUPER_ASSIGNMENT_OPERATOR using super::operator=;
#endif

#define MPARK_VARIANT_DESTRUCTOR(destructible_trait, definition, destroy) \
template <typename... Ts> \
class destructor<traits<Ts...>, destructible_trait> \
Expand All @@ -1845,7 +1836,7 @@ _Pragma("GCC diagnostic pop")
\
public: \
MPARK_INHERITING_CTOR(destructor, super) \
USING_SUPER_ASSIGNMENT_OPERATOR \
using super::operator=; \
\
destructor(const destructor &) = default; \
destructor(destructor &&) = default; \
Expand Down Expand Up @@ -1881,7 +1872,7 @@ class constructor : public destructor<Traits> {

public:
MPARK_INHERITING_CTOR(constructor, super)
USING_SUPER_ASSIGNMENT_OPERATOR
using super::operator=;

protected:
#ifndef MPARK_GENERIC_LAMBDAS
Expand Down Expand Up @@ -1933,7 +1924,7 @@ class move_constructor;
\
public: \
MPARK_INHERITING_CTOR(move_constructor, super) \
USING_SUPER_ASSIGNMENT_OPERATOR \
using super::operator=; \
\
move_constructor(const move_constructor &) = default; \
definition ~move_constructor() = default; \
Expand Down Expand Up @@ -1969,7 +1960,7 @@ class copy_constructor;
\
public: \
MPARK_INHERITING_CTOR(copy_constructor, super) \
USING_SUPER_ASSIGNMENT_OPERATOR \
using super::operator=; \
\
definition copy_constructor(copy_constructor &&) = default; \
~copy_constructor() = default; \
Expand Down Expand Up @@ -1998,7 +1989,7 @@ class assignment : public copy_constructor<Traits> {

public:
MPARK_INHERITING_CTOR(assignment, super)
USING_SUPER_ASSIGNMENT_OPERATOR
using super::operator=;

template <std::size_t I, typename... Args>
inline /* auto & */ auto emplace(Args &&... args)
Expand Down Expand Up @@ -2085,7 +2076,7 @@ class move_assignment;
\
public: \
MPARK_INHERITING_CTOR(move_assignment, super) \
USING_SUPER_ASSIGNMENT_OPERATOR \
using super::operator=; \
\
move_assignment(const move_assignment &) = default; \
move_assignment(move_assignment &&) = default; \
Expand Down Expand Up @@ -2125,7 +2116,7 @@ class copy_assignment;
\
public: \
MPARK_INHERITING_CTOR(copy_assignment, super) \
USING_SUPER_ASSIGNMENT_OPERATOR \
using super::operator=; \
\
copy_assignment(const copy_assignment &) = default; \
copy_assignment(copy_assignment &&) = default; \
Expand Down Expand Up @@ -2155,7 +2146,7 @@ class impl : public copy_assignment<traits<Ts...>> {

public:
MPARK_INHERITING_CTOR(impl, super)
USING_SUPER_ASSIGNMENT_OPERATOR
using super::operator=;

template <std::size_t I, typename Arg>
inline void assign(Arg &&arg) {
Expand Down Expand Up @@ -2842,3 +2833,7 @@ struct hash<paddle::monostate> {
};

} // namespace std

#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 9
#pragma GCC diagnostic pop
#endif

0 comments on commit 178dd27

Please sign in to comment.