Quantcast

[Boost.Test] Custom DataSet compiler error with no match for »operator^

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Boost.Test] Custom DataSet compiler error with no match for »operator^

Boost - Dev mailing list
Hello,


I run into a compile problem with [Boost.Test] DataSet. I can reduce it
by re-using the example provided by the docs:

http://www.boost.org/doc/libs/1_62_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html#boost_test.tests_organization.test_cases.test_case_generation.datasets.example_descr

#define  BOOST_TEST_MODULE  dataset_example68
#include  <boost/test/included/unit_test.hpp>
#include  <boost/test/data/test_case.hpp>
#include  <boost/test/data/monomorphic.hpp>
#include  <sstream>

namespace  bdata  =  boost::unit_test::data;

// Dataset generating a Fibonacci sequence
class  fibonacci_dataset  {
public:
     // Samples type is int
     using  sample=int;
     enum  {  arity  =  1  };

     struct  iterator  {

         iterator()  :  a(1),  b(1)  {}

         int  operator*()  const    {  return  b;  }
         void  operator++()
         {
             a  =  a  +  b;
             std::swap(a,  b);
         }
     private:
         int  a;
         int  b;  // b is the output
     };

     fibonacci_dataset()              {}

     // size is infinite
     bdata::size_t    size()  const     {  return  bdata::BOOST_TEST_DS_INFINITE_SIZE;  }

     // iterator
     iterator         begin()  const    {  return  iterator();  }
};

namespace  boost  {  namespace  unit_test  {  namespace  data  {  namespace  monomorphic  {
   // registering fibonacci_dataset as a proper dataset
   template  <>
   struct  is_dataset<fibonacci_dataset>  :  boost::mpl::true_  {};
}}}}

// Creating a test-driven dataset
BOOST_DATA_TEST_CASE(
     test1,
     fibonacci_dataset()  ^  fibonacci_dataset(),
     fib_sample,  exp)
{
       BOOST_TEST(fib_sample  ==  exp);
}


  error: no match for 'operator^' (operand types are
'boost::unit_test::data::result_of::make<fibonacci_dataset>::type {aka
fibonacci_dataset}' and 'fibonacci_dataset')
      fibonacci_dataset() ^ fibonacci_dataset(),

My use case has to load input and expect files provides by two datasets.
How to fix it?


Thanks,

Olaf


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Boost.Test] Custom DataSet compiler error with no match for »operator^

Boost - Dev mailing list
AMDG

On 03/28/2017 01:38 PM, Olaf Peter via Boost wrote:

>
> I run into a compile problem with [Boost.Test] DataSet. I can reduce it
> by re-using the example provided by the docs:
>
> http://www.boost.org/doc/libs/1_62_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html#boost_test.tests_organization.test_cases.test_case_generation.datasets.example_descr
>
> <snip>
>     fibonacci_dataset()  ^  fibonacci_dataset(),
> <snip>
>
>  error: no match for 'operator^' (operand types are
> 'boost::unit_test::data::result_of::make<fibonacci_dataset>::type {aka
> fibonacci_dataset}' and 'fibonacci_dataset')
>      fibonacci_dataset() ^ fibonacci_dataset(),
>
> My use case has to load input and expect files provides by two datasets.
> How to fix it?
>

Bring the operator into scope:

using bdata::monomorphic::operator^;

This would normally be found by ADL, if either of the
datasets is from Boost.Test.

In Christ,
Steven Watanabe


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Boost.Test] Custom DataSet compiler error with no match for »operator^

Boost - Dev mailing list

> On 03/28/2017 01:38 PM, Olaf Peter via Boost wrote:
>>
>> I run into a compile problem with [Boost.Test] DataSet. I can reduce it
>> by re-using the example provided by the docs:
>>
>> http://www.boost.org/doc/libs/1_62_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html#boost_test.tests_organization.test_cases.test_case_generation.datasets.example_descr
>>
>> <snip>
>>     fibonacci_dataset()  ^  fibonacci_dataset(),
>> <snip>
>>
>>  error: no match for 'operator^' (operand types are
>> 'boost::unit_test::data::result_of::make<fibonacci_dataset>::type {aka
>> fibonacci_dataset}' and 'fibonacci_dataset')
>>      fibonacci_dataset() ^ fibonacci_dataset(),
>>
>> My use case has to load input and expect files provides by two datasets.
>> How to fix it?
>>
>
> Bring the operator into scope:
>
> using bdata::monomorphic::operator^;
>
> This would normally be found by ADL, if either of the
> datasets is from Boost.Test.

Thank you Steven, this works (at last for fibonacci_dataset(), at home
probably too, but I can't test it locally).


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Boost.Test] Custom DataSet compiler error with no match for »operator^

Boost - Dev mailing list
Le 29/03/2017 à 07:33, Olaf Peter via Boost a écrit :

>
>> On 03/28/2017 01:38 PM, Olaf Peter via Boost wrote:
>>>
>>> I run into a compile problem with [Boost.Test] DataSet. I can reduce it
>>> by re-using the example provided by the docs:
>>>
>>> http://www.boost.org/doc/libs/1_62_0/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html#boost_test.tests_organization.test_cases.test_case_generation.datasets.example_descr
>>>
>>>
>>> <snip>
>>>     fibonacci_dataset()  ^  fibonacci_dataset(),
>>> <snip>
>>>
>>>  error: no match for 'operator^' (operand types are
>>> 'boost::unit_test::data::result_of::make<fibonacci_dataset>::type {aka
>>> fibonacci_dataset}' and 'fibonacci_dataset')
>>>      fibonacci_dataset() ^ fibonacci_dataset(),
>>>
>>> My use case has to load input and expect files provides by two datasets.
>>> How to fix it?
>>>
>>
>> Bring the operator into scope:
>>
>> using bdata::monomorphic::operator^;
>>
>> This would normally be found by ADL, if either of the
>> datasets is from Boost.Test.
>
> Thank you Steven, this works (at last for fibonacci_dataset(), at home
> probably too, but I can't test it locally).
>

Please note that with this example, you are combining several datasets
and none of them has a finite size: it will yield a runtime error.

Best,
Raffi



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...