Skip to content

Instantly share code, notes, and snippets.

@farnoy
Created July 17, 2013 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farnoy/6024657 to your computer and use it in GitHub Desktop.
Save farnoy/6024657 to your computer and use it in GitHub Desktop.
c++ Constexprs in std::chrono
kuba@kuba-desk ~ $ cat chrono-constexpr.cc
#include <chrono>
int test() {
std::chrono::hours h{1};
std::chrono::minutes m = ++h;
m--;
return m.count();
}
//////////////////////
kuba@kuba-desk ~ $ clang++ chrono-constexpr.cc -std=c++11 -O3 -S -emit-llvm
kuba@kuba-desk ~ $ cat chrono-constexpr.s
; ModuleID = 'chrono-constexpr.cc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind readnone uwtable
define i32 @_Z4testv() #0 {
ret i32 119
}
attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment