File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414STD ?= c11
1515PEDANTIC ?= -pedantic-errors
1616CFLAGS ?= -g$(G) -march=native -O$(O) -pthread -std=$(STD) -Wall -Wextra $(PEDANTIC) $(CFLAGS_EXTRA) #-pg
17- MYCXXFLAGS ?= -g$(G) -march=native -O$(O) -pthread -std=c++14 -Wall -Wextra $(PEDANTIC) $(CXXFLAGS_EXTRA) #-pg
17+ MYCXXFLAGS ?= -g$(G) -march=native -O$(O) -pthread -std=c++17 -Wall -Wextra $(PEDANTIC) $(CXXFLAGS_EXTRA) #-pg
1818
1919LIBS ?= -lm -lrt $(LIBS_EXTRA) #-lGL -lGLU -lglut
2020
Original file line number Diff line number Diff line change @@ -22,13 +22,7 @@ int main() {
2222 /*
2323 # make_tuple
2424
25- forwards arguments to tuple constructor.
26-
27- The advantage over the constructor is that since it is a function
28- template argument deduction can be done, so we don't need to type in
29- template arguments.
30-
31- Remember that template argument deduction cannot be done for constructors.
25+ Analogous to make_pair, but with variable number of arguments. Pretty neat.
3226 */
3327 {
3428 std::tuple<int ,char ,std::string> t;
@@ -111,6 +105,18 @@ int main() {
111105 // If only we could save both types and assignments...
112106 // http://stackoverflow.com/questions/29312154/how-to-create-a-new-variable-and-use-stdtie-at-the-same-time
113107 // http://codereview.stackexchange.com/questions/61499/a-tuple-unpacking-macro-that-approximates-python-elegance
108+
109+ // Structured bindings
110+ // https://stackoverflow.com/questions/29312154/how-to-create-a-new-variable-and-use-stdtie-at-the-same-time
111+ {
112+ #if __cplusplus >= 201703L
113+ auto tuple = std::make_tuple (1 , ' a' , 2.3 );
114+ auto [ i, c, d ] = tuple;
115+ jassert (i == 1 );
116+ assert (c == ' a' );
117+ assert (d == 2.3 );
118+ }
119+ #endif
114120 }
115121
116122 /*
You can’t perform that action at this time.
0 commit comments