Standalone function definitions in headers must be marked inline.

This commit is contained in:
Vassil Vassilev 2018-11-16 11:12:36 +01:00 committed by sftnight
parent 04601bd1bf
commit 4336ae74c7

View File

@ -28,7 +28,7 @@ namespace cling {
// Fallback for e.g. vector<bool>'s bit iterator: // Fallback for e.g. vector<bool>'s bit iterator:
template <class T, template <class T,
class = typename std::enable_if<!std::is_pointer<T>::value>::type> class = typename std::enable_if<!std::is_pointer<T>::value>::type>
std::string printValue(const T& val) { return "{not representable}"; } inline std::string printValue(const T& val) { return "{not representable}"; }
// void pointer // void pointer
std::string printValue(const void **ptr); std::string printValue(const void **ptr);
@ -92,22 +92,22 @@ namespace cling {
std::string toUTF8(const T* const Src, size_t N, const char Prefix = 0); std::string toUTF8(const T* const Src, size_t N, const char Prefix = 0);
template <size_t N> template <size_t N>
std::string printValue(char16_t const (*val)[N]) { inline std::string printValue(char16_t const (*val)[N]) {
return toUTF8(reinterpret_cast<const char16_t * const>(val), N, 'u'); return toUTF8(reinterpret_cast<const char16_t * const>(val), N, 'u');
} }
template <size_t N> template <size_t N>
std::string printValue(char32_t const (*val)[N]) { inline std::string printValue(char32_t const (*val)[N]) {
return toUTF8(reinterpret_cast<const char32_t * const>(val), N, 'U'); return toUTF8(reinterpret_cast<const char32_t * const>(val), N, 'U');
} }
template <size_t N> template <size_t N>
std::string printValue(wchar_t const (*val)[N]) { inline std::string printValue(wchar_t const (*val)[N]) {
return toUTF8(reinterpret_cast<const wchar_t * const>(val), N, 'L'); return toUTF8(reinterpret_cast<const wchar_t * const>(val), N, 'L');
} }
template <size_t N> template <size_t N>
std::string printValue(char const (*val)[N]) { inline std::string printValue(char const (*val)[N]) {
return toUTF8(reinterpret_cast<const char * const>(val), N, 1); return toUTF8(reinterpret_cast<const char * const>(val), N, 1);
} }
@ -124,13 +124,13 @@ namespace cling {
// Forward declaration, so recursion of containers possible. // Forward declaration, so recursion of containers possible.
template <typename T> std::string printValue(const T* V, const void* = 0); template <typename T> std::string printValue(const T* V, const void* = 0);
template <typename T> std::string template <typename T> inline std::string
printValue(const T& V, typename std::enable_if< printValue(const T& V, typename std::enable_if<
std::is_pointer<decltype(&V)>::value>::type* = 0) { std::is_pointer<decltype(&V)>::value>::type* = 0) {
return printValue(&V); return printValue(&V);
} }
template <typename T0, typename T1> std::string template <typename T0, typename T1> inline std::string
printValue(const std::pair<T1, T0>* V, const void* AsMap = 0) { printValue(const std::pair<T1, T0>* V, const void* AsMap = 0) {
if (AsMap) if (AsMap)
return printValue(&V->first) + " => " + printValue(&V->second); return printValue(&V->first) + " => " + printValue(&V->second);
@ -150,7 +150,7 @@ namespace cling {
// vector, set, deque etc. // vector, set, deque etc.
template <typename CollectionType> template <typename CollectionType>
auto printValue_impl( inline auto printValue_impl(
const CollectionType* obj, const CollectionType* obj,
typename std::enable_if< typename std::enable_if<
std::is_reference<decltype(*(obj->begin()))>::value>::type* = 0) std::is_reference<decltype(*(obj->begin()))>::value>::type* = 0)
@ -171,7 +171,7 @@ namespace cling {
// As above, but without ability to take address of elements. // As above, but without ability to take address of elements.
template <typename CollectionType> template <typename CollectionType>
auto printValue_impl( inline auto printValue_impl(
const CollectionType* obj, const CollectionType* obj,
typename std::enable_if< typename std::enable_if<
!std::is_reference<decltype(*(obj->begin()))>::value>::type* = 0) !std::is_reference<decltype(*(obj->begin()))>::value>::type* = 0)
@ -191,14 +191,14 @@ namespace cling {
// Collections // Collections
template<typename CollectionType> template<typename CollectionType>
auto printValue(const CollectionType *obj) inline auto printValue(const CollectionType *obj)
-> decltype(collectionPrinterInternal::printValue_impl(obj), std::string()) { -> decltype(collectionPrinterInternal::printValue_impl(obj), std::string()) {
return collectionPrinterInternal::printValue_impl(obj); return collectionPrinterInternal::printValue_impl(obj);
} }
// Arrays // Arrays
template<typename T, size_t N> template<typename T, size_t N>
std::string printValue(const T (*obj)[N]) { inline std::string printValue(const T (*obj)[N]) {
if (N == 0) if (N == 0)
return valuePrinterInternal::kEmptyCollection; return valuePrinterInternal::kEmptyCollection;
@ -213,7 +213,7 @@ namespace cling {
// Tuples // Tuples
template <class... ARGS> template <class... ARGS>
std::string printValue(std::tuple<ARGS...> *); inline std::string printValue(std::tuple<ARGS...> *);
namespace collectionPrinterInternal { namespace collectionPrinterInternal {
// We loop at compile time from element 0 to element TUPLE_SIZE - 1 // We loop at compile time from element 0 to element TUPLE_SIZE - 1
@ -249,7 +249,7 @@ namespace cling {
}; };
template <class T> template <class T>
std::string tuplePairPrintValue(T *val) inline std::string tuplePairPrintValue(T *val)
{ {
std::string ret("{ "); std::string ret("{ ");
ret += collectionPrinterInternal::tuplePrinter<T>::print(val); ret += collectionPrinterInternal::tuplePrinter<T>::print(val);
@ -259,7 +259,7 @@ namespace cling {
} }
template <class... ARGS> template <class... ARGS>
std::string printValue(std::tuple<ARGS...> *val) inline std::string printValue(std::tuple<ARGS...> *val)
{ {
using T = std::tuple<ARGS...>; using T = std::tuple<ARGS...>;
if (std::tuple_size<T>::value == 0) if (std::tuple_size<T>::value == 0)
@ -268,7 +268,7 @@ namespace cling {
} }
template <class... ARGS> template <class... ARGS>
std::string printValue(std::pair<ARGS...> *val) inline std::string printValue(std::pair<ARGS...> *val)
{ {
using T = std::pair<ARGS...>; using T = std::pair<ARGS...>;
return collectionPrinterInternal::tuplePairPrintValue<T>(val); return collectionPrinterInternal::tuplePairPrintValue<T>(val);