clang 3.6.0 kullanma, aşağıdaki kod örneğini derleyemiyorum.'Constexpr' Şablonu Kullanılabilir Mümkün Bir Resmi Şablon Değişkeni için Varsayılan Olarak Değişken
#include <type_traits>
template <typename T> constexpr bool IS_SCALAR = ::std::is_scalar<T>::value;
template <typename T, bool = IS_SCALAR<T>>
struct Class_Breaks
{
};
template <typename T, bool = ::std::is_scalar<T>::value>
struct Class_Works
{
};
void function()
{
Class_Breaks<int> break_error;
Class_Breaks<int, IS_SCALAR<int>> breaks_ok;
Class_Works<int> ok;
}
Fakat, aşağıdaki hata iletileri döndürülür:
@StenSoft tarafından belirtildiği gibi1> [ 66%] Building CXX object CMakeFiles/Core.dir/tests.cpp.obj
1>D:\Projects\Core\Core\tests.cpp(4,30): error : non-type template argument is not a constant expression
1> template <typename T, bool = IS_SCALAR<T>>
1> ^
1> D:\Projects\Core\Core\tests.cpp(16,18) : note: while checking a default template argument used here
1> Class_Breaks<int> break_error;
1> ~~~~~~~~~~~~~~~~^
1> 1 error generated.
[Bilinen bir hata] (https://stackoverflow.com/questions/10721130/) – StenSoft