@@ -84,6 +84,61 @@ inline void r_init_vector<EXPRSXP>(SEXP x){}
8484template <>
8585inline void r_init_vector<STRSXP>(SEXP x){}
8686
87+
88+
89+ /* *
90+ * We do not allow List(RTYPE=VECSXP), RawVector(RTYPE=RAWSXP)
91+ * or ExpressionVector(RTYPE=EXPRSXP) to be sorted, so it is
92+ * desirable to issue a compiler error if user attempts to sort
93+ * these types of Vectors.
94+ *
95+ * We declare a template class without defining the generic
96+ * class body, but complete the definition in specialization
97+ * of qualified Vector types. Hence when using this class
98+ * on unqualified Vectors, the compiler will emit errors.
99+ */
100+ template <int RTYPE>
101+ class Sort_is_not_allowed_for_this_type ;
102+
103+ /* *
104+ * Specialization for CPLXSXP, INTSXP, LGLSXP, REALSXP, and STRSXP
105+ */
106+ template <>
107+ class Sort_is_not_allowed_for_this_type <CPLXSXP>
108+ {
109+ public:
110+ static void do_nothing () {}
111+ };
112+
113+ template <>
114+ class Sort_is_not_allowed_for_this_type <INTSXP>
115+ {
116+ public:
117+ static void do_nothing () {}
118+ };
119+
120+ template <>
121+ class Sort_is_not_allowed_for_this_type <LGLSXP>
122+ {
123+ public:
124+ static void do_nothing () {}
125+ };
126+
127+ template <>
128+ class Sort_is_not_allowed_for_this_type <REALSXP>
129+ {
130+ public:
131+ static void do_nothing () {}
132+ };
133+
134+ template <>
135+ class Sort_is_not_allowed_for_this_type <STRSXP>
136+ {
137+ public:
138+ static void do_nothing () {}
139+ };
140+
141+
87142} // internal
88143} // Rcpp
89144
0 commit comments