LoginSignup
3
1

C++ Templates The Complete Guide(2nd Edition)をclang++とg++でコンパイルしてみた

Last updated at Posted at 2018-05-06

C++のTemplate使いこなせてない。
The Complete Guide(2nd Edition)
http://www.tmplbook.com/code/code.html
コンパイルしながら勉強。

勉強の記録
https://researchmap.jp/joqzln3gi-1797580た/#_1797580
だと, qiitaのようにコード表示機能がないためわかりにくい。

<この項は書きかけです。順次追記します。>

compiler

最初はclang++だけで実施。
後日g++をupgradeした時に実施。

clang++

clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

g++

g++ (Homebrew GCC 8.1.0) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# コンパイルスクリプト
毎回コンパイル条件を変えてコンパイルするのに、一気にコンパイルする方法
ひとまずbasicsフォルダ内

ca.sh
#!/bin/bash
while read line
do
  echo "clang++ $line -std=c++2a -Wall"
  clang++ $line -std=c++2a -Wall 
  if [  -e a.out ]; then
  ./a.out
  rm a.out
  fi
done < ./$1

ファイル一覧をbaという名前のファイルで保存。

ba
arrays.cpp
cref.cpp
errornovel1.cpp
errornovel2.cpp
foldtraverse.cpp
foreach.cpp
foreachinvoke.cpp
max1.cpp
max2.cpp
max3ref.cpp
max3val.cpp
max4.cpp
message.cpp
move1.cpp
move2.cpp
myfirst.cpp
myfirstmain.cpp
referror1.cpp
referror2.cpp
specialmemtmpl1.cpp
specialmemtmpl3.cpp
stack1test.cpp
stack3test.cpp
stack9test.cpp
stackauto.cpp
stacknontype.cpp
tmplparamref.cpp
varusing.cpp

同様に、ga.shを作成

ga.sh
#!/bin/bash
while read line
do
  echo "g++ $line -std=c++2a -Wall"
  g++ $line -std=c++2a -Wall 
  if [  -e a.out ]; then
  ./a.out
  rm a.out
  fi
done < ./$1
ca.sh
cd basics 
../ca.sh ba > ba.log.txt &> ba.log.txt
../ga.sh ba > bag.log.txt &> bag.log.txt
cat bag.log.txt >> ba.log.txt

#basics
ba.log.txtは下記 researchmapは拡張子logに対応していない。
https://researchmap.jp/mu1t6mv58-45645/?action=multidatabase_action_main_filedownload&download_flag=1&upload_id=160189&metadata_id=25961

basics clang++ g++
error warning link error execute error error warning link error execute error
arrays.cpp
cref.cpp
errornovel1.cpp 1 1 1 1
errornovel2.cpp 1 1
foldtraverse.cpp 1 1
foreach.cpp
foreachinvoke.cpp
max1.cpp
max2.cpp 1
max3ref.cpp 3 3 1
max3val.cpp 3 3
max4.cpp
message.cpp
move1.cpp
move2.cpp
myfirst.cpp 1 1
myfirstmain.cpp 1 1
referror1.cpp 3 4 2
referror2.cpp 17 19
specialmemtmpl1.cpp
specialmemtmpl3.cpp
stack1test.cpp
stack3test.cpp
stack9test.cpp
stackauto.cpp
stacknontype.cpp
tmplparamref.cpp
varusing.cpp

myfirst.cppとmyfirstmain.cppは一緒にコンパイルする必要があった。
myfirst.cppとmyfirstmain.cppを一緒にコンパイルしてもエラーがあった。

myfirstmain.cppのincludeファイルをmyfirst2.hppに変え、myfirstmain.cppだけでコンパイルしたらコンパイルエラーがなくなった。

そういう題材らしい。

後の、errornovel1.cpp, referror1.cpp, referror2.cppは
ファイル名にあるようにエラーを生成することが目的らしい。

C++ Templates The Complete Guide(2nd Edition) (1) basics/errornovel1.cpp
https://qiita.com/kaizen_nagoya/items/f4dd6ec5fc71e51d8477

C++ Templates The Complete Guide(2nd Edition) (2) referror1.cpp
https://qiita.com/kaizen_nagoya/items/dbd48c3d3b2b250cfa03

C++ Templates The Complete Guide(2nd Edition) (4) inherit/projectioniterator.cpp
https://qiita.com/kaizen_nagoya/items/c8cfcb94e8b3fe499952

C++ Templates The Complete Guide(2nd Edition) (5) inherit/wrapper.cpp
https://qiita.com/kaizen_nagoya/items/8e394f087577201c0419

C++ Templates (6)3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed

C++ Templates The Complete Guide(2nd Edition) (7) deduce/aliastemplate.cpp
https://qiita.com/kaizen_nagoya/items/780332262308f1113cc4

details

cs.sh
cd details
../ca.sh de > de.log.txt &>   de.log.txt
../ga.sh de > deg.log.txt &>   deg.log.txt
cat deg.log.txt >>de.log.txt

de.log.txt researchmapは拡張子logに対応していないためtxtを付加。
https://researchmap.jp/mucn5h1pu-45645/?action=multidatabase_action_main_filedownload&download_flag=1&upload_id=160199&metadata_id=25961

de
adl.cpp
fppm.cpp
funcoverload1.cpp
funcoverload2.cpp
implicit.cpp
inject.cpp
lazy2.cpp
max.cpp
nontmpl1.cpp
nontmpl2.cpp
tmplconstr.cpp
tupleoverload.cpp
variadicoverload.cpp                    
details clang++ g++
error warning link error execution error error warning link error execution error
adl.cpp
fppm.cpp 1 1
funcoverload1.cpp
funcoverload2.cpp
implicit.cpp 1 1
inject.cpp 1
lazy2.cpp 1 1
max.cpp
nontmpl1.cpp
nontmpl2.cpp
tmplconstr.cpp
tupleoverload.cpp
variadicoverload.cpp

inherit

ca.sh
cd inherit
 ../ca.sh in > in.log.txt &> in.log.txt
../ga.sh in > ing.log.txt &>  ing.log.txt
cat ing.log.txt >>in.log.txt

in.log.txtは下記
https://researchmap.jp/muv5r7yo6-45645/?action=multidatabase_action_main_filedownload&download_flag=1&upload_id=160208&metadata_id=25961

in
countertest.cpp
ebco1.cpp
ebco2.cpp
empty.cpp
equalitycomparable.cpp
projectioniterator.cpp
virtual.cpp
wrapper.cpp
inherit clang++ g++
error warning link error execution error error warning link error execution error
countertest.cpp
ebco1.cpp
ebco2.cpp 1 1
empty.cpp
equalitycomparable.cpp 1 1 1
projectioniterator.cpp 5 8
virtual.cpp
wrapper.cpp 1 1

実行エラーは、Illegal instruction: 4

#traits

ca.sh
cd traits
../ca.sh tr > tr.log.txt &> tr.log.txt
../ga.sh tr > trg.log.txt &> trg.log.txt
cat trg.log.txt >>tr.log.txt

tr.log.txtは下記。警告、エラーがない初めての章。
https://researchmap.jp/muv5r7yo6-45645/?action=multidatabase_action_main_filedownload&download_flag=1&upload_id=160208&metadata_id=25961

tr
accum1.cpp
accum6.cpp
decay.cpp
elementtype.cpp
hasmember.cpp
hastype.cpp
isfundatest.cpp
issame.cpp
isvalid1.cpp
isvalid2.cpp
passbyvalue.cpp
rparam1.cpp
rparam2.cpp
sizeof.cpp
traits clang++ g++
error warning link error execution error error warning link error execution error
accum1.cpp
accum6.cpp
decay.cpp
elementtype.cpp
hasmember.cpp
hastype.cpp
isfundatest.cpp
issame.cpp
isvalid1.cpp
isvalid2.cpp
passbyvalue.cpp
rparam1.cpp
rparam2.cpp
sizeof.cpp

#その他
cppファイルが3つ以下のディレクトリはまとめて

cs.sh
cd ..
./ca.sh sm > sm.log.txt &>  sm.log.txt
../ga.sh sm > smg.log.txt &> smg.log.txt
cat smg.log.txt >> sm.log.txt
sm
./bridge/forupto1.cpp
./bridge/forupto4.cpp
./debugging/tracertest.cpp
./deduce/aliastemplate.cpp
./deduce/initlist.cpp
./deduce/resulttypetmpl.cpp
./exprtmpl/sarray1.cpp
./exprtmpl/sarray2.cpp
./meta/sqrt1.cpp
./meta/unruh.cpp
./names/anglebrackethack.cpp
./overload/initlist.cpp
./overload/initlistctor.cpp
./overload/initlistovl.cpp
./poly/dynapoly.cpp
./poly/printmax.cpp
./poly/staticpoly.cpp
./tuples/compressedtuple1.cpp
./tuples/indexsort.cpp
./typeoverload/min.cpp
./utils/isconstructible.cpp
./utils/traits1.cpp
./utils/traits2.cpp

sm.log.txt
https://researchmap.jp/mud6n5ju6-45645/?action=multidatabase_action_main_filedownload&download_flag=1&upload_id=160207&metadata_id=25961

clang++ g++
error warning link error execution error error warning link error execution error
./bridge/forupto1.cpp
./bridge/forupto4.cpp 7 10
./debugging/tracertest.cpp
./deduce/aliastemplate.cpp 14 21
./deduce/initlist.cpp 1 1
./deduce/resulttypetmpl.cpp 1 1
./exprtmpl/sarray1.cpp
./exprtmpl/sarray2.cpp 2 2
./meta/sqrt1.cpp
./meta/unruh.cpp 7 11 1 2
./names/anglebrackethack.cpp
./overload/initlist.cpp
./overload/initlistctor.cpp
./overload/initlistovl.cpp
./poly/dynapoly.cpp 2 2
./poly/printmax.cpp
./poly/staticpoly.cpp 4 4
./tuples/compressedtuple1.cpp
./tuples/indexsort.cpp
./typeoverload/min.cpp 20 30
./utils/isconstructible.cpp :
./utils/traits1.cpp 1 1
./utils/traits2.cpp

#variant
Chapter 26.

va.log.txt
clang++ printrec.cpp -std=c++2a -Wall
printrec.cpp:1:10: fatal error: 'variant-all.hpp' file not found
#include "variant-all.hpp"
         ^~~~~~~~~~~~~~~~~

variant-all.hppファイルは存在しない。
Kindle版で確認すると文章上は
variant.hpp
担って要る。

ファイル名の最後に-2をつけ

//#include "variant-all.hpp"
#include "variant.hpp"

としてコンパイル

va-2.log.txt
$ cat va-2.log.1st
clang++ printrec-2.cpp -std=c++2a -Wall
In file included from printrec-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
12 errors generated.
clang++ variant-2.cpp -std=c++2a -Wall
In file included from variant-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
variant-2.cpp:9:19: error: expected '(' for function-style cast or type construction
  if (field.is<int>()) {
               ~~~^
variant-2.cpp:9:21: error: expected expression
  if (field.is<int>()) {
                    ^
variant-2.cpp:10:62: error: expected '(' for function-style cast or type construction
    std::cout << "Field stores the integer " << field.get<int>()
                                                          ~~~^
variant-2.cpp:10:64: error: expected expression
    std::cout << "Field stores the integer " << field.get<int>()
                                                               ^
variant-2.cpp:16:37: error: expected '(' for function-style cast or type construction
            << field.get<std::string>() << '\"' << std::endl;
                         ~~~~~~~~~~~^
variant-2.cpp:16:39: error: expected expression
            << field.get<std::string>() << '\"' << std::endl;
                                      ^
18 errors generated.
clang++ variantdefaultctor-2.cpp -std=c++2a -Wall
In file included from variantdefaultctor-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
variantdefaultctor-2.cpp:8:15: error: expected '(' for function-style cast or type construction
  if (v.is<int>()) {
           ~~~^
variantdefaultctor-2.cpp:8:17: error: expected expression
  if (v.is<int>()) {
                ^
variantdefaultctor-2.cpp:10:29: error: expected '(' for function-style cast or type construction
                << v.get<int>() << '\n';
                         ~~~^
variantdefaultctor-2.cpp:10:31: error: expected expression
                << v.get<int>() << '\n';
                              ^
variantdefaultctor-2.cpp:13:19: error: expected '(' for function-style cast or type construction
  if (v2.is<double>()) {
            ~~~~~~^
variantdefaultctor-2.cpp:13:21: error: expected expression
  if (v2.is<double>()) {
                    ^
variantdefaultctor-2.cpp:15:33: error: expected '(' for function-style cast or type construction
                << v2.get<double>() << '\n';
                          ~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
clang++ variantexception-2.cpp -std=c++2a -Wall
In file included from variantexception-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
variantexception-2.cpp:39:18: error: expected '(' for function-style cast or type construction
    if (!v.is<int>() && !v.is<NonCopyable>()) {
              ~~~^
variantexception-2.cpp:39:20: error: expected expression
    if (!v.is<int>() && !v.is<NonCopyable>()) {
                   ^
variantexception-2.cpp:39:31: error: 'NonCopyable' does not refer to a value
    if (!v.is<int>() && !v.is<NonCopyable>()) {
                              ^
variantexception-2.cpp:11:7: note: declared here
class NonCopyable
      ^
variantexception-2.cpp:39:44: error: expected expression
    if (!v.is<int>() && !v.is<NonCopyable>()) {
                                           ^
16 errors generated.
clang++ variantpromote-2.cpp -std=c++2a -Wall
In file included from variantpromote-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
variantpromote-2.cpp:11:56: error: expected '(' for function-style cast or type construction
  std::cout << "v2 contains the integer " << v2.get<int>() << '\n';
                                                    ~~~^
variantpromote-2.cpp:11:58: error: expected expression
  std::cout << "v2 contains the integer " << v2.get<int>() << '\n';
                                                         ^
variantpromote-2.cpp:15:58: error: expected '(' for function-style cast or type construction
  std::cout << "v3 contains the double " << v3.get<double>() << '\n';
                                                   ~~~~~~^
variantpromote-2.cpp:15:60: error: expected expression
  std::cout << "v3 contains the double " << v3.get<double>() << '\n';
                                                           ^
16 errors generated.
clang++ visit-2.cpp -std=c++2a -Wall
In file included from visit-2.cpp:2:
./variant.hpp:3:12: error: unknown template name 'VariantStorage'
 : private VariantStorage<Types...>,
           ^
./variant.hpp:4:12: error: unknown template name 'VariantChoice'
   private VariantChoice<Types, Types...>...
           ^
./variant.hpp:16:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:17:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&...> visit(Visitor&& vis) &; 
    ^
./variant.hpp:18:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:19:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types const&...> visit(Visitor&& vis) const&;
    ^
./variant.hpp:20:25: error: unknown type name 'ComputedResultType'
  template<typename R = ComputedResultType, typename Visitor>
                        ^
./variant.hpp:21:5: error: no template named 'VisitResult'
    VisitResult<R, Visitor, Types&&...> visit(Visitor&& vis) &&;
    ^
./variant.hpp:23:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::VariantChoice...;
        ^
./variant.hpp:23:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::VariantChoice...;
                     ^
                     ;
./variant.hpp:32:9: error: using declaration requires a qualified name
  using VariantChoice<Types, Types...>::operator=...;
        ^
./variant.hpp:32:22: error: expected ';' after using declaration
  using VariantChoice<Types, Types...>::operator=...;
                     ^
                     ;
12 errors generated.

現在、cppファイルにhppファイルのincludeを追記中。

1. 分かったこと

コンパイルエラーを出すことが目的のファイル(なんちゃらerror.cpp)がある。

2つのファイルをコンパイルする必要のあるファイル(myfirst.cpp)がある

ヘッダファイルを切り替えてコンパイルするファイルがある。

2. 分からなかったこと

Templateの本質

3. 良かったこと

最初にコンパイルエラーが出た4つのうち1つはコンパイルエラーが取れた。
後の3つはコンパイルエラーを出すことが目的だったらしい。

4. 改めること

全体をコンパイルして結果を集計する記述または枠組(framework)

参考文献(reference)

###プログラミング言語教育のXYZ
https://qiita.com/kaizen_nagoya/items/1950c5810fb5c0b07be4
プログラミング言語教育のXYZ(youtube)
https://www.youtube.com/watch?v=He1_tg4px-w&t=486s

###C++N4741 2018
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4741.pdf

C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010

###C++N4606 2016
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf

C++N4606, 2016符号断片編纂一覧(example code compile list)
Working Draft 2016, ISO/IEC 14882(1)
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

### CEDD(Compile Error Driven Design)
初めての CEDD(Compile Error Driven Design) 8回直してコンパイル。
https://qiita.com/kaizen_nagoya/items/9494236aa1753f3fd1e1

コンパイルエラーを記録するとよい理由7つ
https://qiita.com/kaizen_nagoya/items/85c0e92b206883140e89

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de

docker gnu(gcc/g++) and llvm(clang/clang++)
https://qiita.com/drafts/059874ea39c4de64c0f7

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

文書履歴(document history)

ver 0.10 初稿 20180506
ver 0.11 bridge追記 20180506
ver 0.12 cdコマンド追記 20180508
ver 0.20 g++追記 20180509
ver 0.21 variantフォルダのコンパイル途中結果を記載 20180510
ver 0.22 一覧にフォルダ名を追記 20180515
ver 0.23 basics/errornovel1.cpp URL追記 20180614
ver 0.24 参考文献、コンパイルURL追記 20180616

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1