The following function
derefItemX()
//! Accessory Operations - template argument depended wrappers
template<bool SIMPLE> // For Nodes / non-scoped storage
struct Operations {
//! \brief Defererence wrapped or direct iterator
//!
//! \param iel IItemXT& - iterator to be dereferenced
//! \return ItemT& - resulting reference
template<typename IItemXT>
constexpr static auto& derefItemX(IItemXT& iel)
{
static_assert(is_base_of<std::forward_iterator_tag, typename IItemXT::iterator_category>::value
, "derefItemX(), IItemXT must be a forward iterator type");
return **iel; // Dereference an iterator of pointer to the value
}
};
//! Specialization for non-scoped storage (direct pointers)
template<>
template<typename IItemXT>
constexpr auto& Operations<true>::derefItemX(IItemXT& iel)
{
static_assert(is_base_of<std::forward_iterator_tag, typename IItemXT::iterator_category>::value
, "derefItemX(), IItemXT must be a forward iterator type");
return *iel; // Dereference an iterator of value to the value
}
...
// Usage:
auto& el = Operations<!is_pointer<typename IItemXT::value_type>
::value>::derefItemX(ic);
derefItemX()
include/hierarchy.hpp:168:35: error: out-of-line definition of 'derefItemX' does not match any declaration in 'XXX::Operations<true>'
constexpr auto& Operations<true>::derefItemX(IItemXT& iel)
^~~~~~~~~~
derefItemX()
I don't how to solve the problem in a general way; but this problem (if I'm not wrong) could be solved specializing the entire class; something like
#include <iterator>
#include <type_traits>
using namespace std;
template <bool>
struct Operations;
template<>
struct Operations<false> {
template<typename IItemXT>
constexpr static auto& derefItemX(IItemXT& iel)
{
static_assert(is_base_of<std::forward_iterator_tag, typename IItemXT::iterator_category>::value
, "derefItemX(), IItemXT must be a forward iterator type");
return **iel; // Dereference an iterator of pointer to the value
}
};
template<>
struct Operations<true> {
template<typename IItemXT>
constexpr auto& derefItemX(IItemXT& iel)
{
static_assert(is_base_of<std::forward_iterator_tag, typename IItemXT::iterator_category>::value
, "derefItemX(), IItemXT must be a forward iterator type");
return *iel; // Dereference an iterator of value to the value
}
};
Regarding the problem "why the clang fail to compile"... i'm confused and I don't know whos right between g++ and clang++
p.s.: sorry for my bad English