Skip to content

Commit 97ad855

Browse files
committedMar 24, 2025
remove macros for unordered maps/sets
1 parent 30edbf5 commit 97ad855

File tree

7 files changed

+39
-23
lines changed

7 files changed

+39
-23
lines changed
 

‎ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2025-03-24 Iñaki Ucar <iucar@fedoraproject.org>
2+
3+
* inst/include/Rcpp/platform/compiler.h: Remove definitions of
4+
RCPP_USING_UNORDERED_MAP and RCPP_USING_UNORDERED_SET, deprecate macros
5+
RCPP_UNORDERED_MAP and RCPP_UNORDERED_SET
6+
* inst/include/Rcpp/sugar/sets.h: Remove redefinition of macros
7+
* inst/include/Rcpp/sugar/functions/self_match.h: Replace macros with
8+
std::unordered_map and std::unordered_set respectively
9+
* inst/include/Rcpp/sugar/functions/setdiff.h: Idem
10+
* inst/include/Rcpp/sugar/functions/table.h: Idem
11+
* inst/tinytest/cpp/wrap.cpp: Idem
12+
113
2025-03-21 Dirk Eddelbuettel <edd@debian.org>
214

315
* DESCRIPTION (Version, Date): Roll micro version and date

‎inst/include/Rcpp/platform/compiler.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// compiler.h: Rcpp R/C++ interface class library -- check compiler
22
//
33
// Copyright (C) 2012 - 2025 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey
4+
// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois, Kevin Ushey and Iñaki Ucar
45
//
56
// This file is part of Rcpp.
67
//
@@ -36,11 +37,13 @@
3637
#include <cmath>
3738
#include <initializer_list>
3839
#include <unordered_map>
39-
#define RCPP_USING_UNORDERED_MAP
40-
#define RCPP_UNORDERED_MAP std::unordered_map
40+
#define RCPP_UNORDERED_MAP \
41+
_Pragma("GCC warning \"RCPP_UNORDERED_MAP is deprecated, use std::unordered_map instead\"") \
42+
std::unordered_map
4143
#include <unordered_set>
42-
#define RCPP_USING_UNORDERED_SET
43-
#define RCPP_UNORDERED_SET std::unordered_set
44+
#define RCPP_UNORDERED_SET \
45+
_Pragma("GCC warning \"RCPP_UNORDERED_SET is deprecated, use std::unordered_set instead\"") \
46+
std::unordered_set
4447

4548
#if defined(__GNUC__)
4649
#define RCPP_HAS_DEMANGLING

‎inst/include/Rcpp/sugar/functions/self_match.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// self_match.h: Rcpp R/C++ interface class library -- self match
44
//
5-
// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2012 - 2024 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
67
//
78
// This file is part of Rcpp.
89
//
@@ -57,7 +58,7 @@ class SelfMatch {
5758
inline operator IntegerVector() const { return result ; }
5859

5960
private:
60-
typedef RCPP_UNORDERED_MAP<STORAGE, int> HASH ;
61+
typedef std::unordered_map<STORAGE, int> HASH ;
6162
typedef SelfInserter<HASH,STORAGE> Inserter ;
6263
HASH hash ;
6364
IntegerVector result ;

‎inst/include/Rcpp/sugar/functions/setdiff.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// setdiff.h: Rcpp R/C++ interface class library -- setdiff
44
//
5-
// Copyright (C) 2012 - 2014 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2012 - 2024 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
67
//
78
// This file is part of Rcpp.
89
//
@@ -60,7 +61,7 @@ namespace sugar{
6061
}
6162

6263
private:
63-
typedef RCPP_UNORDERED_SET<STORAGE> SET ;
64+
typedef std::unordered_set<STORAGE> SET ;
6465
typedef typename SET::const_iterator ITERATOR ;
6566
SET lhs_set ;
6667
SET rhs_set ;
@@ -89,7 +90,7 @@ namespace sugar{
8990
}
9091

9192
private:
92-
typedef RCPP_UNORDERED_SET<STORAGE> SET ;
93+
typedef std::unordered_set<STORAGE> SET ;
9394
typedef typename SET::const_iterator ITERATOR ;
9495
SET lhs_set ;
9596
SET rhs_set ;
@@ -123,7 +124,7 @@ namespace sugar{
123124
}
124125

125126
private:
126-
typedef RCPP_UNORDERED_SET<STORAGE> SET ;
127+
typedef std::unordered_set<STORAGE> SET ;
127128
typedef typename SET::const_iterator ITERATOR ;
128129
SET intersect ;
129130

@@ -148,7 +149,7 @@ namespace sugar{
148149
}
149150

150151
private:
151-
typedef RCPP_UNORDERED_SET<STORAGE> SET ;
152+
typedef std::unordered_set<STORAGE> SET ;
152153
typedef typename SET::const_iterator ITERATOR ;
153154
SET result ;
154155

‎inst/include/Rcpp/sugar/functions/table.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// table.h: Rcpp R/C++ interface class library -- table match
22
//
33
// Copyright (C) 2012 - 2025 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey
4+
// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois, Kevin Ushey and Iñaki Ucar
45
//
56
// This file is part of Rcpp.
67
//
@@ -77,7 +78,7 @@ class Table {
7778
}
7879

7980
private:
80-
typedef RCPP_UNORDERED_MAP<STORAGE, int> HASH ;
81+
typedef std::unordered_map<STORAGE, int> HASH ;
8182
typedef CountInserter<HASH,STORAGE> Inserter ;
8283
HASH hash ;
8384

‎inst/include/Rcpp/sugar/sets.h

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#ifndef Rcpp__sugar__sets_h
2121
#define Rcpp__sugar__sets_h
2222

23-
#define RCPP_UNORDERED_SET std::unordered_set
24-
#define RCPP_UNORDERED_MAP std::unordered_map
25-
2623
namespace std {
2724
template<>
2825
struct hash<Rcpp::String> {

‎inst/tinytest/cpp/wrap.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// wrap.cpp: Rcpp R/C++ interface class library -- wrap unit tests
44
//
55
// Copyright (C) 2013 - 2025 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
67
//
78
// This file is part of Rcpp.
89
//
@@ -170,7 +171,7 @@ SEXP nonnull_const_char(){
170171

171172
// [[Rcpp::export]]
172173
IntegerVector unordered_map_string_int(){
173-
RCPP_UNORDERED_MAP< std::string, int > m ;
174+
std::unordered_map< std::string, int > m ;
174175
m["b"] = 100;
175176
m["a"] = 200;
176177
m["c"] = 300;
@@ -179,7 +180,7 @@ IntegerVector unordered_map_string_int(){
179180

180181
// [[Rcpp::export]]
181182
IntegerVector unordered_map_rcpp_string_int(StringVector v){
182-
RCPP_UNORDERED_MAP< String, int > m ;
183+
std::unordered_map< String, int > m ;
183184
m[v[0]] = 200;
184185
m[v[1]] = 100;
185186
m[v[2]] = 300;
@@ -188,7 +189,7 @@ IntegerVector unordered_map_rcpp_string_int(StringVector v){
188189

189190
// [[Rcpp::export]]
190191
LogicalVector unordered_set_rcpp_string(StringVector x) {
191-
RCPP_UNORDERED_SET<String> seen;
192+
std::unordered_set<String> seen;
192193
LogicalVector out(x.size());
193194
for (int i = 0; i < x.size(); i++) {
194195
out[i] = !seen.insert(x[i]).second;
@@ -198,7 +199,7 @@ LogicalVector unordered_set_rcpp_string(StringVector x) {
198199

199200
// [[Rcpp::export]]
200201
NumericVector unordered_map_string_double(){
201-
RCPP_UNORDERED_MAP<std::string,double> m ;
202+
std::unordered_map<std::string,double> m ;
202203
m["b"] = 100;
203204
m["a"] = 200;
204205
m["c"] = 300;
@@ -207,7 +208,7 @@ NumericVector unordered_map_string_double(){
207208

208209
// [[Rcpp::export]]
209210
LogicalVector unordered_map_string_bool(){
210-
RCPP_UNORDERED_MAP<std::string,bool> m ;
211+
std::unordered_map<std::string,bool> m ;
211212
m["b"] = true;
212213
m["a"] = false;
213214
m["c"] = true;
@@ -216,7 +217,7 @@ LogicalVector unordered_map_string_bool(){
216217

217218
// [[Rcpp::export]]
218219
RawVector unordered_map_string_Rbyte(){
219-
RCPP_UNORDERED_MAP<std::string,Rbyte> m ;
220+
std::unordered_map<std::string,Rbyte> m ;
220221
m["b"] = (Rbyte)0;
221222
m["a"] = (Rbyte)1;
222223
m["c"] = (Rbyte)2;
@@ -225,7 +226,7 @@ RawVector unordered_map_string_Rbyte(){
225226

226227
// [[Rcpp::export]]
227228
CharacterVector unordered_map_string_string(){
228-
RCPP_UNORDERED_MAP<std::string,std::string> m ;
229+
std::unordered_map<std::string,std::string> m ;
229230
m["b"] = "foo" ;
230231
m["a"] = "bar" ;
231232
m["c"] = "bling" ;
@@ -234,7 +235,7 @@ CharacterVector unordered_map_string_string(){
234235

235236
// [[Rcpp::export]]
236237
List unordered_map_string_generic(){
237-
RCPP_UNORDERED_MAP< std::string,std::vector<int> > m ;
238+
std::unordered_map< std::string,std::vector<int> > m ;
238239
std::vector<int> b; b.push_back(1); b.push_back(2); m["b"] = b ;
239240
std::vector<int> a; a.push_back(1); a.push_back(2); a.push_back(2); m["a"] = a;
240241
std::vector<int> c; c.push_back(1); c.push_back(2); c.push_back(2); c.push_back(2); m["c"] = c;

0 commit comments

Comments
 (0)
Failed to load comments.