[Groonga-commit] groonga/grnxx [master] Add constexpr to member functions of grnxx::Time.

Back to archive index

susumu.yata null+****@clear*****
Thu Dec 6 10:10:38 JST 2012


susumu.yata	2012-12-06 10:10:38 +0900 (Thu, 06 Dec 2012)

  New Revision: 82539b29b5fac923ed0867234dadbd3e51b29b71
  https://github.com/groonga/grnxx/commit/82539b29b5fac923ed0867234dadbd3e51b29b71

  Log:
    Add constexpr to member functions of grnxx::Time.

  Modified files:
    lib/time.hpp

  Modified: lib/time.hpp (+12 -12)
===================================================================
--- lib/time.hpp    2012-12-06 10:08:28 +0900 (584df22)
+++ lib/time.hpp    2012-12-06 10:10:38 +0900 (30b3f89)
@@ -26,12 +26,12 @@ namespace grnxx {
 class Time {
  public:
   Time() = default;
-  explicit Time(int64_t nanoseconds) : nanoseconds_(nanoseconds) {}
+  explicit constexpr Time(int64_t nanoseconds) : nanoseconds_(nanoseconds) {}
 
   static Time now();
   static Time now_in_seconds();
 
-  int64_t nanoseconds() const {
+  constexpr int64_t nanoseconds() const {
     return nanoseconds_;
   }
   void set_nanoseconds(int64_t nanoseconds) {
@@ -55,35 +55,35 @@ inline Time &operator-=(Time &lhs, Duration rhs) {
   return lhs;
 }
 
-inline Time operator+(Time lhs, Duration rhs) {
+inline constexpr Time operator+(Time lhs, Duration rhs) {
   return Time(lhs.nanoseconds() + rhs.nanoseconds());
 }
-inline Time operator+(Duration lhs, Time rhs) {
+inline constexpr Time operator+(Duration lhs, Time rhs) {
   return Time(lhs.nanoseconds() + rhs.nanoseconds());
 }
-inline Time operator-(Time lhs, Duration rhs) {
+inline constexpr Time operator-(Time lhs, Duration rhs) {
   return Time(lhs.nanoseconds() - rhs.nanoseconds());
 }
-inline Duration operator-(Time lhs, Time rhs) {
+inline constexpr Duration operator-(Time lhs, Time rhs) {
   return Duration(lhs.nanoseconds() - rhs.nanoseconds());
 }
 
-inline bool operator==(Time lhs, Time rhs) {
+inline constexpr bool operator==(Time lhs, Time rhs) {
   return lhs.nanoseconds() == rhs.nanoseconds();
 }
-inline bool operator!=(Time lhs, Time rhs) {
+inline constexpr bool operator!=(Time lhs, Time rhs) {
   return lhs.nanoseconds() != rhs.nanoseconds();
 }
-inline bool operator<(Time lhs, Time rhs) {
+inline constexpr bool operator<(Time lhs, Time rhs) {
   return lhs.nanoseconds() < rhs.nanoseconds();
 }
-inline bool operator<=(Time lhs, Time rhs) {
+inline constexpr bool operator<=(Time lhs, Time rhs) {
   return lhs.nanoseconds() <= rhs.nanoseconds();
 }
-inline bool operator>(Time lhs, Time rhs) {
+inline constexpr bool operator>(Time lhs, Time rhs) {
   return lhs.nanoseconds() > rhs.nanoseconds();
 }
-inline bool operator>=(Time lhs, Time rhs) {
+inline constexpr bool operator>=(Time lhs, Time rhs) {
   return lhs.nanoseconds() >= rhs.nanoseconds();
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index