susumu.yata
null+****@clear*****
Wed Dec 5 21:35:26 JST 2012
susumu.yata 2012-12-05 21:35:26 +0900 (Wed, 05 Dec 2012) New Revision: caf2e088fad1e28dff2f09a9b7407eabb87d6cda https://github.com/groonga/grnxx/commit/caf2e088fad1e28dff2f09a9b7407eabb87d6cda Log: Use constexpr (C++11) instead of GRNXX_CONSTEXPR. Modified files: lib/alpha/blob_vector.hpp lib/alpha/vector.hpp lib/duration.hpp lib/features.hpp lib/flags_impl.hpp Modified: lib/alpha/blob_vector.hpp (+1 -1) =================================================================== --- lib/alpha/blob_vector.hpp 2012-12-05 21:26:09 +0900 (44b846c) +++ lib/alpha/blob_vector.hpp 2012-12-05 21:35:26 +0900 (acc5275) @@ -503,7 +503,7 @@ class BlobVector { return impl_ ? impl_->write_to(builder) : (builder << "n/a"); } - static GRNXX_CONSTEXPR uint64_t max_id() { + static constexpr uint64_t max_id() { return BLOB_VECTOR_MAX_ID; } Modified: lib/alpha/vector.hpp (+5 -5) =================================================================== --- lib/alpha/vector.hpp 2012-12-05 21:26:09 +0900 (07571d3) +++ lib/alpha/vector.hpp 2012-12-05 21:35:26 +0900 (28b453c) @@ -277,19 +277,19 @@ class Vector { return impl_ ? impl_->write_to(builder) : (builder << "n/a"); } - static GRNXX_CONSTEXPR uint64_t value_size() { + static constexpr uint64_t value_size() { return sizeof(Value); } - static GRNXX_CONSTEXPR uint64_t page_size() { + static constexpr uint64_t page_size() { return PAGE_SIZE; } - static GRNXX_CONSTEXPR uint64_t table_size() { + static constexpr uint64_t table_size() { return TABLE_SIZE; } - static GRNXX_CONSTEXPR uint64_t secondary_table_size() { + static constexpr uint64_t secondary_table_size() { return SECONDARY_TABLE_SIZE; } - static GRNXX_CONSTEXPR uint64_t max_id() { + static constexpr uint64_t max_id() { return (PAGE_SIZE * TABLE_SIZE * SECONDARY_TABLE_SIZE) - 1; } Modified: lib/duration.hpp (+25 -25) =================================================================== --- lib/duration.hpp 2012-12-05 21:26:09 +0900 (f6b83ff) +++ lib/duration.hpp 2012-12-05 21:35:26 +0900 (3bb136d) @@ -25,36 +25,36 @@ namespace grnxx { class Duration { public: - GRNXX_CONSTEXPR Duration() : nanoseconds_(0) {} - explicit GRNXX_CONSTEXPR Duration(int64_t nanoseconds) + constexpr Duration() : nanoseconds_(0) {} + explicit constexpr Duration(int64_t nanoseconds) : nanoseconds_(nanoseconds) {} - static GRNXX_CONSTEXPR Duration nanoseconds(int64_t nanoseconds) { + static constexpr Duration nanoseconds(int64_t nanoseconds) { return Duration(nanoseconds); } - static GRNXX_CONSTEXPR Duration microseconds(int64_t microseconds) { + static constexpr Duration microseconds(int64_t microseconds) { return Duration(microseconds * 1000); } - static GRNXX_CONSTEXPR Duration milliseconds(int64_t milliseconds) { + static constexpr Duration milliseconds(int64_t milliseconds) { return Duration(milliseconds * 1000000); } - static GRNXX_CONSTEXPR Duration seconds(int64_t seconds) { + static constexpr Duration seconds(int64_t seconds) { return Duration(seconds * 1000000000); } - static GRNXX_CONSTEXPR Duration minutes(int64_t minutes) { + static constexpr Duration minutes(int64_t minutes) { return Duration(minutes * 1000000000 * 60); } - static GRNXX_CONSTEXPR Duration hours(int64_t hours) { + static constexpr Duration hours(int64_t hours) { return Duration(hours * 1000000000 * 60 * 60); } - static GRNXX_CONSTEXPR Duration days(int64_t days) { + static constexpr Duration days(int64_t days) { return Duration(days * 1000000000 * 60 * 60 * 24); } - static GRNXX_CONSTEXPR Duration weeks(int64_t weeks) { + static constexpr Duration weeks(int64_t weeks) { return Duration(weeks * 1000000000 * 60 * 60 * 24 * 7); } - GRNXX_CONSTEXPR int64_t nanoseconds() const { + constexpr int64_t nanoseconds() const { return nanoseconds_; } void set_nanoseconds(int64_t nanoseconds) { @@ -69,10 +69,10 @@ class Duration { // Copyable. }; -inline GRNXX_CONSTEXPR Duration operator+(Duration duration) { +inline constexpr Duration operator+(Duration duration) { return duration; } -inline GRNXX_CONSTEXPR Duration operator-(Duration duration) { +inline constexpr Duration operator-(Duration duration) { return Duration(-duration.nanoseconds()); } @@ -105,42 +105,42 @@ inline Duration &operator%=(Duration &lhs, Duration rhs) { return lhs; } -inline GRNXX_CONSTEXPR Duration operator+(Duration lhs, Duration rhs) { +inline constexpr Duration operator+(Duration lhs, Duration rhs) { return Duration(lhs.nanoseconds() + rhs.nanoseconds()); } -inline GRNXX_CONSTEXPR Duration operator-(Duration lhs, Duration rhs) { +inline constexpr Duration operator-(Duration lhs, Duration rhs) { return Duration(lhs.nanoseconds() - rhs.nanoseconds()); } -inline GRNXX_CONSTEXPR Duration operator*(Duration lhs, int64_t rhs) { +inline constexpr Duration operator*(Duration lhs, int64_t rhs) { return Duration(lhs.nanoseconds() * rhs); } -inline GRNXX_CONSTEXPR Duration operator*(int64_t lhs, Duration rhs) { +inline constexpr Duration operator*(int64_t lhs, Duration rhs) { return Duration(lhs * rhs.nanoseconds()); } -inline GRNXX_CONSTEXPR Duration operator/(Duration lhs, int64_t rhs) { +inline constexpr Duration operator/(Duration lhs, int64_t rhs) { return (rhs != 0) ? Duration(lhs.nanoseconds() / rhs) : Duration(0); } -inline GRNXX_CONSTEXPR Duration operator%(Duration lhs, Duration rhs) { +inline constexpr Duration operator%(Duration lhs, Duration rhs) { return (rhs.nanoseconds() != 0) ? Duration(lhs.nanoseconds() % rhs.nanoseconds()) : Duration(0); } -inline GRNXX_CONSTEXPR bool operator==(Duration lhs, Duration rhs) { +inline constexpr bool operator==(Duration lhs, Duration rhs) { return lhs.nanoseconds() == rhs.nanoseconds(); } -inline GRNXX_CONSTEXPR bool operator!=(Duration lhs, Duration rhs) { +inline constexpr bool operator!=(Duration lhs, Duration rhs) { return lhs.nanoseconds() != rhs.nanoseconds(); } -inline GRNXX_CONSTEXPR bool operator<(Duration lhs, Duration rhs) { +inline constexpr bool operator<(Duration lhs, Duration rhs) { return lhs.nanoseconds() < rhs.nanoseconds(); } -inline GRNXX_CONSTEXPR bool operator<=(Duration lhs, Duration rhs) { +inline constexpr bool operator<=(Duration lhs, Duration rhs) { return lhs.nanoseconds() <= rhs.nanoseconds(); } -inline GRNXX_CONSTEXPR bool operator>(Duration lhs, Duration rhs) { +inline constexpr bool operator>(Duration lhs, Duration rhs) { return lhs.nanoseconds() > rhs.nanoseconds(); } -inline GRNXX_CONSTEXPR bool operator>=(Duration lhs, Duration rhs) { +inline constexpr bool operator>=(Duration lhs, Duration rhs) { return lhs.nanoseconds() >= rhs.nanoseconds(); } Modified: lib/features.hpp (+0 -12) =================================================================== --- lib/features.hpp 2012-12-05 21:26:09 +0900 (91dd172) +++ lib/features.hpp 2012-12-05 21:35:26 +0900 (5331f22) @@ -118,28 +118,16 @@ # if GRNXX_CLANG_HAS(c_atomic) # define GRNXX_HAS_CLANG_BUILTIN_ATOMIC # endif // GRNXX_CLANG_HAS(c_atomic) -# if GRNXX_CLANG_HAS(cxx_constexpr) -# define GRNXX_HAS_CONSTEXPR -# endif // GRNXX_CLANG_HAS(cxx_constexpr) #elif defined(GRNXX_GNUC) # define GRNXX_HAS_GNUC_BUILTIN_CLZ # if GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 2, 0) # define GRNXX_HAS_GNUC_BUILTIN_SYNC # endif // GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 2, 0) -# if GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 6, 0) -# define GRNXX_HAS_CONSTEXPR -# endif // GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 6, 0) # if GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 7, 0) # define GRNXX_HAS_GNUC_BUILTIN_ATOMIC # endif // GRNXX_GNUC_VERSION >= GRNXX_GNUC_MAKE_VERSION(4, 7, 0) #endif // defined(GRNXX_GNUC) -#ifdef GRNXX_HAS_CONSTEXPR -# define GRNXX_CONSTEXPR constexpr -#else // GRNXX_HAS_CONSTEXPR -# define GRNXX_CONSTEXPR -#endif // GRNXX_HAS_CONSTEXPR - // Source features. #ifdef _POSIX_C_SOURCE Modified: lib/flags_impl.hpp (+11 -11) =================================================================== --- lib/flags_impl.hpp 2012-12-05 21:26:09 +0900 (b75a99e) +++ lib/flags_impl.hpp 2012-12-05 21:35:26 +0900 (bfd87b9) @@ -28,30 +28,30 @@ class FlagsImpl { typedef T Identifier; typedef U Type; - GRNXX_CONSTEXPR FlagsImpl() : flags_(0) {} - GRNXX_CONSTEXPR FlagsImpl(const FlagsImpl &flags) : flags_(flags.flags_) {} + constexpr FlagsImpl() : flags_(0) {} + constexpr FlagsImpl(const FlagsImpl &flags) : flags_(flags.flags_) {} - GRNXX_CONSTEXPR explicit operator bool() const { + constexpr explicit operator bool() const { return flags_ != 0; } - GRNXX_CONSTEXPR FlagsImpl operator&(FlagsImpl rhs) const { + constexpr FlagsImpl operator&(FlagsImpl rhs) const { return FlagsImpl(flags_ & rhs.flags_); } - GRNXX_CONSTEXPR FlagsImpl operator|(FlagsImpl rhs) const { + constexpr FlagsImpl operator|(FlagsImpl rhs) const { return FlagsImpl(flags_ | rhs.flags_); } - GRNXX_CONSTEXPR FlagsImpl operator^(FlagsImpl rhs) const { + constexpr FlagsImpl operator^(FlagsImpl rhs) const { return FlagsImpl(flags_ ^ rhs.flags_); } - GRNXX_CONSTEXPR FlagsImpl operator~() const { + constexpr FlagsImpl operator~() const { return FlagsImpl(~flags_); } - GRNXX_CONSTEXPR bool operator==(FlagsImpl rhs) const { + constexpr bool operator==(FlagsImpl rhs) const { return flags_ == rhs.flags_; } - GRNXX_CONSTEXPR bool operator!=(FlagsImpl rhs) const { + constexpr bool operator!=(FlagsImpl rhs) const { return flags_ == rhs.flags_; } @@ -68,14 +68,14 @@ class FlagsImpl { return *this; } - static GRNXX_CONSTEXPR FlagsImpl define(Type flags) { + static constexpr FlagsImpl define(Type flags) { return FlagsImpl(flags); } private: Type flags_; - explicit GRNXX_CONSTEXPR FlagsImpl(Type flags) : flags_(flags) {} + explicit constexpr FlagsImpl(Type flags) : flags_(flags) {} }; } // namespace grnxx -------------- next part -------------- HTML����������������������������... Download