Put enum in tuple and return tuple from C++ function

56 Views Asked by At

How do we pass an enum in a tuple that is returned by a function? I'm trying the following and it compiles but is this the proper way of doing this?:

Code in header (.h file):

enum mode_en { 
    zero = 0, 
    one = 1, 
    two = 2
};
typedef std::tuple<int,int,int, mode_en> mode_tuple;

Code in main (.cpp file)

mode_tuple func(int val_in) {
    mode_tuple ret_tup;
    int a = 0; int b = 0; int c = 0;
    enum mode_en mode_var = zero;
    mode_var = two;
    ret_tup = make_tuple(a, b, c, mode_var);
    return ret_tup; 
}
0

There are 0 best solutions below