[llvm] r208388 - Remove use of = default/= delete as they're unsupported on MSVC2012

NAKAMURA Takumi geek4civic at gmail.com
Thu May 8 20:06:41 PDT 2014


Thanks, David. I wondered how to introduce alternative of defaulted
functions on that.

We can add LLVM_DELETED_FUNCTION with "= delete". It'd be better to
put deleted functions into private scope for deleted-unaware
compilers, though.

Jordan, I wonder how to implement defaulted functions with macros...

1. Conditionalize

#if LLVM_DEFAULTED_FUNCTION_AVAILABLE
  MoveOnly(...) = default;
#endif

2. Conditionalize with macro

#define LLVM_DEFAULTED_FUNCTION(decl) decl = default /* or eliminate entirely */

  LLVM_DEFAULTED_FUNCTION(MoveOnly(...));

3. Give the body to each functionality.

#if !__has_feature(cxx_defaulted_functions)
#  define LLVM_DEFAULTED_EMPTY_CONSTRUCTOR {}
#  define LLVM_DEFAULTED_COPY_FUNCTION(arg) {*this = arg;}
#endif

0. Ask C++ guru!

2014-05-09 11:26 GMT+09:00 David Blaikie <dblaikie at gmail.com>:
> Author: dblaikie
> Date: Thu May  8 21:26:36 2014
> New Revision: 208388
>
> URL: http://llvm.org/viewvc/llvm-project?rev=208388&view=rev
> Log:
> Remove use of = default/= delete as they're unsupported on MSVC2012
>
> Modified:
>     llvm/trunk/unittests/ADT/StringMapTest.cpp
>
> Modified: llvm/trunk/unittests/ADT/StringMapTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringMapTest.cpp?rev=208388&r1=208387&r2=208388&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/ADT/StringMapTest.cpp (original)
> +++ llvm/trunk/unittests/ADT/StringMapTest.cpp Thu May  8 21:26:36 2014
> @@ -221,10 +221,15 @@ TEST_F(StringMapTest, NonDefaultConstruc
>  struct MoveOnly {
>    int i;
>    MoveOnly(int i) : i(i) {}
> -  MoveOnly(MoveOnly &&) = default;
> -  MoveOnly(const MoveOnly &) = delete;
> -  MoveOnly &operator=(MoveOnly &&) = default;
> -  MoveOnly &operator=(const MoveOnly &) = delete;
> +  MoveOnly(MoveOnly &&RHS) : i(RHS.i) {}
> +  MoveOnly &operator=(MoveOnly &&RHS) {
> +    i = RHS.i;
> +    return *this;
> +  }
> +
> +private:
> +  MoveOnly(const MoveOnly &);
> +  MoveOnly &operator=(const MoveOnly &);
>  };
>
>  TEST_F(StringMapTest, MoveOnlyKey) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list