From 9730ff4183a0d92e2c63c38b23a0ec7d806c4b64 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 31 Dec 2009 01:21:45 +0100 Subject: [PATCH] trying to track down a strange compiler warning --- src/tool/try.cpp | 87 ++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/src/tool/try.cpp b/src/tool/try.cpp index de206c43e..b2823afc8 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -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 #define LUMIERA_LOGGING_CXX #include "include/logging.h" //#include "include/nobugcfg.h" -#include "lib/bool-checkable.hpp" + +#include #include //#include -#include +#include #include #include +//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 + 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 - { - - 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 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";