GUnit icon indicating copy to clipboard operation
GUnit copied to clipboard

IS C++20 concepts support on the roadmap?

Open jamespharvey20 opened this issue 6 years ago • 0 comments

Will c++20 concept support be added, if using gcc -std=c++2a -fconcepts or the clang saarraz fork with concepts? If so, any timeframe on that? I have no idea if it's implementable, and if so, how hard it would be. (Template metaprogramming makes my head hurt, and I can't believe you've been able to do what you have with this!)

This compiles, with a manual injection of a realFoo, if the make<...> line is removed:

#include "GUnit.h"
using namespace testing;

template<typename T>
concept bool Fooable = requires(T a) {
   { a.foo() } -> int;
};

class realFoo {
public:
   int foo() {
      return 0;
   }
};

template<Fooable foo>
class underTest {
public:
   underTest(foo x) : x{x} {
   }
private:
   foo x;
};

GTEST("Concepts") {
   realFoo foo;
   underTest manualUt{foo};
   auto [ut, mocks] = make<underTest, StrictGMock>();
}

With the line, gcc from git master gives:

concepts.gpp: In member function ‘void GTEST<testing::v1::detail::string<'\"', 'C', 'o', 'n', 'c', 'e', 'p', 't', 's', '\"', '\000'>, testing::v1::detail::string<> >::TestBodyImpl(testing::v1::detail::TestRun&)’:
concepts.gpp:28:52: error: no matching function for call to ‘make<template<class foo>  requires  Fooable<foo> class underTest, template<class T> using StrictGMock = testing::StrictMock<testing::v1::GMock<T> > >()’
   28 |    auto [ut, mocks] = make<underTest, StrictGMock>();
      |                                                    ^
In file included from include/GUnit.h:10,
                 from concepts.gpp:1:
include/GUnit/GMake.h:433:6: note: candidate: ‘template<class T, class ... TArgs> auto testing::v1::make(TArgs&& ...)’
  433 | auto make(TArgs &&... args) {
      |      ^~~~
include/GUnit/GMake.h:433:6: note:   template argument deduction/substitution failed:
include/GUnit/GMake.h:444:6: note: candidate: ‘template<class T, template<class> class TMock, class ... TMocks, typename std::enable_if<(testing::v1::detail::is_gmock<TMock>::value && std::is_same<testing::v1::detail::bool_list<testing::v1::detail::always<TMocks>::value ...>, testing::v1::detail::bool_list<testing::v1::detail::is_gmock_type<TMocks>::value
...> >::value), int>::type <anonymous>, class ... TArgs> auto testing::v1::make(TArgs&& ...)’
  444 | auto make(TArgs &&... args) {
      |      ^~~~
include/GUnit/GMake.h:444:6: note:   template argument deduction/substitution failed:

jamespharvey20 avatar May 02 '19 02:05 jamespharvey20