Project

General

Profile

Bug #6417

make_unique() fails on initializer list

Added by Christopher Green over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
06/05/2014
Due date:
% Done:

0%

Estimated time:
Duration:

Description

The following C++ test program:

#include "cetlib/make_unique.h" 

#include <memory>
#include <vector>

int main()
{
  auto x [[gnu::unused]] =
    cet::make_unique<std::vector<double> >({1.0, 2.0, 3.0});
}
fails to compile:
[greenc@mac-120590] ~ (ups) $ g++ -std=c++11 -Wall -Wextra -Werror -g -O0 -I$CETLIB_INC -L$CETLIB_INC -lcetlib -o bug bug.cc
bug.cc: In function ‘int main()’:
bug.cc:9:59: error: too many arguments to function ‘std::unique_ptr<T> cet::make_unique(Args&& ...) [with T = std::vector<double>; Args = {}]’
     cet::make_unique<std::vector<double> >({1.0, 2.0, 3.0});
                                                           ^
In file included from bug.cc:1:0:
/Users/greenc/work/cet-is/external-products/cetlib/v1_04_03/include/cetlib/make_unique.h:14:3: note: declared here
   make_unique(Args&& ... args)
   ^
Doubling-up the braces does not help here.

History

#1 Updated by Christopher Green over 5 years ago

  • Status changed from New to Rejected

The current implementations of std::make_shared (C++11) and std::make_unique (C++14) in G++ 4.9.0 behave in exactly the same way. There appears to be no way to obtain the desired behavior at this point in time. Whether this is a bug in G++ 4.9.0's implementation or a limitation of the standard is unclear.



Also available in: Atom PDF