morzhovets / momo

C++ template containers with optimized memory consumption
https://morzhovets.github.io/momo
MIT License
12 stars 2 forks source link

std::exception: Cannot create DataColumnList #1

Closed asidorov95 closed 2 months ago

asidorov95 commented 5 years ago
#include <iostream>
#include "momo/DataTable.h"

namespace a {
    MOMO_DATA_COLUMN_STRING(int, v);
    // MOMO_DATA_COLUMN_STRING(int, v);  //error: redefinition of 'v'
}

namespace b {
    MOMO_DATA_COLUMN_STRING(int, v);
}

int main() try
{
    momo::experimental::DataColumnList<> {a::v, b::v};
    return 0;
}
catch (std::exception &ex)
{
    std::cerr << "std::exception: " << ex.what() << std::endl;
}
morzhovets commented 2 months ago

Starting from v3.9 you can write this way

namespace a {
    /*inline*/ constexpr momo::DataColumn<int> v("a::v");
}
namespace b {
    /*inline*/ constexpr momo::DataColumn<int> v("b::v");
}

int main()
{
    momo::DataColumnList<> columns{ a::v, b::v };
    momo::DataTable<> table({ a::v, b::v });
    return 0;
}