trying to track down a strange compiler warning
This commit is contained in:
parent
484213e42d
commit
9730ff4183
1 changed files with 51 additions and 36 deletions
|
|
@ -13,71 +13,86 @@
|
|||
// 7/08 - combining partial specialisation and subclasses
|
||||
// 10/8 - abusing the STL containers to hold noncopyable values
|
||||
// 6/09 - investigating how to build a mixin template providing an operator bool()
|
||||
// 12/9 - tracking down a strange "warning: type qualifiers ignored on function return type"
|
||||
|
||||
|
||||
#include <nobug.h>
|
||||
#define LUMIERA_LOGGING_CXX
|
||||
#include "include/logging.h"
|
||||
//#include "include/nobugcfg.h"
|
||||
#include "lib/bool-checkable.hpp"
|
||||
|
||||
#include <tr1/functional>
|
||||
|
||||
#include <iostream>
|
||||
//#include <typeinfo>
|
||||
#include <boost/format.hpp>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
//using std::tr1::bind;
|
||||
using std::tr1::placeholders::_1;
|
||||
|
||||
using std::rand;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using boost::format;
|
||||
|
||||
|
||||
namespace {
|
||||
boost::format fmt ("<%2i>");
|
||||
long checksum = 0;
|
||||
|
||||
template <typename SEQ, typename Oper>
|
||||
inline bool
|
||||
eat_all (SEQ& coll, Oper predicate)
|
||||
{
|
||||
typename SEQ::const_iterator e = coll.end();
|
||||
typename SEQ::const_iterator i = coll.begin();
|
||||
|
||||
predicate(*i);
|
||||
|
||||
// for ( ; i!=e; ++i )
|
||||
// if (!predicate(*i))
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct TestIt1
|
||||
: lib::BoolCheckable<TestIt1>
|
||||
{
|
||||
|
||||
int val_;
|
||||
|
||||
TestIt1 (int v = (rand() % 10))
|
||||
: val_(v)
|
||||
{ }
|
||||
|
||||
bool
|
||||
isValid() const
|
||||
{
|
||||
return val_ % 2;
|
||||
}
|
||||
|
||||
};
|
||||
// template < typename CON, typename FUN
|
||||
// , typename P1
|
||||
// , typename P2
|
||||
// >
|
||||
// inline bool
|
||||
// eat_all (CON& elements, FUN function, P1 bind1, P2 bind2)
|
||||
// {
|
||||
// return eat_all (elements, std::tr1::bind (function, bind1, bind2));
|
||||
// }
|
||||
|
||||
|
||||
namespace {
|
||||
// std::tr1::_Placeholder<1> _1;
|
||||
|
||||
bool
|
||||
plainFunc (int i, int j)
|
||||
{
|
||||
cout <<':'<< i+j;
|
||||
return i+j;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int, char**) //(int argc, char* argv[])
|
||||
main (int, char**)
|
||||
{
|
||||
|
||||
NOBUG_INIT;
|
||||
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
TestIt1 testrosteron (i);
|
||||
|
||||
if (testrosteron)
|
||||
cout << "doIt \n";
|
||||
if (!testrosteron)
|
||||
cout << i << "\n";
|
||||
}
|
||||
cout << "size=" << sizeof(TestIt1) <<"\n";
|
||||
typedef std::vector<int> VecI;
|
||||
|
||||
char* horror = 0;
|
||||
ERROR (all, "note: %s is a horrible thing", horror);
|
||||
uint count = 4;
|
||||
VecI numberz;
|
||||
while (count)
|
||||
numberz.push_back(count--);
|
||||
|
||||
// eat_all (numberz, plainFunc, 10, _1 );
|
||||
eat_all (numberz, std::tr1::bind (plainFunc, 10, _1));
|
||||
|
||||
cout << "\n.gulp.\n";
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue