Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Initializer lists not compiling with template constructors

$
0
0

Products: Intel® C++ Composer XE

Versions: 2013 SP1 (compiler 14.0)

Operating Systems: Windows*, Linux*, OS X*

Software Defect ID: DPD200248554

Problem: The compiler currently gives an error on initializer lists passed to template constructors. For example:

$ cat kb-sample.cpp
#include <initializer_list>
template <class T> class widget {
   template <class U> widget(std::initializer_list<U>);
};
widget<int> w = { 1, 2, 3};
$ icc -std=c++11 -c kb-sample.cpp
kb-sample.cpp(7): error: no instance of constructor "widget<T>::widget [with T=int]" matches the argument list
            argument types are: (int, int, int)
  widget<int> w = { 1, 2, 3};
                  ^
compilation aborted for kb-sample.cpp (code 2)
Resolution: Our front-end team is investigating a resolution for this issue. If the arguments to the initializer list are not POD types, you may be able to workaround the problem by explicitly calling the constructor like so:
widget<other_widget> w = { other_widget{a}, other_widget{b}, other_widget{c} };
  • Apple Mac OS X*
  • Linux*
  • Microsoft Windows* (XP, Vista, 7)
  • Microsoft Windows* 8
  • C/C++
  • Intel® C++ Compiler
  • Intel® C++ Composer XE
  • Herramientas de desarrollo
  • Dirección URL
  • Temas de compilador

  • Viewing all articles
    Browse latest Browse all 1616

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>