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

  • Home
  • SEARCH
  • 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 609191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:32:22+00:00 2026-05-13T17:32:22+00:00

I have a templated class template <T> class Example { … }; inside which

  • 0

I have a templated class

template <T>
class Example 
{
...
};

inside which there
are many methods of the following type:

template <class U> <class V> method(....)

Inside these I use tr1::shared_ptr to U or V or T.

Its tedious typing tr1::shared_ptr<const U> or tr1::shared_ptr<const V>.

The obvious thing to do:

template <typename U>
typedef tr1::shared_ptr<U> shptr<U>;

does not work.

What do you do in this situation? Anything that can reduce verbosity?

  • 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-05-13T17:32:22+00:00Added an answer on May 13, 2026 at 5:32 pm

    You can use an inner type:

    template <typename U>
    struct sptr {
        typedef tr1::shared_ptr<U> t;
    };
    

    Then say sptr<U>::t, or unfortunately often typename sptr<U>::t.

    C++0x has template typedefs, you could check whether your compiler can be persuaded to accept them:

    template<typename U>
    using sptr = tr1::shared_ptr<U>;
    

    Then say sptr<U>

    And of course there’s always #define sptr ::tr1::shared_ptr, for example if you’re expecting C++0x in future and want to bridge the gap. Or if you’re using it in a narrow enough context that a macro isn’t scary.

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

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The error is pretty straightforward (the class wasn't found). I… May 16, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer Right, I have finally worked out where the extra tables… May 16, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer What you ask is not possible. A double in C#… May 16, 2026 at 5:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

If you have a templated base class as in the following example: class A{
I have this example code: #include template<class T> class Class { public: typedef boost::shared_ptr<Class<T>
Let's say I'm using a templated class with something simple like: template <class T>
I have that template class that uses a policy for it's output and another
Given the following template: template <typename T> class wrapper : public T {}; What
I am trying to build a template function. Inside templated classes are used and
I have two classes. One is a management class, which stores a bunch of
Given the following template: template<class T> class Container { private: boost::function<T> f; }; ...
I'm writing a template for which I'm trying to provide a specialization on a
I developed a generic Unsigned class, or really a class template Unsigned<size_t N> that

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.