From 2a6e48d7b5d6bd97fbd3d4eabb45b6b4dc5e8023 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 7 Feb 2016 02:20:01 +0100 Subject: [PATCH] immutable-arguments(#989): verify the tuple builder can handle those too incidentally, this uncovered yet another unwanted narrowing conversion, namely from double via gavl_time_t to TimeValue or alternatively from double via FSecs (= rational) to Duration. As in all the previos cases, actually the compiler is to blame, and GCC-5 is known to get that one right, i.e. let the SFINAE fail instead of passing it with a "narrowing conversion" warning. Note: the real test for command binding with immutable types can be found in BusTerm_test --- src/lib/meta/trait.hpp | 7 +++++++ tests/12metaprogramming.tests | 2 +- tests/library/meta/tuple-record-init-test.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/meta/trait.hpp b/src/lib/meta/trait.hpp index 3ee151a81..49e0ebd76 100644 --- a/src/lib/meta/trait.hpp +++ b/src/lib/meta/trait.hpp @@ -77,6 +77,10 @@ namespace lib{ namespace hash { class LuidH; + } + namespace time { + class TimeValue; + class Duration; }} namespace proc { namespace mobject{ @@ -385,6 +389,9 @@ namespace meta { TRAIT_IS_NARROWING (double, float) + TRAIT_IS_NARROWING (double, lib::time::TimeValue) + TRAIT_IS_NARROWING (double, lib::time::Duration) + #undef TRAIT_IS_NARROWING diff --git a/tests/12metaprogramming.tests b/tests/12metaprogramming.tests index 5effe5d75..e7d6f59f7 100644 --- a/tests/12metaprogramming.tests +++ b/tests/12metaprogramming.tests @@ -576,7 +576,7 @@ TEST "tuple initialisation from GenNode" TupleRecordInit_test <»──(lalü,42) -out-lit: «tuple, string, int, long, double, TimeVar>»──(ID-lal,lala,12,34,5.6,548s7ms) +out-lit: «tuple, string, int, long, double, Duration>»──(ID-lal,lala,12,34,5.6,≺548s7ms≻) return: 0 END diff --git a/tests/library/meta/tuple-record-init-test.cpp b/tests/library/meta/tuple-record-init-test.cpp index 0020ed16e..6138cb0a3 100644 --- a/tests/library/meta/tuple-record-init-test.cpp +++ b/tests/library/meta/tuple-record-init-test.cpp @@ -42,7 +42,7 @@ using lib::diff::GenNode; using lib::meta::Types; using lib::meta::Tuple; using lib::meta::buildTuple; -using lib::time::TimeVar; +using lib::time::Duration; using lib::time::Time; using lib::hash::LuidH; @@ -93,7 +93,7 @@ namespace test { show_simpleUsage() { using NiceTypes = Types; - using UgglyTypes = Types, string, int, int64_t, double, TimeVar>; + using UgglyTypes = Types, string, int, int64_t, double, Duration>; // various conversions and an immutable type (Duration) Rec args = MakeRec().scope("lalü", 42); Rec urgs = MakeRec().scope("lalü", "lala", 12, 34, 5.6, Time(7,8,9));