Last active
March 23, 2018 16:43
-
-
Save cppljevans/b38704f22c9c92f63cf2ff03ef4c4675 to your computer and use it in GitHub Desktop.
variant implicit conversion test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley $ git clone https://github.com/Kojoley/spirit.git -b x3-variant-fixes x3-variant-fixes | |
Cloning into 'x3-variant-fixes'... | |
remote: Counting objects: 110149, done. | |
remote: Compressing objects: 100% (147/147), done. | |
remote: Total 110149 (delta 137), reused 207 (delta 106), pack-reused 109879 | |
Receiving objects: 100% (110149/110149), 119.05 MiB | 586.00 KiB/s, done. | |
Resolving deltas: 100% (84033/84033), done. | |
Checking connectivity... done. | |
~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley $ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-*- mode: compilation; default-directory: "~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley/test/" -*- | |
Compilation started at Fri Mar 23 10:58:54 | |
make -k all | |
***Without implicit conversion: | |
/home/evansl/dwnlds/llvm/5.0/prebuilt/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04/bin/clang++ -c -O0 -gdwarf-2 -stdlib=libc++ -std=c++17 -ftemplate-backtrace-limit=0 -fdiagnostics-show-template-tree -fno-elide-type -fmacro-backtrace-limit=0 -I../x3-variant-fixes/include -I/home/evansl/prog_dev/boost/releases/ro/boost_1_65_1 -UIMPLICIT_CONVERSION joels_preference.cpp | |
rm joels_preference.o | |
***With implicit conversion: | |
/home/evansl/dwnlds/llvm/5.0/prebuilt/clang+llvm-5.0.0-linux-x86_64-ubuntu16.04/bin/clang++ -c -O0 -gdwarf-2 -stdlib=libc++ -std=c++17 -ftemplate-backtrace-limit=0 -fdiagnostics-show-template-tree -fno-elide-type -fmacro-backtrace-limit=0 -I../x3-variant-fixes/include -I/home/evansl/prog_dev/boost/releases/ro/boost_1_65_1 -DIMPLICIT_CONVERSION joels_preference.cpp | |
Compilation finished at Fri Mar 23 10:58:57 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/spirit/home/x3.hpp> | |
#include <boost/spirit/home/x3/support/ast/variant.hpp> | |
#include <string> | |
#include <iostream> | |
using my_variant_with_int=boost::spirit::x3::variant<int,std::string>; | |
void foo(my_variant_with_int const& var) | |
{ | |
std::cout<<"var="<<boost::get<int>(var)<<"\n"; | |
} | |
int main() | |
{ | |
//#define IMPLICIT_CONVERSION | |
#ifdef IMPLICIT_CONVERSION | |
//This should fail compilation. | |
foo(123); | |
#else | |
//This should pass compilation. | |
foo(my_variant_with_int(123)); | |
#endif | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-*- mode: compilation; default-directory: "~/prog_dev/boost/releases/ro/boost_1_65_1/sandbox/kojoley/test/" -*- | |
Compilation started at Fri Mar 23 11:20:46 | |
make -k ls | |
ls -ld ../x3-variant-fixes/include/* | |
drwxrwxr-x 3 evansl evansl 4096 Mar 22 19:40 ../x3-variant-fixes/include/boost | |
Compilation finished at Fri Mar 23 11:20:46 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment