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 8436163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:06:34+00:00 2026-06-10T07:06:34+00:00

I was watching a boostcon talk on youtube titled Introduction to Modern C++ Techniques

  • 0

I was watching a boostcon talk on youtube titled “Introduction to Modern C++ Techniques (Part I)”. Around minute 22 the speaker shows a class which overloads the dereference operator.

template<typename T,
         typename CheckingPolicy = NoChecking,
         typename BadPointerPolicy = BadPointerDoNothing>
class pointer_wrapper
{
public:
    pointer_wrapper() : value_(0) {}
    explicit pointer_wrapper(T* p) : value_(p) {}

    operator T*()
    {
        if ( ! CheckingPolicy::check_pointer(value_) )
        {
            return BadPointerPolicy::handle_bad_pointer(value_);
        }
        else
        {
            return value_;
        }
    }

private:
    T* value_;
};

I have never seen this way of overloading the dereference operator. Why is there no return type and why does the T appear after the ‘operator’ keyword?
I always thought the way to overload this operator was like this:

T& operator *()
{
    // ...
    return *value_
}

If anybody is interested, here is the talk

  • 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-10T07:06:35+00:00Added an answer on June 10, 2026 at 7:06 am

    It’s implicit conversion operator to type T*.
    n3337 12.3.2/1

    A member function of a class X having no parameters with a name of the form

    conversion-function-id:

    operator conversion-type-id

    conversion-type-id:

    type-specifier-seq
    conversion-declaratoropt

    conversion-declarator:

    ptr-operator conversion-declaratoropt

    specifies a conversion from X to the type specified by the conversion-type-id. Such functions are called
    conversion functions. No return type can be specified.

    If a conversion function is a member function, the
    type of the conversion function (8.3.5) is “function taking no parameter returning conversion-type-id”
    .

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

Sidebar

Related Questions

From watching the 2-part YouTube videos and perusing the BIRT manual, my understanding of
I'm watching this lecture: http://www.youtube.com/watch?v=Kq4FpMe6cRs // the speaker states that 'bar' is just some
i am watching this tutorial. at around 15:40, the speaker said something like a
Watching some videos they talk about endpoints and im not sure what the differences
After watching a YouTube video on the Diffie-Hellman Key Exchange , I wanted to
After watching the Fasts Rails Tests talk by Corey and reading through Object on
I was watching the latest C9 lecture and noticed something interesting.. In his introduction
When watching a video on youtube you get a dark player But when you
I was just watching a video on MSDN Channel 9 which can be found
I was watching Anders' talk about C# 4.0 and sneak preview of C# 5.0

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.