boost::logging::manipulator::non_const_context< context_type > Struct Template Reference

In case your manipulator (formatter or destination) needs to hold non-const context information, it can to derive from this. This automatically creates a shared pointer to the context information. More...

Inheritance diagram for boost::logging::manipulator::non_const_context< context_type >:
[legend]

List of all members.


Detailed Description

template<class context_type>
struct boost::logging::manipulator::non_const_context< context_type >

In case your manipulator (formatter or destination) needs to hold non-const context information, it can to derive from this. This automatically creates a shared pointer to the context information.

Also, it provides the following operations:

context(), which returns a context_type & reference

Example:

struct write_to_file : destination_base, destination::non_const_context<std::ofstream> {
write_to_file(const char* filename) : non_const_context_base(filename) {}
void operator()(param msg) const {
    context() << msg ;
}
};

non_const_context - Pointer-like semantics

Using non_const_context guarantees pointer-like semantics: if you copy-construct or copy-assign a value, both values will point to the same context:

write_to_file a, b = a;
a.file_name("t1.txt");
// a == b  (a's state == b's state)

write_to_file c, d;
c.file_name("t2.txt");
// c != d  (c's state != d's state)

d = c;
c.file_name("t3.txt");
// c == d  (c's state == d's state)

Remarks:
In case your manipulator has constant data, you don't need this

The documentation for this struct was generated from the following file:

Copyright John Torjo © 2007
Have a question/ suggestion/ comment? Send me feedback