This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 172419 - Boost metaprogramming usage problem
Summary: Boost metaprogramming usage problem
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: nnnnnk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-16 20:05 UTC by yfiterman
Modified: 2011-07-26 14:15 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yfiterman 2009-09-16 20:05:07 UTC
#include <boost/iostreams/filtering_stream.hpp>
...
   filtering_stream<input> foo;
   foo.push(zlib_decompressor()); //unable to resolve identifier push

From 'filtering_stream.hpp':
...
'// Macro: BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_)
// Description: Defines a template derived from std::basic_streambuf which uses
//      a chain to perform i/o. The template has the following parameters:
//      Mode - the i/o mode.
//      Ch - The character type.
//      Tr - The character traits type.
//      Alloc - The allocator type.
//      Access - Indicates accessibility of the chain interface; must be either
//          public_ or protected_; defaults to public_.
// Macro parameters:
//      name_ - The name of the template to be defined.
//      chain_type_ - The name of the chain template.
//      default_char_ - The default value for the char template parameter.
//
#define BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_) \
    template< typename Mode, \
              typename Ch = default_char_, \
              typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
              typename Alloc = std::allocator<Ch>, \
              typename Access = public_ > \
    class name_ \
        : public boost::iostreams::detail::filtering_stream_base< \
                     chain_type_<Mode, Ch, Tr, Alloc>, Access \
                 > \
    { \
    public: \
        typedef Ch                                char_type; \
        struct category \
            : Mode, \
              closable_tag, \
              detail::filtering_stream_traits<Mode, Ch, Tr>::stream_tag \
            { }; \
        BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
        typedef Mode                              mode; \
        typedef chain_type_<Mode, Ch, Tr, Alloc>  chain_type; \
        name_() { } \
        BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
        ~name_() { \
            if (this->is_complete()) \
                 this->rdbuf()->BOOST_IOSTREAMS_PUBSYNC(); \
        } \
    private: \
        typedef access_control< \
                    boost::iostreams::detail::chain_client< \
                        chain_type_<Mode, Ch, Tr, Alloc> \
                    >, \
                    Access \
                > client_type; \
        template<typename T> \
        void push_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS()) \
        { client_type::push(t BOOST_IOSTREAMS_PUSH_ARGS()); } \
    }; \
    /**/    
BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(filtering_stream, boost::iostreams::chain, char)
BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(wfiltering_stream, boost::iostreams::chain, wchar_t)

typedef filtering_stream<input>    filtering_istream;
typedef filtering_stream<output>   filtering_ostream;
typedef wfiltering_stream<input>   filtering_wistream;
typedef wfiltering_stream<output>  filtering_wostream;'
Comment 1 nnnnnk 2009-09-17 20:41:29 UTC
Hello.

I had out of memory exception.
Now I've fixed it.
But push is still unresolved.

And I can not compile your example too.

With other functions everything is ok (after fixing of out of memory exception).
--
#include <boost/iostreams/filtering_stream.hpp>
int main() {
   boost::iostreams::filtering_stream<boost::iostreams::input> foo;
   foo.get();  // resolved
   return 0;
}
-- or
#include <boost/iostreams/filtering_stream.hpp>

int main() {
   boost::iostreams::filtering_stream<boost::iostreams::output> foo;
   foo.put('c');
   return 0;
}
--

Do you have any completion after foo?
Could you provide some simple compilable example?

I'll put my current changes tomorrow.
And they will be in the nightly build the day after tomorrow.
Comment 2 nnnnnk 2009-09-18 12:10:00 UTC
Hello, Julian.

I can not compile your code with g++-4.3.2 and Sun Studio 12.1.
With other functions (get, put) it works fine.
So may be fixed exception was the reason of the problem.

I'll close this IZ as fixed.
Please reopen it if will be wrong on you computer.

Regards,
Nick.

fixed
http://hg.netbeans.org/cnd-main?cmd=changeset;node=8c0953fca0a6
Comment 3 nnnnnk 2009-09-18 16:48:48 UTC
Nightly builds are available from
http://bits.netbeans.org/download/trunk/nightly/latest/

Comment 4 Quality Engineering 2009-09-19 10:59:31 UTC
Integrated into 'main-golden', will be available in build *200909190201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/8c0953fca0a6
User: Nick N. Krasilnikov <nnnnnk@netbeans.org>
Log: fixing IZ#172419 : Model doesn't recognize class declared through the preprocessor
Comment 5 yfiterman 2009-09-23 16:55:19 UTC
The fix does improve the recognition of the subclass(istream) member functions of filtering_stream but the 'push' member
function is still not recognized. Please note that the push function is part of the standard interface to the
filtering_stream class of the boost::iostreams library. It has nothing particular to do with my code.

Consider this simpler example:

#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/filtering_stream.hpp>

namespace io = boost::iostreams;

int main()
{   
    io::filtering_ostream out;
    out.push(file_sink("my_file.txt")); //unable to resolve identifier 'push'
    // write to out using std::ostream interface
}
Comment 6 nnnnnk 2009-09-24 15:11:27 UTC
Thank you very much.

Compilable (Sun Stusio) example:
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>

namespace io = boost::iostreams;

int main()
{
    io::filtering_ostream out;
    out.push(io::file_sink("my_file.txt")); // push is unresolved
}
Comment 7 nnnnnk 2009-09-24 15:24:46 UTC
Simple example:
struct A {
    int i;
};

template<typename T>
struct B {
    typedef T type;
};

template<typename T, typename Base = typename B<T>::type >
struct C : public Base {
};

int main() {
    C<A> c;
    c.i++; // unresolved
}
Comment 8 nnnnnk 2009-09-24 17:31:28 UTC
I've fixed simple example.
But there are another reason of the problem - partial evaluation of static constructions.
And now we do not it.
Example:
template< bool C_ > struct bool_
{
    static const bool value = C_;
};

typedef bool_<true> _true;

template <bool i> class A {
};

template <> struct A<true> {
    int i;
};

int main() {
    A<_true::value> a;
    a.i++; // unresolved
}
Comment 9 yfiterman 2009-09-24 17:48:54 UTC
Alright. Well, at least there is progress? Out of curiosity are you planning to add this to the model at some point?
Comment 10 nnnnnk 2009-09-24 19:25:50 UTC
Yes, I'd like to add it.
But I'm not sure that it will be implemented in 6.8.
Do you know does some IDE already support partial evaluation?
Comment 12 Quality Engineering 2009-10-01 00:49:34 UTC
Integrated into 'main-golden', will be available in build *200909301401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/9f28196e9e22
User: Nick N. Krasilnikov <nnnnnk@netbeans.org>
Log: partly fixed IZ#172419 : Model doesn't recognize class declared through the preprocessor
Comment 13 nnnnnk 2010-03-24 17:14:25 UTC
Last sample is fixed.
Problem is still here.

So it's more common boost usage problem.
Comment 15 nnnnnk 2011-05-23 16:13:54 UTC
last sample (unresolved a.accept) has different reasons.
created another bug:
http://netbeans.org/bugzilla/show_bug.cgi?id=198823
Comment 16 nnnnnk 2011-06-06 15:49:28 UTC
fixed under flags, because fix decreases performance (~30%).
to enable provide:
-J-Dcnd.modelimpl.expression.evaluator.deep.variable.provider=true -J-Dcnd.modelimpl.expression.evaluator.recursive.calc=true -J-Dcnd.modelimpl.expression.evaluator.extra.spec.params.matching=true

http://hg.netbeans.org/releases/rev/8982adaea001