VS2015:error C2912
flyleier opened this issue · comments
error C2912: explicit specialization;“bool dbg::pretty_print(std::ostream &,const dbg::time &)”is not a specialization of a function template.
When I try to comment the line of 'template <>', I get even more errors.
//template <>
inline bool pretty_print(std::ostream& stream, const time&);
I'm sorry, but VS2015 is probably not supported. Newer versions should be, though.
dbg-macro/.github/workflows/ci.yml
Lines 11 to 27 in 4db6180
I'm sorry, but VS2015 is probably not supported. Newer versions should be, though.
dbg-macro/.github/workflows/ci.yml
Lines 11 to 27 in 4db6180
Thanks for replay. I made some changes and dbg-macro is now available for use in my project. The changes are as follows
/*
template <typename T>
using detect_begin_t = decltype(detail::begin(std::declval<T>()));
template <typename T>
using detect_end_t = decltype(detail::end(std::declval<T>()));
template <typename T>
using detect_size_t = decltype(detail::size(std::declval<T>()));
template <typename T>
struct is_container {
static constexpr bool value =
is_detected<detect_begin_t, T>::value &&
is_detected<detect_end_t, T>::value &&
is_detected<detect_size_t, T>::value &&
!std::is_same<std::string,
typename std::remove_cv<
typename std::remove_reference<T>::type>::type>::value;
};
*/
template<typename T, typename _ = void>
struct is_container : std::false_type {};
template<typename... Ts>
struct is_container_helper {};
template<typename T>
struct is_container<
T,
typename std::conditional<
false,
is_container_helper<
typename std::decay<T>::type::value_type,
typename std::decay<T>::type::size_type,
typename std::decay<T>::type::allocator_type,
typename std::decay<T>::type::iterator,
typename std::decay<T>::type::const_iterator,
decltype(std::declval<T>().size()),
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end()),
decltype(std::declval<T>().cbegin()),
decltype(std::declval<T>().cend())
>,
void
>::type
> : public std::true_type {};
template <typename T>
struct is_container<const std::valarray<T> &> : public std::true_type { };
template <typename T, std::size_t N>
struct is_container<const std::array<T, N> &> : public std::true_type { };
I did some tests in VS2015 and VS2019 and it worked fine.
There may be some limitations, but I hope that someone with this problem can be helped.
Nice.
There may be some limitations, but I hope that someone with this problem can be helped.
Does the whole test-suite still run?
Does the whole test-suite still run?
Not all, the demo.cpp and example.cpp still run, but basic.cpp has a build error : C2679: binary '<<': no operator found which takes a right-hand operand of type 'const user_defined_container<int,3>'
, the error place:
//basic.cpp
SECTION("containers") {
user_defined_container<int, 3> xs{{1, 2, 3}};
CHECK(pretty_print(xs) == "{1, 2, 3}"); // error C2679
}
Don't support user defined container, only STL container. if want to print user defined container, must overload operator <<, like this:
template <typename T, std::size_t N>
struct user_defined_container {
T data[N];
const T* begin() const { return data; }
const T* end() const { return data + N; }
const T* cbegin() const { return data+N-1; }
const T* cend() const { return data-1; }
std::size_t size() const { return N; }
friend std::ostream & operator<<( std::ostream & os, const user_defined_container & value)
{
for(auto i = value.begin(); i != value.end(); ++i)
{
os << *i;
}
return os;
}
};
It is appropriate for my project, So, I have no further changes.
I see - thank you for clarifying. In this case, I think we can close this and people running into the same error on old MSVC versions will hopefully find your solution.