-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
Example of the issue:
#define variant_CONFIG_SELECT_VARIANT 1
#include <variant>
#include "nonstd/variant.hpp"
#include <string>
struct tag_t {};
struct myvisitor {
const std::string& operator()(const int&) const { throw std::exception(); }
const std::string& operator()(const tag_t&) const { throw std::exception(); }
const std::string& operator()(const std::string& s) const { return s; }
};
void test_std() {
std::variant<int, tag_t, std::string> v("hello");
std::visit(myvisitor(), v);
}
void test_nonstd() {
nonstd::variant<int, tag_t, std::string> v("hello");
nonstd::visit(myvisitor(), v);
}
int main() {
test_std();
test_nonstd();
}
The STL version of variant compiles and works. nonstd::variant throws a compile error:
./nonstd/variant.hpp:1925:16: error: reference to type 'const std::__1::basic_string<char>' requires an initializer
return R();
Metadata
Metadata
Assignees
Labels
No labels