The following code fragment builds perfectly in accordance with Clang 3.4 / 3.5 (Xcode 5/6), but throws an error in Visual C ++ 14 CTP3:
1> ------ Build start: Project: InheritingConstructor, Configuration:
Win32 debugging ------ 1> inheritingconstructor.cpp (60): error C2661:
'D :: D': no ββoverloaded function accepts 2 argument
========== Build: 0 succeeded, 1 failed, 0 updated, 0 skipped ==========
The code strengthens the compiler a bit by trying to inherit the template constructor from the base class, is it possible that when Visual C ++ fails again in the competition? Or am I getting into some kind of gray area, thus undefined behavior in the standard?
#include "stdafx.h"
#include <iostream>
#include <type_traits>
template <typename X>
struct B
{
int i;
B(int i_) : i(i_) {}
template < typename T, typename = typename std::enable_if<
std::is_same<T, X>::value >::type >
B(const T*, const T*) : i(0) {}
};
struct D : B<D>
{
using B<D>::B;
};
int main(int argc, const char * argv[]) {
D d((D*)nullptr, (D*)nullptr);
std::cout << "Hello, World!\n";
return 0;
}