Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1329)

Issue 1976703005: Allow constexpr variables of TimeDelta type. (Closed)

Created:
4 years, 7 months ago by Jeffrey Yasskin
Modified:
4 years, 7 months ago
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@lkcr
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Allow constexpr variables of TimeDelta type. This allows TimeDelta variables to be global per https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables since they don't have to run a dynamic initializer anymore. Committed: https://crrev.com/bad4e03c815490e4eb8ceef9b5143b58c6fefb81 Cr-Commit-Position: refs/heads/master@{#394527}

Patch Set 1 #

Patch Set 2 : Use static_assert instead of constexpr variables to check for constant-expression-ness. #

Patch Set 3 : Remove an unused const variable. #

Patch Set 4 : Remove unused constants from a second file. #

Total comments: 3

Patch Set 5 : Remove more unused constants. #

Total comments: 2

Patch Set 6 : Fix overflow from doubles, and test all the boundaries better. #

Total comments: 6

Patch Set 7 : Android doesn't define nexttoward; use nextafter instead. #

Patch Set 8 : Undo FromDouble fix. #

Total comments: 2

Patch Set 9 : Generalize FromProduct a bit. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+73 lines, -64 lines) Patch
M base/time/time.h View 1 2 3 4 5 6 7 8 4 chunks +58 lines, -43 lines 1 comment Download
M base/time/time_unittest.cc View 1 6 7 1 chunk +15 lines, -10 lines 0 comments Download
M components/feedback/feedback_data_unittest.cc View 1 2 3 4 1 chunk +0 lines, -3 lines 0 comments Download
M components/offline_pages/offline_page_model.cc View 1 2 1 chunk +0 lines, -4 lines 0 comments Download
M content/browser/download/base_file_unittest.cc View 1 2 3 1 chunk +0 lines, -3 lines 0 comments Download
M extensions/browser/quota_service_unittest.cc View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 61 (23 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/1
4 years, 7 months ago (2016-05-13 23:06:50 UTC) #2
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/40001
4 years, 7 months ago (2016-05-13 23:24:27 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/60001
4 years, 7 months ago (2016-05-13 23:36:23 UTC) #8
Jeffrey Yasskin
Dana & Nico, as you can see, folks were already creating global TimeDelta variables that ...
4 years, 7 months ago (2016-05-13 23:39:43 UTC) #10
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_gn_rel on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_gn_rel/builds/111172)
4 years, 7 months ago (2016-05-14 00:04:03 UTC) #12
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/80001
4 years, 7 months ago (2016-05-14 00:19:58 UTC) #14
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 7 months ago (2016-05-14 03:21:17 UTC) #16
jschuh
https://codereview.chromium.org/1976703005/diff/80001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/80001/base/time/time.h#newcode632 base/time/time.h:632: return value > std::numeric_limits<int64_t>::max() I think this runs afoul ...
4 years, 7 months ago (2016-05-16 16:54:41 UTC) #17
danakj
I'm all good with making things constexpr where they can. How come the static/global variables ...
4 years, 7 months ago (2016-05-16 18:32:51 UTC) #18
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/100001
4 years, 7 months ago (2016-05-16 18:57:51 UTC) #20
Jeffrey Yasskin
On 2016/05/16 18:32:51, danakj wrote: > I'm all good with making things constexpr where they ...
4 years, 7 months ago (2016-05-16 18:59:17 UTC) #21
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_chromium_gn_compile_dbg/builds/67214)
4 years, 7 months ago (2016-05-16 19:33:51 UTC) #23
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/120001
4 years, 7 months ago (2016-05-16 19:50:12 UTC) #25
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 7 months ago (2016-05-16 21:16:28 UTC) #27
danakj
https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h#newcode627 base/time/time.h:627: // Note that TimeDelta::FromMicroseconds(numeric_limits<int64_t>::min()) is On 2016/05/16 18:59:17, Jeffrey ...
4 years, 7 months ago (2016-05-17 20:28:29 UTC) #28
Jeffrey Yasskin
https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h#newcode627 base/time/time.h:627: // Note that TimeDelta::FromMicroseconds(numeric_limits<int64_t>::min()) is On 2016/05/17 20:28:29, danakj ...
4 years, 7 months ago (2016-05-17 20:48:51 UTC) #29
danakj
https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h#newcode653 base/time/time.h:653: return value > std::numeric_limits<int64_t>::max() / microseconds_per On 2016/05/17 20:48:51, ...
4 years, 7 months ago (2016-05-17 21:17:36 UTC) #30
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/140001
4 years, 7 months ago (2016-05-17 21:46:43 UTC) #32
Jeffrey Yasskin
On 2016/05/17 21:17:36, danakj wrote: > https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h > File base/time/time.h (right): > > https://codereview.chromium.org/1976703005/diff/100001/base/time/time.h#newcode653 > ...
4 years, 7 months ago (2016-05-17 21:47:42 UTC) #33
danakj
On 2016/05/16 18:59:17, Jeffrey Yasskin wrote: > On 2016/05/16 18:32:51, danakj wrote: > > I'm ...
4 years, 7 months ago (2016-05-17 21:53:14 UTC) #34
Jeffrey Yasskin
https://codereview.chromium.org/1976703005/diff/140001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/140001/base/time/time.h#newcode643 base/time/time.h:643: int microseconds_per) { On 2016/05/17 21:53:14, danakj wrote: > ...
4 years, 7 months ago (2016-05-17 22:10:30 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/160001
4 years, 7 months ago (2016-05-17 22:11:24 UTC) #38
danakj
On Tue, May 17, 2016 at 3:10 PM, <jyasskin@chromium.org> wrote: > > https://codereview.chromium.org/1976703005/diff/140001/base/time/time.h > File ...
4 years, 7 months ago (2016-05-17 22:12:27 UTC) #39
Jeffrey Yasskin
Please review a couple deletions of unused code: achaulk: components/feedback/feedback_data_unittest.cc dewittj: components/offline_pages/offline_page_model.cc asanka: content/browser/download/base_file_unittest.cc reillyg: ...
4 years, 7 months ago (2016-05-17 22:16:17 UTC) #42
Reilly Grant (use Gerrit)
lgtm
4 years, 7 months ago (2016-05-17 23:30:30 UTC) #43
dewittj
lgtm
4 years, 7 months ago (2016-05-17 23:36:40 UTC) #44
dewittj
lgtm
4 years, 7 months ago (2016-05-17 23:36:44 UTC) #45
dewittj
lgtm
4 years, 7 months ago (2016-05-17 23:36:48 UTC) #46
asanka
lgtm
4 years, 7 months ago (2016-05-18 00:10:05 UTC) #47
Jeffrey Yasskin
s/achaulk/bsimonnet/ for components/feedback/feedback_data_unittest.cc
4 years, 7 months ago (2016-05-18 18:52:48 UTC) #49
Jeffrey Yasskin
s/achaulk/bsimonnet/ for components/feedback/feedback_data_unittest.cc
4 years, 7 months ago (2016-05-18 18:52:53 UTC) #50
bsimonnet
lgtm
4 years, 7 months ago (2016-05-18 18:54:54 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1976703005/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1976703005/160001
4 years, 7 months ago (2016-05-18 18:56:36 UTC) #53
commit-bot: I haz the power
Committed patchset #9 (id:160001)
4 years, 7 months ago (2016-05-18 20:19:46 UTC) #55
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/bad4e03c815490e4eb8ceef9b5143b58c6fefb81 Cr-Commit-Position: refs/heads/master@{#394527}
4 years, 7 months ago (2016-05-18 20:21:35 UTC) #57
Peter Kasting
https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h File base/time/time.h (right): https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h#newcode585 base/time/time.h:585: constexpr inline TimeDelta TimeDelta::FromDays(int days) { Doesn't constexpr imply ...
4 years, 7 months ago (2016-05-18 20:53:28 UTC) #59
Jeffrey Yasskin
On 2016/05/18 20:53:28, Peter Kasting wrote: > https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h > File base/time/time.h (right): > > https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h#newcode585 ...
4 years, 7 months ago (2016-05-18 20:56:24 UTC) #60
Jeffrey Yasskin
4 years, 7 months ago (2016-05-18 20:59:59 UTC) #61
Message was sent while issue was closed.
On 2016/05/18 20:56:24, Jeffrey Yasskin wrote:
> On 2016/05/18 20:53:28, Peter Kasting wrote:
> > https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h
> > File base/time/time.h (right):
> > 
> >
>
https://codereview.chromium.org/1976703005/diff/160001/base/time/time.h#newco...
> > base/time/time.h:585: constexpr inline TimeDelta TimeDelta::FromDays(int
days)
> {
> > Doesn't constexpr imply the same rules (e.g. for ODR) as "inline"? Shouldn't
> we
> > remove "inline" on these?
> 
> Good question. I don't know if 'constexpr' implies 'inline'. Do you happen to
> have a reference for that, or should I try to find it myself?

Yep: [dcl.constexpr]p2. I'll send a fix. Thanks.

Powered by Google App Engine
This is Rietveld 408576698