Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8901403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:20:44+00:00 2026-06-15T01:20:44+00:00

I wanted to protect the access to a log file that I use for

  • 0

I wanted to protect the access to a log file that I use for multithreaded logging with boostlog library.

I tried this stream class

class ThreadSafeStream
{
public:
    template <typename TInput>
    const ThreadSafeStream& operator<< (const TInput &tInput) const
    {
         // some thread safe file access    
         return *this;
    }
};

using it this way (text_sink is a boostlog object):

    //...
m_spSink.reset(new text_sink); 
text_sink::locked_backend_ptr pBackend = m_spSink->locked_backend();

const boost::shared_ptr< ThreadSafeStream >& spFileStream = boost::make_shared<ThreadSafeStream>();

pBackend->add_stream(spFileStream); // this causes the compilation error

and I get this mysterious error: cannot convert from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T>'

the whole compile error:

Log.cpp(79): error C2664: 'boost::log2_mt_nt5::sinks::basic_text_ostream_backend<CharT>::add_stream' : cannot convert parameter 1 from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T> &'
1>          with
1>          [
1>              CharT=char
1>          ]
1>          and
1>          [
1>              T=ThreadSafeStream
1>          ]
1>          and
1>          [
1>              T=std::basic_ostream<char,std::char_traits<char>>
1>          ]
1>          Reason: cannot convert from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T>'
1>          with
1>          [
1>              T=ThreadSafeStream
1>          ]
1>          and
1>          [
1>              T=std::basic_ostream<char,std::char_traits<char>>
1>          ]
1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

I suspect that I am not well defining the operator<<()… but I don’t find what is wrong.

this is the prototype of addStream: void add_stream(shared_ptr< stream_type > const& strm); with typedef std::basic_ostream< target_char_type > stream_type;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:20:46+00:00Added an answer on June 15, 2026 at 1:20 am

    From the error message presuably pBackend->add_stream is expected a shared_ptr (!) to an ostream while you’re giving it a shared_ptr to a ThreadSafeStream which is a totally unrelated type. You’ll need to create an overloaded add_stream method that works with ThreadSafeStreams most likely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to use full import names in my project (see this question ).
In my app i wanted to use a custom font, i tried below approach
I'm taking over a project and wanted to understand if this is common practice
I wanted to use a particle system in a kinect project with c sharp
I wanted to know how to can i protect a resource on a webserver
I am going back and forth with my team on this and wanted to
I've created a jar from my Java project and wanted to use the same
I wanted to get some thoughts about API access either through WCF or MVC.
If I wanted to access a database in Delphi, I could add a datamodule
At the company I work for, I have created a Error Logging class to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.