Isn't a pointer just a reference when you don't de-reference it?
#include "stdafx.h"
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
std::list<int>* user_defined_func( ) {
std::cout << "BEGIN: user_defined_func" << std::endl;
std::list<int>* l = new std::list<int>;
l->push_back(8);
l->push_back(0);
std::cout << "END: user_defined_func" << std::endl;
return l;
}
bool validate_list(std::list<int> &L1)
{
std::cout << "BEGIN: validate_list" << std::endl;
std::list<int>::iterator it1 = L1.begin();
for(; it1 != L1.end(); ++it1)
{
if(*it1<= 1){
std::cout << "Validation failed because an item in the list was less than or equal to 1." << std::endl;
std::cout << "END: validate_list" << std::endl;
return false;
}
}
std::cout << "Test passed because all of the items in the list were greater than or equal to 1" << std::endl;
std::cout << "END: validate_list" << std::endl;
return true;
}
BOOST_AUTO_TEST_SUITE( test )
BOOST_AUTO_TEST_CASE( test )
{
std::list<int>* list1 = user_defined_func();
BOOST_CHECK_PREDICATE( validate_list, (list1) );
}
BOOST_AUTO_TEST_SUITE_END()
In the line,
BOOST_CHECK_PREDICATE( validate_list, (list1) );
above, I was told that I can't pass pointer to the function expecting reference. I thought that a pointer (that hasn't been de-referenced) was just an address (i.e. a reference). What am I missing here?