[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

   Severity|major   |normal


[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||fdumont at gcc dot gnu.org

--- Comment #2 from Paolo Carlini paolo.carlini at oracle dot com ---
With 100 KB of code to look at, this could be anything, could be front-end,
could be library, could well be boost.

Francois, did we change anything in the library for 4.8.x?


[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

--- Comment #3 from Daniel Krügler daniel.kruegler at googlemail dot com ---
First, this issue should be categorized as belonging to the component
libstdc++, not to c++.

Second, the defect report is invalid, because std::upper_bound requires a
minimum iterator category of forward iterator, but boost::transform_iterator
with a function object that returns a value (not a real reference) has an
iterator category input iterator, which is correct, since forward iterators
are required to return a real reference for operator*.

[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Paolo Carlini paolo.carlini at oracle dot com ---
Oh well, thanks Daniel for helping on this.


[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

--- Comment #5 from Daniel Krügler daniel.kruegler at googlemail dot com ---
(In reply to Paolo Carlini from comment #2)
 Francois, did we change anything in the library for 4.8.x?

I think that Francois added more iterator concept checking and this one looks
correct. Unfortunately I would say, this is correct, because the standard says
so, but from a practical point of view, std::upper_bound just works for any
forward traversal iterator and it does not require that the return type of
operator* *really* is a reference type. We also cannot blame boost here,
because it is not their fault that the standard requires for forward iterators
to have a real reference return type for iterator dereference. My
recommendation to the issue reporter would be to provide a function object that
returns a real reference. This can be easily done by a unary functor adaptor
such as the following one:

templateclass UnaryFunction, class ArgumentType
struct LValueUnaryFunctionAdaptor
{
  typedef typename std::result_ofconst UnaryFunction(ArgumentType)::type
value_type;
  LValueUnaryFunctionAdaptor(UnaryFunction func) : func(func) {}
  typedef const value_type result_type;
  result_type operator()(ArgumentType arg) const
  {
return res = func(arg);
  }
private:
  UnaryFunction func;
  mutable value_type res;
};

templateclass ArgumentType, class UnaryFunction
inline
LValueUnaryFunctionAdaptorUnaryFunction, ArgumentType
make_LValueUnaryFunction(UnaryFunction func)
{
  return LValueUnaryFunctionAdaptorUnaryFunction, ArgumentType(func);
}

So instead of

calc_value

he could use

make_LValueUnaryFunctionint(calc_value)

This trick doesn't make the transform_iterator fully conforming, but it should
convince the compile-time test machinery.

[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-19 Thread woodroof at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

--- Comment #6 from Danil Ilinykh woodroof at gmail dot com ---
Thank you!


[Bug c++/58191] Can't use boost transform_iterator with _GLIBCXX_DEBUG

2013-08-18 Thread woodroof at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58191

--- Comment #1 from Danil Ilinykh woodroof at gmail dot com ---
Created attachment 30671
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=30671action=edit
Preprocessed file archive