typedef std::chrono::duration<int, std::ratio_multiply<std::ratio<12, 34>, std::ratio<9>>> irrelevant;
void func(irrelevant){} // comment this out to make it work
void func(std::chrono::seconds){}
void func(std::chrono::minutes){}
int main()
{
func(std::chrono::seconds(43));
}
Above, the inclusion of an overload that takes an irrelevant causes a bunch of errors, like:
‘std::ratio_divide<_R1,_R2>::type’ is not a member of a base class of ‘std::ratio_divide<_R1,_R2>’
Is there actually something wrong, or is VS2012 to blame? How can I work around it?
I don’t have access to VS2012, but see if this works:
Your code compiles for me in C++11 mode, but not in C++03 mode (clang/libc++). My theory is that VS2012 hasn’t yet implemented template aliases, or if it has, its
<chrono>hasn’t yet reacted to the availability of template aliases. As a fall back,ratio_multiplyhas a nested typetypewhich should do the job.