Namespaces
Variants
Views
Actions

Talk:cpp/container/set/set

From cppreference.com

Example is for map, not set!

   220.156.98.41 23:41, 26 December 2013 (PST) Nishant

Example is now for set. I've tested gcc and clang, both compile and produce expected output. Incidentally I made a new template page for this to not damage other pages using the old template, but that template is poorly made and could be replaced by a more generic version of my template.

   DizzySkin (talk) 00:42, 22 June 2014 (PDT)

[edit] The default constructor can take arguments?

I find it misleading that the default constructor can take a Compare and an Allocator. The default constructor is only when both arguments gets their default values, otherwise we have overloaded constructors where we can input the Compare and/or Allocators. 69.191.176.31 09:24, 26 September 2014 (PDT)

The constructor set(const Compare& comp = Compare(), const Allocator& alloc = Allocator()) is the default constructor. I'll wikilink the definition. --Cubbi (talk) 09:39, 26 September 2014 (PDT)

[edit] Optional allocator in C++14 range/initializer-list constructor creates ambiguity?

It seems the given definitions of the range and initializer-list constructors added in C++14 mark the Allocator parameter as optional, creating an ambiguity when called with only first and last.

According to n4140's §23.4.6.1, the new range and initializer-list constructors are instead:

template< class InputIt >
set(InputIt first, InputIt last,
    const Allocator& alloc); // alloc is not optional

set(std::initializer_list<value_type> init,
    const Allocator& alloc); // alloc is not optional

Surprisingly, cplusplus.com makes the allocator optional too. Should this page be modified to comply with the standard?

KevinSztern (talk) 14:06, 4 December 2014 (PST)

Yes this page is wrong, that constructor was supposed to be the default compare/non-default allocator range constructor. I updated it just now. Thank you for bringing it up! --Cubbi (talk) 15:31, 4 December 2014 (PST)