From 96d530c1286936c78b5ad6869d926e159b4563b5 Mon Sep 17 00:00:00 2001 From: chentianyu03 Date: Wed, 23 Feb 2022 19:46:02 +0800 Subject: [PATCH] move array_ref_test and small_vector_test into paddle/utils and format header macro define (#39831) --- paddle/testing/CMakeLists.txt | 2 -- paddle/utils/CMakeLists.txt | 2 ++ paddle/utils/any.h | 7 ++----- paddle/utils/array_ref.h | 7 ++----- paddle/{testing => utils}/array_ref_test.cc | 0 paddle/utils/flat_hash_map.h | 2 +- paddle/utils/none.h | 9 +++------ paddle/utils/optional.h | 8 +++----- paddle/utils/small_vector.h | 9 +++------ paddle/{testing => utils}/small_vector_test.cc | 0 10 files changed, 16 insertions(+), 30 deletions(-) rename paddle/{testing => utils}/array_ref_test.cc (100%) rename paddle/{testing => utils}/small_vector_test.cc (100%) diff --git a/paddle/testing/CMakeLists.txt b/paddle/testing/CMakeLists.txt index fe288ec2bf1..eace7c41f4a 100644 --- a/paddle/testing/CMakeLists.txt +++ b/paddle/testing/CMakeLists.txt @@ -3,5 +3,3 @@ if(WITH_TESTING) cc_library(paddle_gtest_main SRCS paddle_gtest_main.cc DEPS init device_context memory gtest gflags) endif() -cc_test(small_vector_test SRCS small_vector_test.cc DEPS gtest gflags) -cc_test(array_ref_test SRCS array_ref_test.cc DEPS gtest gflags) diff --git a/paddle/utils/CMakeLists.txt b/paddle/utils/CMakeLists.txt index 2b4803e3538..64c88a47b43 100644 --- a/paddle/utils/CMakeLists.txt +++ b/paddle/utils/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory(string) +cc_test(small_vector_test SRCS small_vector_test.cc DEPS gtest gflags) +cc_test(array_ref_test SRCS array_ref_test.cc DEPS gtest gflags) diff --git a/paddle/utils/any.h b/paddle/utils/any.h index d0e72b70635..148d3f45b56 100644 --- a/paddle/utils/any.h +++ b/paddle/utils/any.h @@ -6,8 +6,7 @@ // See http://www.boost.org/libs/any for Documentation. -#ifndef PADDLE_ANY_INCLUDED -#define PADDLE_ANY_INCLUDED +#pragma once // what: variant type boost::any // who: contributed by Kevlin Henney, @@ -168,12 +167,10 @@ template inline const ValueType *unsafe_any_cast(const any *operand) { return unsafe_any_cast(const_cast(operand)); } -} +} // namespace paddle // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) - -#endif diff --git a/paddle/utils/array_ref.h b/paddle/utils/array_ref.h index 9b39e9775f9..d2ab762bb15 100644 --- a/paddle/utils/array_ref.h +++ b/paddle/utils/array_ref.h @@ -12,8 +12,7 @@ // //===----------------------------------------------------------------------===// -#ifndef PADDLE_UTILS_ARRAY_REF_H_ -#define PADDLE_UTILS_ARRAY_REF_H_ +#pragma once #include #include @@ -332,6 +331,4 @@ inline bool operator!=(SmallVectorImpl &LHS, ArrayRef RHS) { return !(LHS == RHS); } -} // end namespace paddle - -#endif // PADDLE_UTILS_ARRAY_REF_H_ +} // namespace paddle diff --git a/paddle/testing/array_ref_test.cc b/paddle/utils/array_ref_test.cc similarity index 100% rename from paddle/testing/array_ref_test.cc rename to paddle/utils/array_ref_test.cc diff --git a/paddle/utils/flat_hash_map.h b/paddle/utils/flat_hash_map.h index 07b7b5d3c82..64a75fffa57 100644 --- a/paddle/utils/flat_hash_map.h +++ b/paddle/utils/flat_hash_map.h @@ -1741,4 +1741,4 @@ struct power_of_two_std_hash : std::hash { typedef paddle::power_of_two_hash_policy hash_policy; }; -} // end namespace paddle +} // namespace paddle diff --git a/paddle/utils/none.h b/paddle/utils/none.h index 20d6f4d2c7d..d2da8f26a11 100644 --- a/paddle/utils/none.h +++ b/paddle/utils/none.h @@ -15,8 +15,7 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef PADDLE_NONE_17SEP2003_HPP -#define PADDLE_NONE_17SEP2003_HPP +#pragma once namespace paddle { @@ -26,7 +25,7 @@ struct none_helper {}; typedef int detail::none_helper::*none_t; -} // namespace boost +} // namespace paddle // NOTE: Borland users have to include this header outside any precompiled // headers @@ -37,6 +36,4 @@ namespace paddle { none_t const none = ((none_t)0); -} // namespace boost - -#endif +} // namespace paddle diff --git a/paddle/utils/optional.h b/paddle/utils/optional.h index 00d8ae28ee8..d2a9a3f11ef 100644 --- a/paddle/utils/optional.h +++ b/paddle/utils/optional.h @@ -17,8 +17,7 @@ // You are welcome to contact the author at: // fernando_cacciola@hotmail.com // -#ifndef PADDLE_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP -#define PADDLE_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP +#pragma once #include #include @@ -27,6 +26,8 @@ #include "none.h" +namespace paddle { + // Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<> // member template of a factory as used in the optional<> implementation. // He proposed this simple fix which is to move the call to apply<> outside @@ -38,7 +39,6 @@ void construct(Factory const& factory, void* address) { } } -namespace paddle { template class optional; @@ -865,5 +865,3 @@ inline void optional_swap(optional& x, optional& y) { } // namespace optional_detail } // namespace paddle - -#endif diff --git a/paddle/utils/small_vector.h b/paddle/utils/small_vector.h index 48af2491b89..14cb8f410f4 100644 --- a/paddle/utils/small_vector.h +++ b/paddle/utils/small_vector.h @@ -18,8 +18,7 @@ // //===----------------------------------------------------------------------===// -#ifndef PADDLE_UTILS_SMALL_VECTOR_H_ -#define PADDLE_UTILS_SMALL_VECTOR_H_ +#pragma once #include #include @@ -1461,7 +1460,7 @@ static_assert(sizeof(SmallVectorSizeType) == sizeof(uint32_t), "Expected SmallVectorBase variant to be in use."); #endif -} // end namespace paddle +} // namespace paddle namespace std { @@ -1479,6 +1478,4 @@ inline void swap(paddle::SmallVector &LHS, LHS.swap(RHS); } -} // end namespace std - -#endif // PADDLE_UTILS_SMALL_VECTOR_H_ +} // namespace std diff --git a/paddle/testing/small_vector_test.cc b/paddle/utils/small_vector_test.cc similarity index 100% rename from paddle/testing/small_vector_test.cc rename to paddle/utils/small_vector_test.cc -- GitLab