BuiltInDefaultValue issue with boost::tuple and non-default constructor

83 views
Skip to first unread message

Erica Bradnick

unread,
Oct 9, 2016, 10:17:24 PM10/9/16
to Google C++ Mocking Framework
I am migrating code from C++98 to C++11 and running into a compile error with gmock (compiles fine C++98, the BuiltInDefaultValueGetter is causing me problems in C++11). Please advise how I can code this mock to prevent the DefaultGet() being compiled.

Classes involved:
  • boost's tuple (boost 1.59)
  • another team's class with no default constructor (AnotherGroupsClass) ... takes two ints.
  • another team's class with typedef of boost::tuple<bool, AnotherGroupsClass> ... 
When I mock out my class with a function that returns this boost::tuple, gmock (through std::is_default_constructible) thinks it can.

Have you run into issues like this? I would prefer to fix it on my side, but if it requires changes to AnotherGroupsClass, its a 50-50 chance they can change. Is there a way to disable the C++11 BuiltInDefaultValueGetter?

Thanks much,

Compile Error:
/<mysource>/include/boost/tuple/detail/tuple_basic.hpp: In instantiation of 'boost::tuples::cons<HT, boost::tuples::null_type>::cons() [with HT = some_ns::AnotherGroupsClass]':
/<mysource>/include/boost/tuple/detail/tuple_basic.hpp:284:25:   required from 'boost::tuples::cons<HT, TT>::cons() [with HT = bool; TT = boost::tuples::cons<some_ns::AnotherGroupsClass, boost::tuples::null_type>]'
/<mysource>/include/boost/tuple/detail/tuple_basic.hpp:485:11:   required from 'boost::tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::tuple() [with T0 = bool; T1 = some_ns::AnotherGroupsClass; T2 = boost::tuples::null_type; T3 = boost::tuples::null_type; T4 = boost::tuples::null_type; T5 = boost::tuples::null_type; T6 = boost::tuples::null_type; T7 = boost::tuples::null_type; T8 = boost::tuples::null_type; T9 = boost::tuples::null_type]'
/<mysource>/include/gmock/gmock-actions.h:76:29:   required from 'static T testing::internal::BuiltInDefaultValueGetter<T, kDefaultConstructible>::Get() [with T = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>; bool kDefaultConstructible = true]'
/<mysource>/include/gmock/gmock-actions.h:107:59:   required from 'static T testing::internal::BuiltInDefaultValue<T>::Get() [with T = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>]'
/<mysource>/include/gmock/gmock-actions.h:238:46:   required from 'static T testing::DefaultValue<T>::Get() [with T = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>]'
/<mysource>/include/gmock/gmock-spec-builders.h:1515:37:   required from 'testing::internal::FunctionMockerBase<F>::Result testing::internal::FunctionMockerBase<F>::PerformDefaultAction(const ArgumentTuple&, const string&) const [with F = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>(int, int); testing::internal::FunctionMockerBase<F>::Result = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>; testing::internal::FunctionMockerBase<F>::ArgumentTuple = std::tuple<int, int>; testing::internal::string = std::basic_string<char>]'
/<mysource>/include/gmock/gmock-spec-builders.h:1394:67:   required from 'static testing::internal::ActionResultHolder<T>* testing::internal::ActionResultHolder<T>::PerformDefaultAction(const testing::internal::FunctionMockerBase<F>*, const typename testing::internal::Function<F>::ArgumentTuple&, const string&) [with F = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>(int, int); T = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>; typename testing::internal::Function<F>::ArgumentTuple = std::tuple<int, int>; testing::internal::string = std::basic_string<char>]'
/<mysource>/include/gmock/gmock-spec-builders.h:1528:46:   required from 'testing::internal::UntypedActionResultHolderBase* testing::internal::FunctionMockerBase<F>::UntypedPerformDefaultAction(const void*, const string&) const [with F = boost::tuples::tuple<bool, some_ns::AnotherGroupsClass>(int, int); testing::internal::string = std::basic_string<char>]'
ComplianceTester.cpp:301:1:   required from here
/<mysource>/include/boost/tuple/detail/tuple_basic.hpp:373:17: error: no matching function for call to 'some_ns::AnotherGroupsClass::AnotherGroupsClass()'
   cons() : head() {}
Reply all
Reply to author
Forward
0 new messages