The error, of course, is not Boost; boost::function is basically just std::function with all the semantics. And boost::function , where the reference parameters work fine. You simply cannot use them with std::not1 or the rest of the <functional> .
C ++ 11 reference-collapsing makes std::not1 work the way you think. The method std::not1 was specified in C ++ 03, it may not have worked without link-collapsing - except for implementations when the developers interpreted the creative interpretation a bit, rather than slavishly following the letter of the standard.
You can make std::not1 work in C ++ 03 by adding the specialization std::unary_negate for predicates with the argument_type s reference, but neither lib ++ nor libstd ++ did this.
But do you know who? Boost If you just changed your code to use boost::not1 wherever you use std::not1 , everything will work fine. Basically, think of the boost namespace, as if it were a version compatible with C ++ 11 std ; everything that works in the C ++ 11 std probably works in the C ++ 03 boost namespace.
A Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) , I hope, is off topic: the Clang compiler on my Macbook ( Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) ) silently destroys links even in -std=c++03 mode, so
typedef const int& ref; typedef const ref& ref2;
does not cause errors. When you check your C ++ 03 code, make sure you are not using the compiler with this error.
Quuxplusone
source share