Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions core/cont/inc/TCollectionProxyInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ template <typename T> class TStdBitsetHelper {
}

namespace Detail {

// Detect whether a type is an instantiation of vector<T,A>
// We need to use a custom type and not an integral constant such as std::true/false_type as mother classes
// because a type of specialized non-type template argument cannot depend on a template parameter of the
// partial specialization
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this work? https://godbolt.org/z/TNDPQI

struct VectorBoolTrue{};
struct VectorBoolFalse{};

template <typename>
struct IsVectorBool_t{
using value = VectorBoolFalse;
};

template <typename A>
struct IsVectorBool_t<std::vector<bool, A>>{
using value = VectorBoolTrue;
};

class TCollectionProxyInfo {
// This class is a place holder for the information needed
// to create the proper Collection Proxy.
Expand Down Expand Up @@ -281,7 +299,7 @@ namespace Detail {
* @version 1.0
* @date 10/10/2004
*/
template <class T> struct Type
template <class T, class V = typename IsVectorBool_t<T>::value> struct Type
: public Address<TYPENAME T::const_reference>
{
typedef T Cont_t;
Expand Down Expand Up @@ -613,16 +631,18 @@ namespace Detail {

};

template <> struct TCollectionProxyInfo::Type<std::vector<Bool_t> >
: public TCollectionProxyInfo::Address<std::vector<Bool_t>::const_reference>
// This specialization is chosen if T is a vector<bool, A>, irrespective of the nature
// of the allocator A represents.
template <class T> struct TCollectionProxyInfo::Type<T, VectorBoolTrue>
: public TCollectionProxyInfo::Address<typename T::const_reference>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would something like this simplify the VectorBoolTrue/False logic? https://godbolt.org/z/_glVS7

{
typedef std::vector<Bool_t> Cont_t;
typedef std::vector<Bool_t>::iterator Iter_t;
typedef std::vector<Bool_t>::value_type Value_t;
typedef Environ<Iter_t> Env_t;
typedef Env_t *PEnv_t;
typedef Cont_t *PCont_t;
typedef Value_t *PValue_t;
typedef T Cont_t;
typedef typename T::iterator Iter_t;
typedef typename T::value_type Value_t;
typedef Environ<Iter_t> Env_t;
typedef Env_t *PEnv_t;
typedef Cont_t *PCont_t;
typedef Value_t *PValue_t;

virtual ~Type() {}

Expand Down Expand Up @@ -675,7 +695,7 @@ namespace Detail {
//typedef Iterators<Cont_t,fgLargeIterator> Iterators_t;

struct Iterators {
typedef Cont_t::iterator iterator;
typedef typename Cont_t::iterator iterator;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this Iter_t above?


static void create(void *coll, void **begin_arena, void **end_arena, TVirtualCollectionProxy*) {
PCont_t c = PCont_t(coll);
Expand Down