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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:23:20+00:00 2026-05-25T06:23:20+00:00

While experimenting with the C++11 std::scoped_allocator_adaptor as implemented in gcc 4.7.0 so far, I

  • 0

While experimenting with the C++11 std::scoped_allocator_adaptor as implemented in gcc 4.7.0 so far, I noticed that C++11 FDIS defines a specialization of std::uses_allocator for tuples (20.4.2.8[tuple.traits]), but not for pairs, although for all other purposes, pairs look and act just like tuples (they have specializations of std::get, std::tuple_size, etc).

On further reading, N2554, which introduced these things, defined allocator_arg constructors and uses_allocator specialization for the pairs as well (pages 23-24).

Why were they dropped for pairs? Is there another way to use them that I can’t see, or is this a hint of deprecation of pairs in favor of tuples?

My test code was:

// myalloc is like std::allocator, but has a single-argument
// constructor that takes an int, and has NO default constructor
typedef std::vector<int, myalloc<int>> innervector_t;
typedef std::tuple<int, innervector_t> elem_t;
typedef std::scoped_allocator_adaptor<myalloc<elem_t>, myalloc<int>> Alloc;
Alloc a(1,2);
std::vector<elem_t, Alloc> v(a);
v.resize(1);                  // uses allocator #1 for elements of v
// the following line fails to compile if pair is used instead of tuple
// because it attempts to default-construct myalloc<int> for innervector_t
std::get<1>(v[0]).resize(10); // uses allocator #2 for elements of innervector_t
  • 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-25T06:23:21+00:00Added an answer on May 25, 2026 at 6:23 am

    One reason is that we want to avoid having 15 constructors (like in N3000) for a seemingly simple class like std::pair.

    We have now instead got one “general-purpose” constructor

    template <class... Args1, class... Args2>
    pair(piecewise_construct_t,
         tuple<Args1...> first_args, tuple<Args2...> second_args);
    

    where you can pass just about anything you like to the constructors of each pair member, including allocators.

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

Sidebar

Related Questions

While experimenting with this question on collections in Spring.NET , I discovered that Spring
i've started learning about javascript closures, and while experimenting, i realised that the following
I'm experimenting with writing ActiveX controls and noticed that I can't seem to create
While experimenting with ternary and null coalesce operators in C# I discovered that it
While experimenting with pixel shaders in WPF I decided to draw some pixels onto
While experimenting a bit with C++ templates I managed to produce this simple code,
I'm an amateur programmer that's experimenting using pthreads, to see to what extent a
While experimenting with some stuff on the REPL, I got to a point where
While experimenting with iPhone app development, we have several AppIDs which should be deleted
I ran into the following algorithmic problem while experimenting with classification algorithms. Elements are

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.