Can I use boost as c++20 module now?

1.8k views Asked by At

I'm using "Visual Studio 2019 16.8 Preview 3"

module;

//#include <boost/algorithm/string.hpp>   // (1) global module fragment
export module M;

import boost;  // (2) as C++20 module

Can I import boost (or part of it) as C++20 module now ? I am using boost 1.73.0 installed by vcpkg.

BTW, I am not sure why this page uses boost as example, https://vector-of-bool.github.io/2019/03/10/modules-1.html

1

There are 1 answers

0
bitnick On

boost is not support module now since gcc12 still not fully support c++ modules. MSVC is the only one fully supported and on Visual Stuidio 2022 import boost works well.

MyModule.cppm

export module MyModule;

export import <boost/any.hpp>;

main.cpp

#include <iostream>

import MyModule;

void main() {
    boost::any object;
    object = 1;
    std::cout << object.type().name();
}